What I built
I built a ChatBot that communicates via Twilio's API on WhatsApp. The Bot gives Covid-19 statistics from the US & the UK. It also provides some positive news articles to read in light of recent times.
Category Submission:
COVID-19 Communications
Interesting Integrations
ari-hacks / covid-chatbot
🤖 A Twilio Hackathon Project
Covid-19 ChatBot 🤖
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 |
How I built it
Stack
- Python web framework using FastApi
- Twilio API for WhatsApp
- Automated responses and bot training with Chatterbot
Some Issues
- Setting up ChatterBot produced issues with the nltk package.
- It took some time to find the right way to set up deployment in Heroku, FastApi is a relatively new Python framework so there are not as many resources for it as Django or Flask.
- Querying news articles based on keywords did not always produce 'good' news, however, I selected The Guardian API because you can also query on basic logic operators.
- The Chatbot doesn't always return the desired results.
Things I learned
Since this is my first Hackathon and I am quarantined in another country I decided to use the time and opportunity to learn all new things! This is the first API I've created with python. I decided on FastApi because of its simplicity and great features (especially the built-in docs 🙌🏾).
I also wanted to add a machine learning component so after some research, I landed on ChatterBot. I think it is a great introduction for someone wanting to learn some of the basics of ML.
Additional Resources/Info
I used the Guardian API to get news articles and a Covid-19 API from rapidapi.com to get coronavirus statistics.
Top comments (5)
Can you tell me about the bug:
File "./app/services/stats_service.py", line 17, in getUkStats
response = httpx.get(settings.COVID_STATS_ENDPOINT + '?format=json&name=uk', headers=headers)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Hey Phu,
Are you using Python 3?
I am using python3.8
I'm so excited about what you did.
You can provide detailed source code for the project to be deployed to covid-chatterbot.herokuapp.com
My mail : quynhbuihd@gmail.com
Thank you!
Hey Phu,
Happy to help out, send me a message via Chat here on Dev.to