Generate AI images via Telegram with WaveSpeed, credit system, PIX and S3
๐ค Generate images via Telegram using an AI bot with a credit system and S3 storage
A complete, production-ready Telegram bot for AI-powered image generation and editing, featuring a built-in credit system, payment integration, and cloud storage.
โจ Features
๐จ AI Image Generation Text-to-Image: Generate stunning images from text prompts using the Nano Banana Pro Ultra model via WaveSpeed API Image-to-Image Editing: Edit existing images by sending a photo with a caption describing the desired changes Multiple Resolutions: Support for both 4K and 8K output quality Flexible Aspect Ratios: Choose from 10 different aspect ratios (1:1, 3:2, 2:3, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9)
๐ณ Credit Management System Per-generation billing**: Different costs for 4K vs 8K resolution Balance tracking**: Real-time credit balance displayed to users Initial credits**: New users receive starter credits automatically Insufficient balance handling**: Graceful messages when credits run out
Here's the adjusted payment section:
๐ฐ Payment Integration (Mercado Pago PIX)
> 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: Multiple deposit options**: Pre-configured credit packages (R$ 3, R$ 6, R$ 10) QR Code generation**: Automatic PIX QR code sent directly to users via Telegram Copy-paste code**: PIX code provided for manual payment Webhook confirmation**: Real-time payment status updates via Mercado Pago webhooks Auto credit top-up**: Credits added automatically upon payment approval Payment status handling**: Supports approved, pending, and rejected states
> ๐ก 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.
โ๏ธ User Configuration Resolution settings**: Users can set their preferred default resolution Aspect ratio preferences**: Save preferred aspect ratio for future generations Custom default prompts**: Set a default prompt that's automatically appended to all generations Persistent settings**: All preferences stored in n8n Data Tables
๐ฆ Cloud Storage (S3/MinIO) Automatic upload**: Generated images are automatically uploaded to S3-compatible storage Persistent URLs**: Images remain accessible via permanent links Edit from storage**: Reference previously uploaded images for editing
๐ ๏ธ Tech Stack
| 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 |
๐ Prerequisites
Before using this workflow, you'll need:
Telegram Bot Token - Create a bot via @BotFather WaveSpeed API Key - Sign up at WaveSpeed S3-compatible Storage - MinIO, AWS S3, or any S3-compatible service Mercado Pago Account (optional) - For payment integration n8n Data Table - Create a table with the required schema
๐ Data Table Schema
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 |
โก Quick Setup
Import the workflow into your n8n instance Configure the Global Environment node with your settings: botName: Your bot's display name botToken: Your Telegram bot token dataTableId: Your n8n Data Table ID bucketName: Your S3 bucket name initialCredits: Credits given to new users generateImageCost4k: Cost per 4K image generateImageCost8k: Cost per 8K image Set up credentials: Telegram API credentials WaveSpeed API credentials S3 credentials Mercado Pago credentials (if using payments) Activate the workflow
๐ฎ Bot Commands
| 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 |
๐ Workflow Flow
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 โโโโโโโโโโโโโโ
๐ Notes
The workflow uses polling to check generation status - WaveSpeed processes may take up to 1 minute Credits are deducted when the task is submitted and refunded if generation fails All user states are managed through the Data Table for persistence across restarts
๐ License
Free to use and modify. Attribution appreciated but not required.
Related Templates
Automate Daily Keyword Research with Google Sheets, Suggest API & Custom Search
Who's it for This workflow is perfect for SEO specialists, marketers, bloggers, and content creators who want to automa...
USDT And TRC20 Wallet Tracker API Workflow for n8n
Overview This n8n workflow is specifically designed to monitor USDT TRC20 transactions within a specified wallet. It u...
Add product ideas to Google Sheets via a Slack
Use Case This workflow is a slight variation of a workflow we're using at n8n. In most companies, employees have a lot o...
๐ Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments