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.comName: 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
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.
5 generations/day per Telegram userπ’ Set Daily Limit node/execute workflow in Telegram β not "Execute Node" in editorSet nodes for debugging as needed

