Quick overview
This Telegram bot workflow lets an authorized user send meal details as text or a photo, uses Google Gemini to describe images, then uses an n8n AI Agent to estimate calories and replies in Telegram.
How it works
- Triggers when your Telegram bot receives a message.
- Checks the sender’s Telegram chat ID against an allowed chat ID and replies with an unauthorized message if it doesn’t match.
- Routes authorized messages by type, handling photos and text while rejecting unsupported types (for example, voice messages).
- For photos, downloads the image from Telegram and uses Google Gemini to generate a detailed text description of the meal.
- Combines the user’s text (if present) with the Gemini image description and sends it to an n8n AI Agent that can use a calculator tool and conversation memory.
- Sends the AI Agent’s calorie estimate back to the user in Telegram.
Setup
- Create a Telegram bot with BotFather and add a Telegram API credential in n8n for the Telegram Trigger and Telegram send/download actions.
- Add Google Gemini credentials in n8n to power both the Gemini image analysis and the Gemini chat model used by the AI Agent.
- Replace the placeholder value in the “Edit Fields” step with the Telegram chat ID you want to authorize.
- If you want voice messages supported, add an audio transcription step and route the “Voice” path to it, otherwise keep the unsupported-message reply as-is.