Food Tracker BOT
A simple an easy to use food tracker Telegram bot.
About
Telegram bot that, based on the photos you send to, tells if you should improve or not your diet based on how healthy or unhealthy is the food you eat on a weekly basis. Users can also have a conversation with the bot as if it were a human.
Developing
Requirements
Libraries
- Flask 1.1.1
- pyTelegramBotAPI 3.6.6
- Pillow 7.0.0
- chatterBot 1.0.5
- pandas 0.25.3
- keras 2.2.4
- scikit-learn 0.22.1
- opencv-contrib-python-headless 4.1.2.30
Getting Started
- Fork this repository
- Clone your forked repository
git clone https://github.com/YOUR-USERNAME/food-tracker-bot.git
Project structure
.
├── chatbot # Chatbot module
│ ├── data # Some training data
│ └── main.py # Main chatbot class
│
├── food_classifier # Food classifier module
│ ├── k_model.py # Used to build the keras model with some architectures to choose
│ ├── predict.py # Script to obtain a prediction from an image
│ └── train.py # Script to train the model
│
├── rasa # Unused module with rasa chatbot implementation
│ ├── data # Some training data
│ ├── models # Trained models
│ ├── rasa-train.py # Script to train rasa data
│ └── main.py # Rasa in action!
│
├── utils # Some project utilities
│ ├── download_image.py # Script to download and resize online image
│ └── generate_message.py # Script to transform food tags to an end-user message
│
└── bot.py # Main bot class
Deployment
-
Create the Telegram bot profile
To create the bot profile you can use an integrated Telegram bot called “Bot Father”. With this bot, you can create new bots by filling the name, description, image and commands. This bot will give you a token (
TELEGRAM_BOT_TOKEN
) that you have to use in the server to get all user info and messages. You have to add this token in the bot.py file. -
Setup server
You can setup the bot server remotely or on a local machine. You only have to run the bot.py file on the machine where you want to host the server with the command
python3 bot.py
.After that, you have to tell Telegram API your server url (weebhook). To do that, you simply has to enter this website:
https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/setWebhook?url={WEBHOOK_URL}
. The url has to be public and with a SSL certificate (https). If you are using a local machine, you will have to make a tunnel to your local url (See: NGROK utility). -
Use the bot!
You are ready to use the bot :)