Quick Overview
This workflow listens for meal photos sent to a Telegram bot, uses Google Gemini Vision to estimate the dish and nutrition, logs each entry to a Google Sheets food diary, and replies in Telegram with the estimate plus the sender’s running totals for the day.
How it works
- Triggers when a new Telegram message is received by your bot.
- Checks whether the message includes a photo and replies asking for a meal photo if none is provided.
- Downloads the largest available version of the Telegram photo and sends it (plus any caption) to Google Gemini Vision to return structured nutrition estimates.
- Stops and replies in Telegram if Gemini indicates the image is not food.
- Appends the meal details (date/time, user info, dish, calories, macros, confidence, notes) to a Meals sheet in Google Sheets and then reads back today’s rows for that date.
- Totals today’s calories and macros for the same Telegram user and replies with the per-meal estimate and daily totals.
Setup
- Create a Telegram bot with @BotFather and add its token as a Telegram credential in n8n.
- Add a Google Gemini (PaLM) API credential with an API key that can access the Gemini vision model.
- Connect a Google Sheets OAuth2 credential and replace YOUR_SHEET_ID with your spreadsheet ID in both Google Sheets steps.
- Create a Google Sheet tab named Meals with columns matching the workflow fields (date, time, user_id, user_name, dish, portion, calories_kcal, protein_g, carbs_g, fat_g, confidence, notes).
- Set the workflow timezone in n8n so the “today” totals match your local day, then activate the workflow.