Generate AI Images in Telegram with GPT-4o Enhancement and Flux Pro
π§ AI Image Generator Bot β Telegram + AI/ML API
This n8n workflow allows users to generate AI-generated images by sending messages to a Telegram bot. Each request is logged in Google Sheets and limited by a daily quota per user. Image prompts are enhanced by LLM before generation.
π Features
π© Telegram-based input π§ Prompt enhancement with GPT-4o π¨ AI image generation via flux-pro model (AIMLAPI) π Auto-caption generation π Usage tracked per user daily in Google Sheets π Daily request limits β Graceful UX for over-limit cases
π Setup Guide
-
π² Create Telegram Bot Talk to @BotFather Use /newbot β Choose a name and username Save the bot token
-
π Set Up Credentials in n8n Telegram API: Use your bot token Google Sheets: Set up via OAuth2 or Service Account AI/ML API: Set up with your API key from aimlapi.com
-
π Prepare Google Sheet Name: Any (e.g., Image bot usage statistic) Sheet: Sheet1 Columns: user_id | date | query | result_url
Share the sheet with the email of your service/OAuth2 account
- π§ Configure the Workflow
Open the n8n editor and import the JSON Update:
Telegram credential Google Sheets credential and Sheet ID AI/ML API credentials
βοΈ Flow Summary
| Node | Function | | ------------------------------ | ------------------------------------ | | π© Receive Telegram Message | Triggered by user message | | π Fetch Usage Logs | Reads today's entries from Sheet | | π Count Todayβs Requests | Counts how many generations today | | π’ Set Daily Limit | Sets default limit (5) | | π¦ Check Limit Exceeded? | If over limit β notify | | π§ Enhance Prompt | Uses GPT-4o to improve user's prompt | | π¨ Generate Image | Sends to AIMLAPI to generate | | π Describe Image | Generates caption for the image | | π€ Send Image to User | Sends back to Telegram | | π Log Successful Generation | Writes to Google Sheets |
π Data Logging
Each successful generation is stored in Google Sheets:
| user_id | date | query | result_url | | -------- | ---- | ----- | ----------- |
π‘ Example Prompt Flow
User sends:
astronaut cat floating in space
Bot replies:
> Hereβs your image: > A majestic feline astronaut drifts through a glittering cosmic void, its helmet reflecting starlight.
The image is sent with the caption
π Daily Limit
Default: 5 generations/day per Telegram user You can change this in the π’ Set Daily Limit node
π§ͺ Testing
Use /execute workflow in Telegram β not "Execute Node" in editor Log test results to sheet Add extra Set nodes for debugging as needed
π Resources
π AI/ML API Docs πΌοΈ flux-pro Model UI
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Automatic News Summarization & Email Digest with GPT-4, NewsAPI and Gmail
π° AI News Digest Agent: Auto News Summarizer & Email Newsletter Create an intelligent news curation system that automat...
Generate Food Recipes from Gmail & Form Requests with Ollama & Llama 3.2
This n8n template demonstrates how to create an intelligent food recipe assistant that accepts requests via Gmail and we...
π Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments