An application that can be used to find food and restaurants through a chatbot
Start talking now! -> m.me/FoodChatApp
These instructions will guide you through the process of setting up the application on your local machine
Python 3.x
Let's setup your development environment
# Installing basic requirements
$ git clone https://github.com/baileyritchie/food_chat_app
$ cd food_chat_app
$ virtualenv venv
$ source venv/bin/activate
$ (venv) pip install -r requirements.txt
When developing locally, create a .env file in your root folder that follows the structure below:
ACCESS_TOKEN = "Paste access token here. Check it from the facebook developer account section"
VERIFY_TOKEN = "Make your own activation token and make set it on facebook developer"
DB_NAME = "food_chat_db"
DB_USER = "root"
DB_HOST = "localhost"
DB_PASS = "password here"
- make sure you have an .env file at the root location with the database and verification tokens inside it. Also make sure you have the database schema built. If not run
run_build_db.py
and make sure mysql is running on your computer. - run
run_server.py
- run
ngrok http 5000 -bind-tls=true
in your terminal, then copy the https address - go to
https://developers.facebook.com/apps/1270646319787767/messenger/settings/
- Click
Edit Callback URL
and enter thehttps address/webhook
- Enter the verification token you declared in your .env file
- go to food chat app page and talk to the bot!
Okay so you wannna do some NLP stuff.
- Go to
food_chat_app/models/nlp/data/intents.json
and follow the format.
Be cognizant about these major model characteristics: word frequency is not rewarded, word counts are normalized to either 1 if the word exists, or 0 if it doesn't. Sentence structure is mildly important as lemmatization uses POS tagging. Pay careful attention to how your frame your questions, two intents should not have sentences framed the same way. If that happens maybe you should rethink your approach and might not need two separate intents. Prepositions seem to have a noticeable impact on performance. And finally, write a bunch of phrases for your intent to get better training.
-
Go to
food_chat_app/controllers/app_routes.py
and update the intent_to_strat() function. -
Go to
food_chat_app/models/nlp/intent_types.py
and update with your new intent. -
Go to
food_chat_app/models/nlp/intent_strategy.py
and update with your new intent. -
run
run_build_nlp.py
if the accuracy is < 70%, then run again or consider changing training data for the model. -
run
pytest -s --disable-pytest-warnings
to see results. Make sure all test cases pass.
Provided is a run_scraper.py
file you can use to generate a .csv file with data. You can update your database using the csv file, calling the upsert_data() function, or asking your chatbot to do it for you "update database"
Provided run_build_db.py
file builds the schema for you. Otherwise, use the create_all_tables.sql file to make the schema manually.