See llms.txt for all machine-readable content.

Back to Templates

Log Telegram meal photos and text to Google Sheets with Gemini nutrition analysis

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

  1. Triggers when a new Telegram message is received by your bot.
  2. Checks whether the message includes a photo and replies asking for a meal photo if none is provided.
  3. Downloads the largest available version of the Telegram photo and sends it (plus any caption) to Google Gemini Vision to return structured nutrition estimates.
  4. Stops and replies in Telegram if Gemini indicates the image is not food.
  5. 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.
  6. Totals today’s calories and macros for the same Telegram user and replies with the per-meal estimate and daily totals.

Setup

  1. Create a Telegram bot with @BotFather and add its token as a Telegram credential in n8n.
  2. Add a Google Gemini (PaLM) API credential with an API key that can access the Gemini vision model.
  3. Connect a Google Sheets OAuth2 credential and replace YOUR_SHEET_ID with your spreadsheet ID in both Google Sheets steps.
  4. 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).
  5. Set the workflow timezone in n8n so the “today” totals match your local day, then activate the workflow.