← Back to directory

Nutrition tracker & meal logger with Telegram, Gemini AI and Google Sheets

unverified

geminitelegramn8n-template

Install Guide

Draft — community verifying

Generated by claude-sonnet-auto · 5/27/2026

Prerequisites

Before you begin, ensure you have the following:

  • n8n (self-hosted or cloud) — version 1.0 or later recommended
  • A Google account with access to Google Sheets and Google Cloud Console
  • A Telegram account to create and manage a bot
  • A Google Gemini API key (via Google AI Studio or Google Cloud Vertex AI)
  • A Google Sheet created and ready to store meal/nutrition log entries
  • Basic familiarity with n8n's workflow editor and credential management

Get Your API Keys

1. Telegram Bot Token

  1. Open Telegram and search for @BotFather.
  2. Start a chat and send /newbot.
  3. Follow the prompts to name your bot and choose a username (must end in bot).
  4. BotFather will return a token like 123456789:ABCdefGhIJKlmNoPQRstuVWXyz.
  5. Copy and save this token securely.

Portal: https://t.me/BotFather


2. Google Gemini API Key

  1. Go to https://aistudio.google.com/app/apikey.
  2. Sign in with your Google account.
  3. Click Create API Key.
  4. Select an existing Google Cloud project or create a new one.
  5. Copy the generated API key and store it securely.

Alternatively, if using Vertex AI: visit https://console.cloud.google.com/ and enable the Generative Language API.


3. Google Sheets OAuth Credentials

  1. Go to https://console.cloud.google.com/apis/credentials.
  2. Click Create Credentials → OAuth 2.0 Client ID.
  3. Set the application type to Web application.
  4. Under Authorized redirect URIs, add your n8n OAuth callback URL:
    https://<your-n8n-domain>/rest/oauth2-credential/callback
    
  5. Download or note the Client ID and Client Secret.
  6. Ensure the Google Sheets API is enabled at https://console.cloud.google.com/apis/library.

Installation

This integration runs as an n8n workflow — there is no standalone codebase to clone. Follow these steps to import it into n8n.

Option A: Self-Hosted n8n via npm

# Install n8n globally
npm install -g n8n

# Start n8n
n8n start

Then open your browser at http://localhost:5678.

Option B: Self-Hosted n8n via Docker

docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

Import the Workflow

  1. In the n8n UI, go to Workflows → Add Workflow → Import from File/URL.
  2. If you have a .json workflow export file, upload it here.
  3. If no file is available, you will need to manually recreate the workflow using the nodes described in the Configuration section below.

If a workflow JSON file was provided separately, import it via Settings → Import Workflow.


Configuration

Set up the following credentials inside the n8n Credentials panel (Settings → Credentials → Add Credential):

| Variable / Credential | Description | Where to Get It | |---|---|---| | TELEGRAM_BOT_TOKEN | Token used to authenticate your Telegram bot | @BotFather on Telegram | | GEMINI_API_KEY | API key for accessing Google Gemini AI models | aistudio.google.com/app/apikey | | GOOGLE_SHEETS_CLIENT_ID | OAuth 2.0 Client ID for Google Sheets access | Google Cloud Console → Credentials | | GOOGLE_SHEETS_CLIENT_SECRET | OAuth 2.0 Client Secret for Google Sheets access | Google Cloud Console → Credentials | | GOOGLE_SPREADSHEET_ID | The ID of the target Google Sheet for logging meals | Found in your Sheet's URL: .../spreadsheets/d/<ID>/edit | | SHEET_NAME | The specific tab/sheet name within the spreadsheet (e.g., MealLog) | Your Google Sheets document | | N8N_WEBHOOK_URL | Base URL of your n8n instance (needed for Telegram webhook mode) | Your server's public domain or ngrok URL |

Registering the Telegram Webhook

Once n8n is running and your Telegram credential is configured, set the webhook so Telegram delivers messages to your workflow:

https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://<your-n8n-domain>/webhook/<your-webhook-path>

Replace <your-webhook-path> with the path defined in your n8n Telegram Trigger node.


Running the Bot

Development Mode (local with ngrok)

# In terminal 1 — start n8n
n8n start

# In terminal 2 — expose local port via ngrok
ngrok http 5678
  1. Copy the https:// ngrok URL.
  2. Update your Telegram webhook URL (see above) using the ngrok domain.
  3. Activate your workflow in the n8n UI by toggling it to Active.

Production Mode

# Run n8n as a background process with pm2
npm install -g pm2
pm2 start n8n --name "nutrition-bot"
pm2 save
pm2 startup

Or with Docker in detached mode:

docker run -d \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  --restart unless-stopped \
  n8nio/n8n

Ensure your workflow is set to Active in the n8n UI — inactive workflows will not respond to incoming messages.


Testing

Smoke Test — Send a Message to Your Bot

  1. Open Telegram and find your bot by its username.
  2. Send a message like:
    I had oatmeal with banana and a black coffee for breakfast
    
  3. The bot should respond with a nutritional breakdown generated by Gemini AI.
  4. Open your Google Sheet and verify a new row was logged with the meal details, calories, and timestamp.

Verify the Webhook is Active

curl https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getWebhookInfo

Expected response includes "url" pointing to your n8n instance and "pending_update_count": 0.

Check Workflow Execution Logs

In n8n, go to Executions (left sidebar) to see a log of each triggered run. A successful execution will show all nodes with a green checkmark.


Troubleshooting

| Problem | Likely Cause | Fix | |---|---|---| | Bot does not respond to Telegram messages | Webhook not set or pointing to wrong URL | Re-run the setWebhook curl command with the correct n8n URL; verify with getWebhookInfo | | 401 Unauthorized error on Gemini node | Invalid or expired Gemini API key | Regenerate the key at aistudio.google.com and update the credential in n8n | | Google Sheets node fails with 403 Forbidden | Sheets API not enabled or OAuth scope insufficient | Enable the Google Sheets API in Cloud Console and re-authorize the OAuth credential in n8n | | Workflow executes but no row appears in Google Sheet | Wrong Spreadsheet ID or Sheet tab name | Double-check GOOGLE_SPREADSHEET_ID from the Sheet URL and ensure SHEET_NAME matches exactly (case-sensitive) | | ngrok tunnel works locally but bot stops responding after restart | ngrok generates a new URL on each restart | Use a paid ngrok plan for a static domain, or deploy n8n to a server with a fixed public URL | | n8n shows ECONNREFUSED when calling Gemini | Network/firewall blocking outbound requests | Ensure your server allows outbound HTTPS on port 443; check proxy settings if behind a corporate firewall |

Sign in to leave feedback on this guide.

Language
n8n-workflow
Author
alejandro-silva
Stars
45250
Source
n8n
Added
5/26/2026
Found something off? Email meow@cheesyboy.dev and we'll update the entry.