Nutrition tracker & meal logger with Telegram, Gemini AI and Google Sheets
Install Guide
Draft — community verifyingGenerated 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
- Open Telegram and search for @BotFather.
- Start a chat and send
/newbot. - Follow the prompts to name your bot and choose a username (must end in
bot). - BotFather will return a token like
123456789:ABCdefGhIJKlmNoPQRstuVWXyz. - Copy and save this token securely.
Portal: https://t.me/BotFather
2. Google Gemini API Key
- Go to https://aistudio.google.com/app/apikey.
- Sign in with your Google account.
- Click Create API Key.
- Select an existing Google Cloud project or create a new one.
- 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
- Go to https://console.cloud.google.com/apis/credentials.
- Click Create Credentials → OAuth 2.0 Client ID.
- Set the application type to Web application.
- Under Authorized redirect URIs, add your n8n OAuth callback URL:
https://<your-n8n-domain>/rest/oauth2-credential/callback - Download or note the Client ID and Client Secret.
- 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
- In the n8n UI, go to Workflows → Add Workflow → Import from File/URL.
- If you have a
.jsonworkflow export file, upload it here. - 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
- Copy the
https://ngrok URL. - Update your Telegram webhook URL (see above) using the ngrok domain.
- 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
- Open Telegram and find your bot by its username.
- Send a message like:
I had oatmeal with banana and a black coffee for breakfast - The bot should respond with a nutritional breakdown generated by Gemini AI.
- 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.