Code Monkey home page Code Monkey logo

covid-chatbot's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.