This is a simple ChatBot that communicates via Twilio's API on WhatsApp. The Bot gives Covid statistics from the US & the UK. It also provides some positive news articles to read in light of recent times.
Users interact with WhatsApp to communicate with the ChatBot. The Bot replies to greetings along with different variations of the following questions.
Input | Output |
---|---|
Greeting! | Hi |
Hi, How is it going? | Good |
uk confirmed cases? | Confirmed Uk Cases 165221 |
How many uk confirmed cases? | Confirmed Uk Cases 165221 |
What are the us covid stats? | United States Stats: confirmed: 1055303 recovered: 144423 critical: 18665 deaths: 61112 |
uk stats | United Kingdom Stats: confirmed: 165221 recovered: 1918 critical: 1559 deaths: 26097 |
what are the uk covid stats? | United Kingdom Stats: confirmed: 165221 recovered: 1918 critical: 1559 deaths: 26097 |
how many us recovered cases are there? | Recovered Us Cases 147411 |
tell me some positive news, please? | https://www.theguardian.com/news/2020/apr/13/coronavirus-looking-for-good-news-run-for-heroes-and-an-opera-singing-doctor |
- Python web framework using FastApi
- Twilio API for WhatsApp
- Automated responses and bot training with Chatterbot
- Testing with
requests_mock
andpytest
- Automated CI testing using Travis CI
- Project specific environment variables using
.env
- Built-in API documentation with Open API docs
- One click deploy buttons for Heroku
After the above requirements have been met:
- Clone this repository and
cd
into it
git clone https://github.com/ari-hacks/covid-chatbot.git
cd covid-chatbot
- Install dependencies
pip3 install chatterbot==1.0.4
pip3 install twilio
pip3 install pytest
pip3 install uvicorn
pip3 install fastapi
pip3 install nltk
pip3 install httpx
pip3 install requests_mock
- Run the application
uvicorn app.main:app --reload
#uvicorn runs on http://127.0.0.1:8000
- Next we need to unzip the ngork download. Ngork creates a secure public tunnel for us to use when communicating with WhatsApp via the twilio API. From your terminal run the following command:
./ngrok http 8000
#this port must match the app port
- After you have created your twilio account navigate to the dashboard's sandbox in the field titled
when a message comes in
enter the generated forwarding address from your terminal and save. The forwarding url will look like this:
- Next follow these twilio instructions to connect your account to WhatsApp and send a message ๐๐๐
You can run the tests locally by typing:
pytest
If you run into issues with nltk
#error in terminal related to ssl verification
#solution - in the terminal run the following commands, make sure you change the version of python accordingly
>>/Applications/Python 3.8/Install Certificates.command
>>Python3
>>Import nltk
>>nltk.download()
To try this application locally, you can deploy it to Heroku.
#check if app is running with this endpoint
https://heroku-porject.herokuapp.com/twilio/health-check
#add this endpoint into your twilio snadbox
https://heroku-porject.herokuapp.com/twilio/bot
Please Sign up before Deploying.
No warranty expressed or implied. Software is as is.