Calories Tracker Bot

Telegram meal-logging assistant using LLM and Google Sheets

Python Telegram Bot API LLM Google Sheets API LangChain

Overview

A personal Telegram bot that makes counting calories easy. Instead of downloading a dedicated app and searching a food database, I can simply send a natural-language message describing what I ate. The bot uses a LLM to estimate the calorie count, logs the entry to Google Sheets, and keeps a running daily total.

The project was built to help me lose weight by making calorie tracking as simple as possible. while I did not manage to lose weight in the end, the bot was a fun and educational experiment in building a real-world application using LLMs and APIs.

The Problem

Most calorie-tracking apps require you to open the app, search a specific food name, find the right entry. It's a quick 30-second interaction, but that friction adds up over time and I found it hard to maintain the habit.

The question was: what if tracking a meal was as easy as sending a Telegram message? Natural language is flexible enough to describe "half a plate of chicken rice with soup" without exact measurements, and an LLM is well-suited to convert that into a reasonable calorie estimate.


The Solution

A Telegram bot removes all the friction: users are already in Telegram, there is no new app to install, and sending a message is the lowest-effort interaction possible. The bot accepts any natural-language meal description, asks the LLM to return a structured JSON breakdown of items and estimated calories, and confirms the log in one reply.

Demonstration of meal logging, daily summary and Google Sheets integration


Features

Natural Language Meal Logging

Send any free-text description of a meal โ€” "two slices of toast with peanut butter and a flat white" โ€” and the bot extracts items, estimates portions, and returns a calorie breakdown per item plus a total.

Google Sheets Persistence

Every logged entry is appended to a Google Sheet โ€” one row per food item, with columns for timestamp, description, quantity, and calories. A new sheet tab is created automatically each week to keep the data organised.

Daily Summary on Demand

Send /list at any point and the bot replies with the day's total calories, a breakdown of all meals logged, and a comparison against a configurable daily target.


Architecture

Request flow:

  1. User sends meal description via Telegram
  2. Bot receives update via Telegram Bot API webhook
  3. Message text passed to Groq LLM with a structured prompt requesting JSON output
  4. LLM returns item list with calorie estimates per item
  5. Rows appended to the active week's Google Sheet via Sheets API
  6. Bot replies with formatted calorie breakdown
ComponentTechnologyRole
Bot runtime python-telegram-bot Webhook handling, message routing, command dispatch
LLM inference Groq API (Llama 3) Calorie estimation from free-text meal descriptions
Storage Google Sheets API Persistent meal log; auto-creates a new tab each week
Hosting Railway / local Always-on webhook listener