An automated Telegram bot that generates AI images with platform-aware formatting and publishes to a channel only after human approval, built with n8n and OpenAI's image API.
Project details
Context:
- Business/industry: Content & Social Media Management
- Current process: Creating platform-specific visuals (Instagram vs Facebook aspect ratios) required manually generating or resizing images, then manually posting to the channel with no review step.
Problem:
- Different platforms need different image dimensions (portrait for Instagram, landscape for Facebook), and getting this wrong means wasted generations or awkward cropping.
- No safeguard against publishing an AI-generated image straight to a channel without a human check.
- Requesting an image and formatting it for the right platform was two separate manual steps.
Solution
<aside>
🧠
The system receives an image request via Telegram, detects the target platform from a keyword in the message, generates the image in the correct aspect ratio, sends it back for review, and only publishes to the channel after the user explicitly approves it.
Tools used: n8n, Telegram Bot API, OpenAI (GPT-image model), Switch/Merge routing logic.
</aside>
Solution logic:
- A message is received via Telegram Trigger and normalized (text, user, chat ID).
- The message is routed by a Switch node based on keywords: "insta" → portrait format, "fb" → landscape format, no keyword → square default, "/start" → onboarding instructions.
- The platform keyword is stripped from the text before it's used as the image prompt — so "insta a cat drinking coffee" generates a clean prompt without the routing keyword leaking into the image.
- The image is generated via OpenAI's image API at the dimensions matching the detected platform (1024x1536, 1536x1024, or 1024x1024).