n8n

How to Generate Telegram Image Responses?

Turn your Telegram bot into a creative assistant that chats and makes images on request. Great for marketing teams and creators who want quick drafts and visual ideas without leaving Telegram.

Incoming Telegram messages start the flow. A chat agent powered by an OpenAI model reads the message, remembers the last 10 messages for each chat, and replies in plain text. When a user asks for an image, the agent calls a built in Dall E 3 tool. That tool triggers a sub path that sends the prompt to the OpenAI Images API and returns a photo link. The bot then sends the image back to the same chat. Special characters are escaped to avoid Telegram HTML errors, so replies do not fail.

You need a Telegram bot token and an OpenAI API key. Set both credentials in n8n Cloud and activate the workflow to register the Telegram webhook. Expect faster content turnaround, fewer back and forth messages, and less manual copy and paste. Use it for social posts, mockups, mood boards, and quick concept art, all requested with a simple chat message.

What are the key features?

  • Telegram message trigger listens for new chat messages and starts the flow
  • AI chat replies using an OpenAI model with a balanced temperature for helpful answers
  • Memory keeps the last 10 messages per chat to maintain short context
  • Agent tool to request Dall E 3 when the user asks to draw or generate an image
  • HTTP request to OpenAI Images API with model dall e 3 and 1024x1024 size
  • Image sent back to the same Telegram chat using the returned photo URL
  • HTML character escaping prevents Telegram parse errors in text replies
  • Execute Workflow Trigger cleanly routes image requests through a separate sub path

What are the benefits?

  • Reduce manual image request handling from 30 minutes to 2 minutes per request
  • Streamline content requests in Telegram by up to 70 percent
  • Eliminate most Telegram formatting errors with automatic HTML escaping
  • Handle more chat requests at once with automated replies and image generation
  • Connect Telegram and OpenAI without switching tools or copying prompts

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Telegram and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. Create a Telegram bot using BotFather and copy the bot token.
  4. In the n8n credentials manager, create a new Telegram credential. Double click the Telegram Trigger node or any Telegram node, choose 'Create new credential', paste your bot token, and save.
  5. Open the Telegram Trigger node and confirm updates are set to message. Select your Telegram credential and save.
  6. Create an OpenAI API key in your OpenAI account. In the n8n credentials manager, create a new OpenAI API credential using that key and save.
  7. Open the HTTP Request node named Generate image in Dall E 3 and select your OpenAI credential. Confirm the URL, method POST, and body fields model, prompt, n, and size match your needs.
  8. Open the AI Agent and confirm the linked OpenAI Chat Model and Memory nodes are connected. Keep the model and temperature as set, or adjust if you want different tone.
  9. Check the Dall E 3 Tool node. Ensure it passes the chat_id and that the workflowId matches the current workflow. The tool should send the user prompt as the inline query string.
  10. Activate the workflow so n8n registers the Telegram webhook. Send a normal message to your bot and confirm you get a text reply.
  11. Test an image request, such as Draw a friendly robot mascot. You should receive a photo in the chat. If no image arrives, check OpenAI quota and the HTTP node execution data.
  12. If Telegram shows an error about HTML, make sure the Correct errors node is active and parse mode is set to HTML in the Telegram send nodes.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.