Download the coronavirus notifier bot and get more information about the project from here.

Also, the notifier bot sends an information message in the given period if there is no change (STABLE).

The project in a nutshell:

To obtain the information from the data provider(JHU CSSE with JHU APL), I used a well-programmed application by Rodrigo Pombo (pomber). It collects all the required data for the bot in a JSON file.

As you may have got familiar with my previous projects, to send notification messages via WhatsApp, I used the Twilio's API for WhatsApp in PHP.

To host the coronavirus notifier bot and manage the data evaluation process automatically in PHP to detect the data status of the selected country (STABLE or CHANGED), I set up a LAMP (Linux, Apache, MySQL, PHP) server with MariaDB on Raspberry Pi.

Running on the LAMP server hosted by Raspberry Pi, I designed a user-friendly interface in which you can change the country whose data is collated and enter your Twilio application settings (SID, AUTH_TOKEN, from_phone_number, to_phone_number). The interface also allows you to automatically create a database table named variables before activating the notifier bot. And thus, without needing any coding, you can observe the daily coronavirus case report of the selected country by merely using the bot interface.

By the following steps, you can replicate the WhatsApp coronavirus notifier bot project to run it on your Raspberry Pi or your personal computer as the localhost.

Preview: What You Will Learn

Step 1: Creating a Twilio application

To send WhatsApp messages through Twilio's API, the only thing you need to do is to sign up for a Twilio Trial Account.

After signing up, with your SID and Auth Token, you can use Twilio's API for WhatsApp without any charge. As explained on Twilio, you need to join a shared phone number with your phone in order to verify your phone number and initiate the Twilio's API for WhatsApp.

For more information and learn how to create a new account, click the link below.

Go to Twilio.

You can sign up for Twilio with my referral code here.

1) Create a new application

2) Go to the Sandbox to get the code

3) Connect your phone to your application with the code

Step 2: Setting up a LAMP web server on Raspberry Pi

If you are a novice in programming with Raspberry Pi, you can inspect well-explained instructions and tutorials on the official Raspberry Pi website.

To go to the official Raspberry Pi setting up tutorial, click here.

sudo apt-get install apache2 -y
hostname -I
sudo apt-get update
sudo apt-get install php -y

- Install the MySQL Server (MariaDB) and PHP-MySQL packages by entering the following command into the terminal window:

sudo apt-get install mariadb-server php-mysql -y
sudo mysql_secure_installation
sudo mysql -uroot -p
create database coronabot;

GRANT ALL PRIVILEGES ON coronabot.* TO 'root'@'localhost' IDENTIFIED BY 'bot';

FLUSH PRIVILEGES;
sudo apt-get install php-curl
sudo service apache2 restart

Step 3: Developing the coronavirus notifier bot and installing it on Raspberry Pi

I developed the coronavirus notifier bot (coronabot) in PHP and explained the source code of the bot in the Code Explanation section below for those who are interested.

However, if you are not fond of web development, you can skip the Code Explanation section since the bot is ready to install and run.

Install:

If you have completed Step 1 and Step 2, you can run the bot interface to enter settings (SID, AUTH_TOKEN, To_Number, From_Number, Country) without needing any coding on your Raspberry Pi by installing the coronabot on the localhost. All database and user settings are pre-filled.

By the following steps, install the coronabot on the localhost:

Extract the coronabot.zip.

sudo mv /home/pi/Downloads/coronabot/ /var/www/html/

http://localhost/coronabot/

Features:

1) Open the bot interface to create a table named as variables in the coronabot database. You should see the default variables if the bot is working properly after installation.

2) Enter the required settings for the bot - SID, AUTH_TOKEN, To_Phone_Number, From_Phone_Number, Country. All accessible countries are provided. Note: Refrain from entering phone numbers with '+' at the beginning.

3) Display the current settings in the table (variables) and change them even though you activated the terminal to get WhatsApp messages.

4) Via the terminal, according to the settings in the table (variables), get the daily case report of the selected country from the data provider and send WhatsApp notification or information messages depending on the data status (CHANGED or STABLE). If there is a change in date, confirmed, or recovered variables, the bot defines the data status as CHANGED.

http://localhost/coronabot/terminal.php

Code Explanation (Optional):

In this section, I will explain how I developed the coronavirus notifier in PHP.

1) index.php

2) index.css

3) class.php

4) terminal.php

Note: If you have completed Step 1 and Step 2, do not change any values.

Step 4: Programming Raspberry Pi to create a loop

Download the requests library to make HTTP requests in Python.

pip install requests

Note: I chose to get update messages via WhatsApp every 15 minutes, but you can change the period in the code - 15 * 60.

Features

1) Get notified when there is a change in date, confirmed, or recovered values in the daily case report. (⚠)

2) Change the selected country via the bot interface on Raspberry Pi to obtain information about different countries via WhatsApp.

3) Observe the daily coronavirus (COVID-19) case report of your country in the given period (15 minutes) via WhatsApp. (🔔)

Videos

Demonstration