In this project, I will show you how you can easily create a powerful chatbot to handle your growing customer requests and inquiries.
I will also show you how to deploy your chatbot to a web application using Flask.
Feel free to read the post I published on Towards Data Science here
Chatbot Notebook.ipynb - Jupyter notebook used to develop chatbot
chatbot_training.py - chatbot training script
chatbot.py - chatbot script
web_app.py - Flask web application
Please install chatterbot, chatterbot_corpus and spacy if you had not done so. Apart from that, there should be no extra libraries required to install apart from those coming together with Anaconda distribution. The code should run with no issues using Python versions 3.5 and above.
chatterbot, os, flask
- Install ChatterBot library.
pip install chatterbot
- The ChatterBot text corpus is distributed in its own Python package, so you need to install it separately.
pip install chatterbot_corpus
- If you have not installed spaCy (an open source library for advanced NLP) before, then please install it now because CHatterBot library needs it to work.
pip install spacy
- Install spaCy English ('en') model after installing the spaCy library.
python -m spacy download en
- Save your conversation text files in training_data folder.
- Run chatbot_training.py to train your chatbot. You will be asked to choose if you want to train the chatbot with English corpus data - select Y or N.
(Select Y - your chatbot will be trained to have conversations in the following scope: AI, botprofile, computers, conversations, emotion, food, gossip, greetings, health, history, humor, literature, money, movies, politics, psychology, science, sports & trivia.) - Run chatbot.py to launch chatbot in terminal. You can input some conversations and test if it responds properly.
- Run web_app.py to deploy chatbot to web app using Flask.
ChatterBot for creating such a powerful chatbot library.