A personal Telegram bot that tracks your daily calories and macros using natural language. Powered by Google Gemini 2.0 Flash for AI meal parsing and Google Sheets for persistent storage.
Just type
2 roti + dal makhani 1 katoriand NutriBot handles the rest.
- Natural language meal logging — no dropdowns, no structured forms
- Indian food optimized — knows roti, dal, paneer, poha, dosa, chai, and more
- Instant macro breakdown — calories, protein, carbs, fat, fiber per meal
- Running daily totals — see progress after every meal
- 7 bot commands —
/today,/meals,/week,/goals,/setgoal,/undo,/help - Smart reminders — breakfast, lunch, snack, dinner nudges (skipped if you already logged)
- Automated 9 PM daily report — progress bars + goal tracking
- Google Sheets storage — all data in your own spreadsheet
- ₹0 monthly cost — entirely on free tiers
| Service | What to do |
|---|---|
| Telegram | Message @BotFather → /newbot → save the token |
| Gemini | Get a free API key at Google AI Studio |
| Google Sheets | Create a spreadsheet named CalorieTracker with two tabs: Logs and Daily Summary |
| Google Cloud | New project → enable Sheets API + Drive API → create Service Account → download JSON key → share the spreadsheet with the service account email |
cd DietCalorieTracker
npm installcp .env.example .envFill in your .env:
TELEGRAM_BOT_TOKEN=your_bot_token_from_botfather
TELEGRAM_CHAT_ID=your_personal_chat_id
GEMINI_API_KEY=your_gemini_api_key
GOOGLE_SHEETS_ID=your_spreadsheet_id
GOOGLE_SERVICE_ACCOUNT_EMAIL=your-sa@project.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n"Tip: To find your
TELEGRAM_CHAT_ID, message @userinfobot on Telegram.
node index.js| Command | Description |
|---|---|
| (any text) | Log a meal — AI parses it automatically |
/today |
Today's macro summary with progress bars |
/meals |
List all meals logged today |
/week |
7-day summary with averages |
/goals |
View current macro goals |
/setgoal protein 150 |
Update a specific goal |
/undo |
Delete the last logged meal |
/help |
Show all commands |
| Time (IST) | Reminder |
|---|---|
| 8:00 AM | Breakfast nudge + yesterday's protein |
| 1:00 PM | Lunch check-in + morning total |
| 5:00 PM | Snack reminder + remaining macros |
| 8:30 PM | Dinner reminder + calories to goal |
| 9:00 PM | Daily macro report (always sent) |
Meal reminders are skipped if you logged something in the last 2 hours.
- Push to GitHub
- Connect repo on Railway
- Set environment variables in the dashboard
- Deploy — the
Procfilehandles the rest
npm install -g pm2
pm2 start ecosystem.config.js
pm2 save
pm2 startup| Column | Content |
|---|---|
| A | Date (DD/MM/YYYY) |
| B | Time (HH:MM) |
| C | Meal Description |
| D | Raw Input |
| E | Calories |
| F | Protein (g) |
| G | Carbs (g) |
| H | Fat (g) |
| I | Fiber (g) |
| Column | Content |
|---|---|
| A | Date |
| B–F | Total macros |
| G | Meals count |
| H–I | Goal met (boolean) |
- Node.js — runtime
- node-telegram-bot-api — Telegram integration
- @google/generative-ai — Google Gemini 2.0 Flash AI parsing
- googleapis — Google Sheets read/write
- node-cron — scheduled reminders
- dotenv — environment configuration
DietCalorieTracker/
├── index.js # Entry point
├── src/
│ ├── config.js # Environment & goals
│ ├── gemini.js # AI meal parsing
│ ├── sheets.js # Google Sheets CRUD
│ ├── bot.js # Telegram bot + commands
│ ├── formatter.js # Message formatting
│ └── reminders.js # Cron-based reminders
├── .env.example # Environment template
├── ecosystem.config.js # PM2 config
├── Procfile # Railway config
└── package.json
- https://console.cloud.google.com/auth/overview/create?orgonly=true&project=nutribot-490406&supportedpurview=organizationId
- https://docs.google.com/spreadsheets/d/1GFtn2dMPjU_CiY5gHZnE7dcve5IX1eI0EECW0FoqWj4/edit?gid=0#gid=0
- https://console.groq.com/keys
- https://aistudio.google.com/api-keys?projectFilter=gen-lang-client-0636504204
- https://railway.com/project/7c85123f-ce41-4c39-b3c0-d3583c68a8af?environmentId=c5a58a31-84e4-4281-869d-0d1760e7d285
- https://claude.ai/share/579e9b36-a87f-4cff-b0ae-b6efc107edec