Skip to content

ari-hacks/covid-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Covid-19 ChatBot 🤖

MIT license Build Status

About

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.

How it works

Users interact with WhatsApp to communicate with the ChatBot. The Bot replies to greetings along with different variations of the following questions.

Sample 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

Features

  • Python web framework using FastApi
  • Twilio API for WhatsApp
  • Automated responses and bot training with Chatterbot
  • Testing with requests_mock and pytest
  • 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

Set up

Requirements

Local development

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone https://github.com/ari-hacks/covid-chatbot.git
cd covid-chatbot
  1. 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         
  1. Run the application
uvicorn app.main:app --reload 

#uvicorn runs on http://127.0.0.1:8000    
  1. 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
  1. 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:

Alt text

  1. Next follow these twilio instructions to connect your account to WhatsApp and send a message 🎉🎉🎉

Tests

You can run the tests locally by typing:

pytest

Troubleshooting

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() 

Cloud deployment

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.

Deploy

License

MIT

Disclaimer

No warranty expressed or implied. Software is as is.