Nutrition Manager - Personal AI nutritionist on Telegram
.jpg)
Process description
This automation is an intelligent power management system via the Telegram interface. The system automatically identifies new users, conducts onboarding to calculate personal BJU take, keeps a food diary, analyzes food photos counting calories and macronutrients, monitors progress and provides personalized dietary recommendations.
API keys and services:
- Telegram Bot API - for the user interface (bot: Nutrition)
- OpenAI API Key - for AI agents and image analysis (gpt-4.1, gpt-4.1-mini, gpt-4o)
- Google Gemini API - backup language model
- Google Sheets OAuth2 - for storing user data and a food diary
- SerPapi - to find information about products and dishes
System architecture by blocks
SECTION 1: RECEIVING AND ROUTING REQUESTS
1.1 Telegram Trigger — Entry Point
Purpose: Tracks all incoming messages and photos from users Settings:
- Updates: message
- Credentials: Nutrition
1.2 New User Verification
Purpose: Checks if a user is in the Google Sheets database Settings:
- Document ID: (Goals table)
- Sheet: Sheet1
- Return First Match: true
- Credentials: Your credentials
1.3 Aggregate - Processing results
Purpose: Aggregates verification data to determine user status Settings:
- Field to Aggregate: ID
- Aggregation Type: standard
1.4 If - Conditional Routing
Purpose: Directs users to the appropriate processing flow Condition:
- Condition: $json.id contains $ ('Telegram Trigger') .item.json.message.chat.id
- True Output: Existing User → Switch
- False Output: New User → AI Agent1
1.5 Switch - Content Classification
Purpose: Splits incoming messages into text and photos Conditions:
- Output 0 “Text”: message.text exists
- Output 1 “Photo”: message.photo exists
SECTION 2: ONBOARDING NEW USERS
2.1 AI Agent1 - Nutrition Program Creation Agent
Purpose: Onboards new users and creates a personalized nutrition program
System prompt:
# Nutrition Program Creation Agent - Onboarding
## Your role
You're a specialist in creating personalized nutrition programs. You work ONLY with new users.
## Work scenario
### Message 1: Welcome
“Hi! 👋 Pleased to meet you!
I'll help you create your personalized nutrition program in 3 minutes.
What is your name?”
### Message 2: After the name
“Nice to meet you [Name]!
Tell us about yourself:
- Gender and age?
- Height and weight?”
### Message 3: After receiving data
“Great! Now let's define the goal:
1 ️ ⃣ Lose weight
2 ️ ⃣ Gain weight
3 ️ ⃣ Support the form
What do you choose? (write a number)”
### Message 4: After choosing a goal
[If losing weight]: “How many kilos do you want to lose weight?”
[If set]: “How many kg do you want to gain?”
[If maintained]: move on to the next
### Message 5: Activity Level
“The last question is your activity:
1 ️ ⃣ Sedentary lifestyle
2 ️ ⃣ 1-2 workouts per week
3 ️ ⃣ 3-4 workouts per week
4 ️ ⃣ 5+ workouts per week
Choose a number”
### Message 6: Calculate and Save
[Calculate using formulas]
[Call SAVE_USER_PROGRAM]
“✨ Done, [Name]!
📊 Your program:
- [XXXX] kcal per day
- Proteins: [X] g
- Fat: [X] g
- Carbohydrates: [X] g
The program has been saved! Now you can text me what you eat and I'll count everything 💪”
## Formulas
BMR male = (10×weight) + (6.25×height) - (5×age) +5
BMR women = (10×weight) + (6.25×height) - (5×age) -161
TDEE = BMR × [1.2/1.375/1.55/1.725]
Calories = TDEE ± goal adjustment
Connected components:
- OpenAI Chat Model1 (gpt-4.1-mini)
- Simple Memory1 (Session Key: chat.id)
- SAVE_USER_PROGRAM - program saving tool
2.2 SAVE_USER_PROGRAM - Save a nutrition program
Purpose: Saves the new user's personal nutrition program to Google Sheets Settings:
- Operation: AppendorUpdate
- Matching Column: ID
- Fields to be filled in by an AI agent:
- ID (from Telegram)
- First name (Name)
- Gender
- Age
- Weight (Weight)
- Height
- Desired result (Result)
- Physical. Activity
- Goal
- Norma BJU (Daily goals)
SECTION 3: WORKING WITH EXISTING USERS
3.1 AI Agent — Principal Nutrition Agent
Purpose: Works with existing users, keeps food records and makes recommendations
System prompt (short version):
# Principal Nutrition Agent
## Your role
You're working with users who ALREADY HAVE a nutrition program. You help keep track of food and monitor progress.
## Main scenario
### With any food report:
1. **Get context right away: **
- GET_USER_PROGRAM (user plan)
- GET_USER_MEAL (what's already eaten today)
2. **Analyze food: **
- If you need data about KBJU → GET_INFO
- Calculate calories and BJU
3. **Reply to user: **
“[Dish name] is a great choice!
📊 Nutritional value:
- [XXX] kcal
- Proteins: [X] g
- Fat: [X] g
- Carbohydrates: [X] g
📈 Your day:
Eats: [XXX]/[normal] kcal ([X]%)
The goal is left: [XXX] kcal
[Advice based on progress]
Am I recording it?”
4. **Upon confirmation: **
- SAVE_USER_MEAL
Connected components:
- OpenAI Chat Model (gpt-4.1) - basic model
- Google Gemini Chat Model - backup model
- Simple Memory (Your chat ID)
- GET_USER_PROGRAM - getting a nutrition program
- GET_USER_MEAL - getting a food diary
- SAVE_USER_MEAL - preserving food intake
- GET_INFO - search for product information
3.2 AI Transform — Data preparation
Purpose: Unifies the data format from different sources (text/photo) for an AI agent Settings:
- Converts all input data to the “Text” parameter
- Keeps the contents of message.text if it exists
- JavaScript code for transformation
SECTION 4: FOOD PHOTO PROCESSING
4.1 Get a file - Upload photos from Telegram
Purpose: Downloads a food photo sent by a user Settings:
- Resource: file
- File ID: $ ('Telegram Trigger') .item.json.message.photo [2] .file_id
- Credentials: Nutrition
4.2 Analyze image - AI image analysis
Purpose: Analyzes food photos and determines the composition and calorie content
Instructions for analysis:
MAIN FEATURES
- When viewing an image of a food, identify each food and its main components (proteins, carbohydrates, fats, etc.).
- Use standard dimensions (e.g. 26 cm plate, 250 ml cup) to determine the scale.
- Pay attention to whether the dish looks like the one prepared in the restaurant — if so, add extra fat to cook.
- Estimate portion sizes in grams. Use the guidelines in the image.
- Make realistic assumptions. Give preference to normal portion sizes.
- Evaluate calories and macronutrients for each product using reliable databases.
- Calculate calories for each food by entering the likely range.
- Summarize your total calorie range.
Settings:
- Model: gpt-4o
- Input Type: base64
- Text: + caption instructions from the user
SECTION 5: DATA TOOLS
5.1 GET_USER_PROGRAM - Getting a nutrition program
Purpose: Extracts the user's personal nutrition program from Google Sheets Settings:
- Document: “Goals” table
- Filter: ID = chat.id
- Fields: all fields of the nutrition program
5.2 GET_USER_MEAL - Getting a food diary
Purpose: Retrieves the user's meal records for the current day Settings:
- Document ID: 1v2wcfRwakesBMIBAMC4YZ3ZFMY90ZGSHGFEWXDQuiq0
- Filter: ID = chat.id
- Fields: date, time, dish, KBJU, portion weight
5.3 SAVE_USER_MEAL - Saving meals
Purpose: Records a new meal in a food diary Settings:
- Operation: append
- AI fields to fill in:
- Date and time (automatic)
- User ID
- Dish
- Calories
- Proteins
- Carbs (carbs)
- Fats
- Portion weight (weight of food)
- Admission category (type of serving)
5.4 GET_INFO - Information search
Purpose: Searches information about products and dishes via SerpAPI Settings:
- Tool Type: SerPapi
- Query: is formed by an AI agent
- Credentials: Your credentials
SECTION 6: SENDING RESPONSES
6.1 Send a text message - Reply to existing users
Purpose: Sends responses from the main AI agent to users Settings:
- Chat ID: $ ('Telegram Trigger') .item.json.message.chat.id
- Text: $json.output
- AppendAttribution: false
6.2 Send a text message1 - Reply to new users
Purpose: Sends responses from an onboarding agent to new users Settings: Identical to Send a text message
Node connection diagram
Main stream:
Telegram Trigger → New User Verification → Aggregate → If
New User Thread:
If (False: new) → AI Agent1 → Send a text message1
Existing user thread:
If (True: Existing) → Switch
├─ Switch (Text) → AI Transform → AI Agent → Send a text message
└─ Switch (Photo) → Get a file → Analyze image → AI Transform → AI Agent → Send a text message
Connecting AI components to the main agent:
OpenAI Chat Model ──
Gemini Chat Model ───→ AI Agent
Simple Memory ──────
GET_USER_PROGRAM ───
GET_USER_MEAL ──────
SAVE_USER_MEAL ────
GET_INFO ─────────
Onboarding agent connections:
OpenAI Chat Model1 ─
Simple Memory1 ────→AI Agent1
SAVE_USER_PROGRAM ──
Required services and their settings
Telegram Bot setup:
- Create a bot via @BotFather
- Get the token and save it as “Nutrition” credentials
- Set up rights to receive messages and photos
- Install commands: /stats, /today, /left
Setting up Google Sheets:
- Create two sheets in Google Sheets:
- “Goals” table for nutrition programs
- “Nutrition” table for a food diary
- Set up OAuth2 for Google Sheets
- The structure of the “Goals” table:
- ID, Name, Gender, Age, Weight, Height, Desired Result, Physical Activity, Goal, BJU Norm
- The structure of the “Nutrition” table:
- ID, Date, Time, Dish, Calories, Protein, Carbs, Fat, Portion Weight, Intake Category
Setting up AI services:
- OpenAI API:
- Models: gpt-4.1, gpt-4.1-mini, gpt-4o
- Set up billing for all models
- Google Gemini API:
- Backup model for the main agent
- SerPapi:
- To find product information
System capabilities
Features for new users:
- Interactive onboarding in 3 minutes
- Calculation of the KBJU personal rate using scientific formulas
- Taking into account individual goals (sliming/set/maintenance)
- Adapting to activity levels
Features for existing users:
- Keeping a food diary via text or photo
- AI analysis of food photos with the definition of the composition
- Counting calories and macronutrients in real time
- Tracking daily progress
- Personalized recommendations based on goals
- Searching for information about all foods and dishes
AI capabilities:
- Multimodality: working with text and images
- Contextual memory: personalization for every user
- Intelligent analysis: identifying products and services from photos
- Adaptive recommendations: advance-based tips
Use cases
Scenario 1: Onboarding a new user
🤖 Bot: Hi! 👋 Pleased to meet you! What is your name?
👤 User: Anna
🤖 Bot: Nice to meet you, Anna! Tell us about yourself...
[dialogue continues]
🤖 Bot: ✨ Done! Your norm: 1850 kcal
Scenario 2: Accounting for food through text
👤 User: I ate a burger with potatoes
🤖 Bot: Potato burger is a great choice!
📊 Nutritional value: 820 kcal
📈 Eats: 1320/1850 kcal (71%)
Am I writing it down?
👤 User: Yes
🤖 Bot: ✅ Recorded!
Scenario 3: Food photo analysis
👤 User: [sends a photo of the salad]
🤖 AI analysis: [determines composition]
🤖 Bot: Caesar salad is a great choice!
📊 Approximately 380 kcal
The goal is left: 150 kcal
Scenario 4: Statistics and Recommendations
👤 User: /stats
🤖 Bot: 📊 Weekly statistics:
- Average consumption: 1790 kcal
- Goal completed: 5 days out of 7
- Weight trend: -0.8 kg
Great progress! Keep it up!
System application
For personal use:
- Nutrition control without complex applications
- Fast food accounting via photo or text
- Personal program taking into account the goals
- Motivation by tracking progress
For fitness trainers:
- Customer monitoring through a common database
- Automating a routine CBJU calculations
- Objective control meals for wards
- Scaling practitioners
For nutritionists:
- Remote support patients
- Detailed analytics on nutrition
- Increased commitment to the program
- Save time at consultations
The result of the system
What happens is:
- Personal AI nutritionist in your pocket
- Automated food diary with AI analysis
- Goal Achievement System by weight
- Knowledgebase about products and dishes
- Motivational support 24/7
Performance metrics:
- Onboarding time: 3 minutes
- Photo analysis accuracy: 85-90%
- Processing speed: 5-10 seconds
- User commitment: 70% active after a month
- Achieving goals: 65% achieve their goal in 3 months
System advantages:
- Simplicity: messenger interface instead of complex applications
- Personalization: an individual program for everyone
- Flexibility: working with text and photos
- Accessibility: works on any Telegram device
- Science: calculations using proven formulas
ROI and practical value:
- Savings on a nutritionist
- Save time: 5 minutes instead of 30 to keep a diary
- Improving performance: +40% goal achievement
- Scalability: unlimited users

