An AI Chatbot using Python and Flask REST API
- TensorFlow
- Flask
- Clone the repository-> cd into the cloned repository folder
- Create a python virtual environment
# macOS/Linux
# You may need to run sudo apt-get install python3-venv first
python3 -m venv .venv
# Windows
# You can also use py -3 -m venv .venv
python -m venv .venv
When you create a new virtual environment, a prompt will be displayed to allow you to select it for the workspace.
- Activate the virtual environment
#linux
source ./venv/bin/activate # sh, bash, or zsh
#windows
.\venv\Scripts\activate
- Run
pip install --upgrade tensorflow
to installTensorflow
- Run
pip install -U nltk
to installnltk
- Run
pip install -U Flask
to installflask
- To expose your bot via Ngrok, run
pip install flask-ngrok
to installflask-ngrok
Then you'll need to configure your ngrok credentials(login: email + password) Then uncomment this linerun_with_ngrok(app)
and comment the last two linesif __name__ == "__main__": app.run()
Notice that ngrok is not used by default. - To access your bot on localhost, go to
http://127.0.0.1:5000/
If you're on Ngrok your url will besome-text.ngrok.io
https://dentricedev.com/blog/how-to-create-an-ai-chatbot-in-python-and-flask-gvub
https://dev.to/dennismaina/how-to-create-an-ai-chatbot-in-python-and-flask-1c3m
To run this Bot, first run the train.py
file to train the model. This will generate a file named chatbot_model.h5
This is the model which will be used by the Flask REST API to easily give feedback without the need to retrain.
After running train.py
, next run the app.py
to initialize and start the bot.
To add more terms and vocabulary to the bot, modify the intents.json
file and add your personalized words and retrain the model again.
Reach out to me [email protected] I will be happy to assist
Fork the repo @ GitHub.