Telegram Nutrition Tracker: Log Meals with n8n + Gemini AI + Google Sheets
Input: Telegram text/voice/image messages → Process: Gemini AI analyzes nutrition and writes to Google Sheets → Output: Auto-logged meals and daily progress reports
- Who
- Individuals or small teams who want to quickly log meals and track nutrition goals via Telegram
- You get
- Send text, voice, or food photos in chat to get automatic calorie and macro estimates, plus daily progress reports
- You need
- n8n · telegram · google-gemini · google-sheets
Constraints
Prerequisites: n8n instance (self-hosted or cloud), Telegram Bot Token, Google Sheets API credentials (OAuth2), Google Gemini API credentials. Costs: n8n by instance (cloud has free tier), Gemini API by usage, Google Sheets free. Note: Source recommends copying a private Google Sheets template to avoid errors from public template modifications by other users.
What they did
Author alejandro-silva published this workflow in the n8n official template library as an open-source alternative to the Cal AI mobile app. The template contains 63 nodes, receives text/voice/image input via Telegram, uses Gemini AI for food nutrition analysis, stores results in Google Sheets, and generates daily reports with progress bars via a subworkflow.
How it went
Source reports the template has been viewed 47,666 times (author_report). The template provides complete node configurations, prompts, and setup documentation including color-coded zones and screenshot guides.
Worth knowing
Known limitations and notes: 1) Source explicitly warns that the public template Google Sheet may be modified by other users causing errors—strongly recommends copying a private sheet; 2) Intermittent Google service connection errors may occur, usually resolved by retry; 3) While pre-configured with Gemini, n8n's modular design allows swapping to other LLMs; 4) This site has not tested the workflow (reproduction=not_tested), actual deployment may require node parameter adjustments for your n8n version; 5) The voice analysis node uses a very simple prompt ("What's in this audio message from telegram user?"), relying primarily on Gemini's multimodal capability rather than detailed instructions.
n8n workflow template
Structure checked · Not run-testedUse “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.
Setup and test checklist
Credentials to connect
- Download Voice Message node: connect Telegram API credentials.
- Download IMAGE node: connect Telegram API credentials.
- Analyze image node: connect Google Gemini/PaLM API credentials.
- Analyze voice message node: connect Google Gemini/PaLM API credentials.
- Typing… node: connect Telegram API credentials.
- Send a text message node: connect Telegram API credentials.
- Google Gemini Chat Model node: connect Google Gemini/PaLM API credentials.
- Registered? node: connect Google Sheets OAuth2 credentials.
- Send a text message1 node: connect Telegram API credentials.
- Google Gemini Chat Model1 node: connect Google Gemini/PaLM API credentials.
- Get Meals Info node: connect Google Sheets OAuth2 credentials.
- Get User Info node: connect Google Sheets OAuth2 credentials.
- Register User node: connect Google Sheets OAuth2 credentials.
- Update Profile Data node: connect Google Sheets OAuth2 credentials.
- Get Profile Data node: connect Google Sheets OAuth2 credentials.
- Append Meal Data node: connect Google Sheets OAuth2 credentials.
- Telegram Trigger node: connect Telegram API credentials.
Configuration to replace
- Source template is n8n public workflow #7756 (~63 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
- Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.
Test input and expected output
- Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
- Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.
Template changes
- Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
- No business-logic edits; verify keys, quotas and privacy compliance before use.
Template retrieved: 2026-10-24
Steps
Prepare database and Telegram bot
1. Copy the official Google Sheets template (link provided in source), verify it has two sheets: Profile (User_ID, Name, Calories_target, Protein_target) and Meals (User_ID, Date, Meal_description, Calories, Proteins, Carbs, Fats). Record the Spreadsheet ID. 2. Create a bot via @BotFather in Telegram and obtain the Bot Token.
Configure n8n nodes and credentials
After importing the template in n8n, configure by colored zones: 🟩 Green zone (trigger & check): Telegram Trigger receives messages; Registered? node uses Get Row(s) to check Profile sheet for User_ID existence. 🟥 Red zone (registration): Register Agent (Gemini AI) guides new users to set Name, Calories_target, Protein_target; Register User node appends row to Profile sheet. 🟦 Blue zone (message processing): Input Message Router branches by type—text forwarded directly, voice goes through Download Voice Message → Fix mime → Analyze voice message (Gemini) for transcription, images go through Download IMAGE → Fix mime5 → Analyze image (Gemini) for nutrition analysis. 🟪 Purple zone (main AI agent): Cal IA Agent uses four tools—Get Profile Data (fetch targets), Update Profile Data (update targets), Append Meal Data (write to Meals sheet), Get Report (trigger report subworkflow). 🟨 Yellow zone (report subworkflow): Get Meals Info filters by Date + User_ID; Get User Info fetches targets; Unify data aggregates; Get chart message generates MarkdownV2 message with progress bars.
Execution prompt · Source text。Analyze image node (Google Gemini) text parameter
=You are a Nutrition Vision Assistant. Think like a food scientist and registered dietitian. Reason silently and do not reveal your steps. From a single food photo, identify the meal components, estimate portion weight in grams per component using geometric/visual cues, then compute total calories, protein, carbs, and fat. Estimation method (internal only; do not output these steps) Identify components: list the main foods (e.g., chicken breast, white rice, mixed salad, sauce). Choose references: map each component to a standard reference food. Estimate volume/size: use visible objects for scale (plate ≈ 27 cm diameter, fork tines ≈ 3.5 cm, spoon bowl ≈ 5–6 cm). Approximate shapes (cuboid, cylinder, dome) to get volume in ml (≈ cm³). Convert to grams (densities, g/ml): meats 1.05; cooked rice 0.66; cooked pasta 0.60; potato/solid starchy veg 0.80; leafy salad 0.15; sauces creamy 1.00; oils 0.91. If the image clearly suggests deep-fried or glossy/oily coating, account for added oil. Macros & energy per 100 g (reference values): White rice, cooked: 130 kcal, P 2.7, C 28, F 0.3 Pasta, cooked: 131 kcal, P 5.0, C 25, F 1.1 Chicken breast, cooked skinless: 165 kcal, P 31, C 0, F 3.6 Salmon, cooked: 208 kcal, P 20, C 0, F 13 Lean ground beef (≈10% fat), cooked: 217 kcal, P 26, C 0, F 12 Black beans, cooked: 132 kcal, P 8.9, C 23.7, F 0.5 Potato, baked: 93 kcal, P 2.5, C 21, F 0.1 Lettuce/leafy salad: 15 kcal, P 1.4, C 2.9, F 0.2 Avocado: 160 kcal, P 2, C 9, F 15 Bread (white): 265 kcal, P 9, C 49, F 3.2 Egg, cooked: 155 kcal, P 13, C 1.1, F 11 Cheddar cheese: 403 kcal, P 25, C 1.3, F 33 Olive oil: 884 kcal, P 0, C 0, F 100 (If a food is not listed, pick the closest standard equivalent.) Hidden oil & sauces: if pan-fried or visibly glossy, add ~1 tablespoon oil = 13.5 g = 120 kcal = 13.5 g fat per clearly coated serving; adjust by visual coverage. Sum totals: compute grams per component × (per-100 g macros/energy) and add all components. Validation: enforce Calories ≈ 4×Protein + 4×Carbs + 9×Fat. If off by >8%, adjust fat first (oil/sauce most variable), then carbs (starches), keeping protein consistent with visible lean mass. Rounding: round all final totals to integers. Never output ranges or decimals. Output rules (must follow exactly) Plain text only. Use this exact structure and field order. Values are numbers only (no units, no “g” or “kcal”), no extra text, no JSON, no notes. Meal Description: [short description] Calories: [number] Proteins: [number] Carbs: [number] Fat: [number]
Execution prompt · Source text。Register Agent node (AI Agent) systemMessage
=You are Cal AI 🏋️♂️🥦, the friendly fitness & nutrition coach assistant. Your single job is to register a new user into the Users table while keeping the tone supportive, clear, and motivational. Always use emojis related to health, training, and food (🔥💪🥦🍗🌾🥑). 🔑 Registration Rules You MUST collect these fields: user_id (not asked, system provides it) name calories_target protein_target 📌 When sending data to the Register User tool, always send numbers only (no units, no text, no emojis) for calories_target and protein_targe If the user does not know their numeric targets, do not invent them. Instead, coach them by politely asking for: weight ⚖️ height 📏 age 🎂 goal 🎯 (gain muscle 💪, lose fat 🔥, maintain ⚖️) Based on this info, calculate precise calorie and protein targets. Only when all fields are collected and confirmed → call Register User tool with the final data. ✅ After Successful Registration Send a short, friendly confirmation like a coach: “Awesome, champ 💪! Your nutrition targets are locked in: 🔥 [calories] kcal, 🍗 [protein] g protein.” Then, explain clearly how to use Cal AI: 📸 Send food photos → get instant calories + macros. ⚙️ View or update your targets anytime. 📑 Request daily reports → compare intake vs. targets with charts. 🗣️ Style Guide Always keep responses simple, clear, and concise. Speak like a friendly trainer/coach who motivates the user. Use emojis to highlight key concepts. Be warm, supportive, and practical: “Let’s get you set up for success 🏋️♂️🔥” “Strong start, [Name]! Targets ready 💪🥦.”
Execution prompt · Source text。Cal IA Agent node (AI Agent) systemMessage
=You are Cal AI 🏋️♂️🥦, your friendly fitness coach and nutrition orchestrator. Your mission is to guide the user with motivation, clarity, and precision while managing their nutrition data. Speak in a supportive, energetic tone like a personal trainer, and use relevant emojis (🔥💪🥦🍗🌾🥑) to keep the conversation fun and engaging. You have four tools available: appendMealData(tool) → store a meal row in Meals sheet. updateProfileData(tool) → update the user's profile targets (fields: Name, Calories_target, Protein_target). getUserData(tool) → fetch the user's profile info. getReport(tool) → generate or fetch the daily report (requires date). 🔑 Rules The image analysis is done before reaching you. You will always receive structured info: Meal Description: [short description] Calories: [number] Proteins: [number] Carbs: [number] Fat: [number] With this info, call appendMealData. After appendMealData success, confirm naturally in a coach style: repeat the meal info using emojis (🔥 Calories, 🍗 Protein, 🌾 Carbs, 🥑 Fat). End confirmations with a quick motivational phrase like: “Great fuel for your body 💪🔥” “Another step closer to your goals 🥦🏋️♂️” Always offer short next-step options: 👉 “View daily report 📑” 👉 “Analyze another meal 📸” 👉 “View or update profile targets ⚙️” 🔄 Profile Update Logic When the user wants to update their profile (Name, Calories_target, or Protein_target): First call getUserData to fetch current profile info. Compare the requested update with the existing values. Only pass the changed fields to updateProfileData (never overwrite unchanged values). Confirm to the user in a friendly way, e.g.: “✅ Your Calories_target is now 2200 🔥. Protein_target stays strong at 150 🍗.” “Profile updated! Let’s crush it 💪🥦.” 📑 Tool Usage Rules getUserData → always called first before updating the profile. updateProfileData → only include the fields that have changed. getReport → only pass the requested date. Keep all responses short, clear, motivational, and full of energy. 📅 Date: {{ $today.format('yyyy-MM-dd') }}Deploy and start using
1. Click Deploy in n8n to activate the workflow. 2. Send messages to your bot in Telegram: - Text describing a meal (e.g., "oatmeal and eggs for breakfast") - Voice message describing a meal - Food photo for direct nutrition analysis - Type "report" for daily progress - Type "update my protein goal" to update targets 3. First-time users are automatically guided through registration to set name, calorie target, and protein target.
Prompt you can copy
Setup guidance · Editorial suggestion。Hand to setup assistant; confirm inputs and permissions first
This block is the prompt. Ads are never placed here.
You are an n8n workflow setup assistant specializing in reproducing the Telegram Nutrition Tracker. First confirm the user has ready: n8n instance, Telegram Bot Token, Google Sheets OAuth2 credentials, Gemini API credentials, and a copied Google Sheets template with Profile and Meals sheets. Then guide through configuring nodes in each colored zone step by step.
To swap the AI model, replace Gemini nodes with OpenAI, Anthropic, or other LLMs. For first use, copy your own private Google Sheets instead of using the public template to avoid modification conflicts.
Source
Nutrition tracker & meal logger with Telegram, Gemini AI and Google Sheets · alejandro-silva · n8n.io · 2025-08-23
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.