๐ŸŽฌ Generate AI images via Telegram with WaveSpeed, credit system, PIX and S3

โšก 65 views ยท ๐ŸŽฌ Content Creation & Video

Description

๐Ÿค– 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

๐Ÿ’ณ Credit Management System

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:

> ๐Ÿ’ก 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

๐Ÿ“ฆ Cloud Storage (S3/MinIO)


๐Ÿ› ๏ธ Tech Stack

ComponentTechnology
Bot PlatformTelegram Bot API
AI GenerationWaveSpeed API (Nano Banana Pro)
StorageS3-compatible (MinIO/AWS S3)
Databasen8n Data Tables
PaymentsMercado Pago PIX
Automationn8n

๐Ÿ“‹ Prerequisites

Before using this workflow, youโ€™ll need:

  1. Telegram Bot Token - Create a bot via @BotFather
  2. WaveSpeed API Key - Sign up at WaveSpeed
  3. S3-compatible Storage - MinIO, AWS S3, or any S3-compatible service
  4. Mercado Pago Account (optional) - For payment integration
  5. n8n Data Table - Create a table with the required schema

๐Ÿ“Š Data Table Schema

Create a Data Table with the following columns:

ColumnTypeDescription
chat_idStringTelegram chat ID (primary key)
usernameStringTelegram username
statusStringCurrent user state in the flow
creditsStringUserโ€™s credit balance
resolutionStringPreferred resolution (4k/8k)
aspect_ratioStringPreferred aspect ratio
user_default_promptStringCustom default prompt
number_imagesNumberTotal images generated
number_videosNumberTotal videos generated
demo_sendedBooleanWelcome demo sent flag

โšก Quick Setup

  1. Import the workflow into your n8n instance
  2. 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
  3. Set up credentials:
    • Telegram API credentials
    • WaveSpeed API credentials
    • S3 credentials
    • Mercado Pago credentials (if using payments)
  4. Activate the workflow

๐ŸŽฎ Bot Commands

CommandDescription
/startInitialize bot and receive welcome message
menuReturn to main menu
configOpen settings menu
Any textGenerate image from prompt (when in generation mode)
Photo + captionEdit 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


๐Ÿ“„ License

Free to use and modify. Attribution appreciated but not required.


๐Ÿ”— Nodes Used

Edit Image, HTTP Request, Webhook, Telegram, Telegram Trigger, S3

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup