An intelligent Telegram bot that helps users track their nutrition and fitness goals using AI-powered image analysis and natural language processing. The bot can analyze food photos, provide nutritional information, and offer personalized health advice.
Bot url: t.me/Fit_ioBot
- Use
/startcommand to start the bot. - The bot will ask you to select your health goal.
- After selecting your health goal, the bot will ask you to upload a photo.
- The bot will analyze the photo and give you a report and a chart.
- (Beta) You can choose to store your photo and data in your record.
- (Beta) Use
/paycommand to pay for the service. - Use
/cancelcommand to cancel the current operation. - You can also chat with the bot by sending messages and the bot will remember your conversation.
- Install python 3.11 or later.
- Install poetry.
- Use command
make installto install all the dependancies in poetry. - Use command
make runto run the telegram bot.
- User goal setting and profile management
- Real-time food photo analysis
- Nutritional content estimation
- Visual nutrition charts
- Meal history tracking
- Interactive conversations about health and nutrition
- Payment integration
- Main Bot Application (
main.py)- Handles bot initialization and conversation flow
- Manages user states and interactions
- Implements command handlers and callbacks
- Utilities Package (
utils/)gpt4.py: OpenAI GPT-4 integration for image and text analysischart.py: Nutrition visualization generationsave_food_to_db.py: Database operations for meal trackinghealth_rating.py: Health rating calculations and formatting
graph TD
A[Start] --> B[Health State]
B --> C[Photo State]
C --> D[Reply State]
D --> E[End State]
class State(Enum):
HEALTH_STATE = 1
PHOTO = 2
REPLY_PHOTO = 3
REPLY_TEXT = 4
END = 5- Start Handler
- Initializes user profile
- Stores user information in database
- Sets up conversation context
- Health State Handler
- Manages user health goal selection
- Provides interactive goal buttons
- Updates user profile with selected goal
- Photo Handler
- Processes uploaded food images
- Triggers AI analysis
- Generates nutrition charts
- Offers meal saving options
- Used for image analysis and natural language understanding
- Custom prompts for consistent formatting
- Nutrition extraction and health scoring
- RESTful endpoints for user management
- Food entry storage and retrieval
- User profile updates
user_data = {
"name": str,
"age": int,
"height": float,
"weight": float,
"telegram_id": int,
"goal": str
}food_data = {
"user_id": int,
"food_analysis": str,
"food_photo": bytes,
"calories": float,
"carb": float,
"protein": float,
"fat": float
}BOT_TOKEN=your_telegram_bot_token
OPENAI_API_KEY=your_openai_api_key
API_BASE_URL=your_backend_api_url
python-telegram-bot
openai
Pillow
matplotlib
requests
python-dotenv
- Multi-language support
- Progress tracking and analytics
- Social sharing features (ex. Instagram)
- Integration with fitness tracking devices