A complete, production-ready Telegram bot for AI-powered image generation and editing, featuring a built-in credit system, payment integration, and cloud storage.
Here's the adjusted payment section:
About PIX: PIX is Brazil's instant payment system, launched by the Central Bank of Brazil in 2020. It allows instant money transfers 24/7, 365 days a year, using QR codes or copy-paste codes. It has become the most popular payment method in Brazil due to its speed and zero fees for individuals.
This workflow includes a fully integrated PIX payment flow as a reference implementation. You can adapt it to your local payment provider.
Features:
💡 Tip: To adapt this for other regions, replace the Mercado Pago nodes with your preferred payment gateway (Stripe, PayPal, etc.) while keeping the same credit update logic.
| Component | Technology |
|---|---|
| Bot Platform | Telegram Bot API |
| AI Generation | WaveSpeed API (Nano Banana Pro) |
| Storage | S3-compatible (MinIO/AWS S3) |
| Database | n8n Data Tables |
| Payments | Mercado Pago PIX |
| Automation | n8n |
Before using this workflow, you'll need:
Create a Data Table with the following columns:
| Column | Type | Description |
|---|---|---|
chat_id |
String | Telegram chat ID (primary key) |
username |
String | Telegram username |
status |
String | Current user state in the flow |
credits |
String | User's credit balance |
resolution |
String | Preferred resolution (4k/8k) |
aspect_ratio |
String | Preferred aspect ratio |
user_default_prompt |
String | Custom default prompt |
number_images |
Number | Total images generated |
number_videos |
Number | Total videos generated |
demo_sended |
Boolean | Welcome demo sent flag |
botName: Your bot's display namebotToken: Your Telegram bot tokendataTableId: Your n8n Data Table IDbucketName: Your S3 bucket nameinitialCredits: Credits given to new usersgenerateImageCost4k: Cost per 4K imagegenerateImageCost8k: Cost per 8K image| Command | Description |
|---|---|
/start |
Initialize bot and receive welcome message |
menu |
Return to main menu |
config |
Open settings menu |
| Any text | Generate image from prompt (when in generation mode) |
| Photo + caption | Edit the photo based on the caption |
User Message → Telegram Trigger → Route by Status
↓
┌───────────────────┼───────────────────┐
↓ ↓ ↓
New User Generate Image Edit Image
↓ ↓ ↓
Welcome Flow Check Credits Check Credits
↓ ↓ ↓
Create User Submit to WaveSpeed Upload to S3
↓ ↓ ↓
Show Menu Poll for Result Submit Edit
↓ ↓
Download Image Poll for Result
↓ ↓
Send to User ←←←←←←←←←←←←←┘
Free to use and modify. Attribution appreciated but not required.