Build a Free AI Calorie Tracker That Rivals $3M/Month Apps

In this tutorial, I’ll show you how to build your own AI-powered calorie tracker that analyzes food photos and automatically calculates nutritional information. This system can count calories, protein, fats, and carbs from a simple picture, making it incredibly useful for anyone looking to control their diet without expensive subscriptions.

By the end of this guide, you’ll have a working automation that rivals apps generating millions in revenue.

In my video, I walk through the complete setup process and demonstrate how this AI agent works in real-time.

The Inspiration Behind This AI Calorie Tracker

The idea for this automation came to me when I discovered an app called Cal AI. This application charges users $20 to $30 per year for a subscription, and I was shocked to learn it generates approximately $3 million per month in gross revenue. What surprised me most wasn’t just the revenue figure, but how simple the core concept actually is. Even more interesting, numerous other calorie-counting apps generate hundreds of thousands of dollars using essentially the same functionality.

This realization made me want to show you how to create a simple version of this app yourself, completely free. While these commercial apps have polished interfaces and additional features, the core AI functionality that analyzes food and calculates nutrition can be replicated with readily available tools.

How the AI Food Tracker Works

In my demonstration, I show how the system operates through a Telegram bot interface. The process is remarkably straightforward: you simply open the Telegram bot and send a picture of your food. Within seconds, the AI returns detailed nutritional information about what you’re eating.

In my example, I sent a photo of a mixed green salad, and the AI accurately identified the ingredients including cucumbers, tomatoes, balsamic glaze, and even hemp seeds. The system provided a complete breakdown showing proteins, fats, carbs, and total calories. After receiving this information, you have three options: record the meal to your database, change it if you want to upload a new picture, or delete it if you don’t need it.

When you press record, the meal gets saved to a spreadsheet where you can track all your nutritional intake. The system also allows you to check your daily calorie summary by simply pressing a “today” button, which aggregates all the meals you’ve logged for the current day.

Multi-User Capability

One of the most valuable features I’ve built into this system is its ability to support multiple users. The automation tracks each user by their username and chat ID, which means you can share the bot with friends and family. Each person will receive their own personalized information about their calories and meals, completely separate from other users’ data.

Setting Up the Automation in n8n

I created all these automations in n8n, which is a powerful workflow automation tool. If you’re not familiar with n8n, you can check out my affiliate link in the description to get started. The automation begins with a Telegram trigger that understands whether you’re sending a picture or a text command, then switches to the correct processing thread based on what you’ve sent.

You can get my full template for free in my Skool community, which will save you considerable setup time. The workflow structure includes the Telegram trigger where you create credentials by obtaining an access token from Telegram’s BotFather.

Creating Your Telegram Bot

To set up the Telegram integration, you need to open Telegram and find BotFather, which is the main bot used to create all other Telegram bots. In BotFather, you simply press “open,” then create a new bot by providing a bot name and username. Once created, you’ll receive an API key that you copy and paste into your n8n credentials.

Adding Access Control

An important security feature I’ve included is an IF node that only allows people from a specific list to use the bot. This is crucial because anyone can potentially find your bot and use it, which would consume your AI tokens and incur costs. To implement this, you add your chat ID to a filter.

You can easily find your chat ID by executing the workflow in test mode and checking the output. I explain in my video that you need to add the chat ID filter for both JSON callback query and JSON message from ID, setting them to “is equal to” your approved chat IDs.

The Food Recognition Process

The main processing happens through a switch node that transfers the workflow to the correct thread depending on what type of input you send. When you send a photo, the system checks if JSON message photo exists, which triggers the food recognition thread.

The workflow then retrieves the file and analyzes the image using OpenAI’s vision capabilities. I use a carefully crafted prompt that positions the AI as a nutritionist assistant. The prompt instructs the system to estimate the meal’s composition, portion size, and macros along with total calories. If there are multiple dishes in one photo, the AI evaluates everything together and provides both a combined total and a breakdown by individual item.

The prompt specifies exact output format requirements including protein, fat, carbs, and calories, with explicit instructions not to include anything except what’s shown in the example output. This ensures consistency in the data structure.

Processing with an AI Agent

After the initial analysis, I pass the information to an agent node with another prompt that reinforces the role as an AI nutritionist. This agent processes the input and returns only JSON format with the exact fields needed: proteins, fats, carbs, calories, and dish name. This structured approach ensures the data can be reliably stored in a database.

Storing Data in Airtable

All the nutritional information gets added to an Airtable base. I explain in my video how to connect Airtable to n8n by creating new credentials. You need to open the n8n documentation, find the section on personal access tokens, then create a token in Airtable with the appropriate scopes: data read, data write, schema read, and schema write.

When creating the token, you can either add a specific base or add all current and future bases. Once you copy and paste the token into n8n, you can connect to your Airtable workspace. The system first adds meal data to a temporary table that includes the dish name, date, calories, proteins, fats, carbs, username, and chat ID.

After adding to the temporary base, the automation sends the ingredient list back to Telegram with an inline keyboard containing three buttons: record, change, and delete. Each button includes callback data with the record ID, which is crucial for the system to understand which meal the button actions should affect.

Recording, Changing, and Deleting Meals

When you press the record button in Telegram, the system uses the callback query to identify which meal to process. I demonstrate in test mode how the system captures the JSON ID from the button, which corresponds to the Airtable record ID created when the meal was first added to the temporary table.

The automation uses an expression with a split function to extract just the record ID portion from the button data. The split function takes the second part (index 1, since it starts counting from zero) of the callback data. This allows the system to precisely identify which meal record to work with.

Once identified, the system creates a new record in the permanent meals table with all the nutritional information, then deletes the record from the temporary database since it’s no longer needed. Finally, it sends a confirmation message to Telegram that the meal has been recorded.

The change function is straightforward—it simply prompts you to upload a new picture for a more accurate estimate. The delete function uses the same record ID approach, first sending a message confirming which meal was deleted, then removing the record from the temporary table. I configured the delete node to continue on error using error output, which handles cases where a meal has already been deleted and prevents the workflow from breaking.

Daily Calorie Summary Feature

One of the most useful features is the daily summary command. When you press the “today” button, the switch node checks if the message text equals “today,” then routes to a search function. This search uses a formula that filters meals by date and chat ID, ensuring you only see your own meals from the current day.

The system retrieves all matching records—in my example, it found two meals—then uses a summarize node to calculate the total calories, proteins, fats, and carbs across all meals. This aggregated information gets formatted and sent back to you via Telegram, giving you a complete overview of your nutritional intake for the day.

Accuracy Compared to Commercial Apps

After testing both my custom system and the commercial Cal AI app for several days, I noticed that my AI system actually produced more accurate results than the $3 million per month app. This demonstrates that with the right prompts and workflow design, you can build automation that matches or exceeds commercial solutions.

The template for this entire system is available for free in my Skool community, where you can download it and customize it for your specific needs. The setup process is straightforward when you follow the steps I’ve outlined, and you’ll have a fully functional AI calorie tracker running within a short time.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *