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.
- How to create a Twilio application
- How to install and configure Apache, PHP, and MySQL to create a LAMP web server on Raspberry Pi
- How to install CURL on Raspberry Pi
- How to define a new user and create a new database with MariaDB on Raspberry Pi
- How to develop a web application (bot) in PHP to send WhatsApp notification or information messages depending on the incoming data from an external server
- How to install the bot on Raspberry Pi
- How to activate the bot terminal in a loop on Raspberry Pi
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.
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.
- Open a terminal window by selecting Accessories > Terminal from the menu.
- Install the apache2 package by typing the following command into the terminal and pressing Enter:
sudo apt-get install apache2 -y
- To test the server, open Chromium by selecting Internet > Chromium Web Browser from the menu and enter http://localhost.
- If you want, you can use the IP address of your Raspberry Pi as well.
- Install the PHP package with the following command:
- Do not forget to update the Pi.
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
- To create a new user, run the MySQL secure installation command in the terminal window.
- You will be asked Enter current password for root (enter for none): — press Enter.
- Type in...