Back to Templates
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.
flux-pro
model (AIMLAPI)/newbot
→ Choose a name and usernameTelegram API
: Use your bot tokenGoogle Sheets
: Set up via OAuth2 or Service AccountAI/ML API
: Set up with your API key from aimlapi.comImage bot usage statistic
)Sheet1
user_id | date | query | result_url
Open the n8n editor and import the JSON
Update:
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 |
Each successful generation is stored in Google Sheets:
user_id | date | query | result_url |
---|
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
5
generations/day per Telegram user🔢 Set Daily Limit
node/execute workflow
in Telegram — not "Execute Node" in editorSet
nodes for debugging as needed