DEV Community

Prathamesh More
Prathamesh More

Posted on

1 2

Build COVID19 SMS Tracker using Twilio + NodeJS

Let’s get started,

Install the required packages

npm install --save express twilio axios

We will be using an external REST API to get COVID19 Cases.

https://api.covid19api.com/

First, get the latest COVID19 cases for India using Axios.


const covidINdata = await axios.get('https://api.covid19api.com/live/country/india/status/confirmed');

const latestData = covidINdata.data;

//API returns an array which contains all snapshots of cases. We will use the latest, which means the last element of the array.

const data = latestData[latestData.length - 1];

//Now configure, Twilio SMS API - Signup for Twilio, and get Account ID and API KEY.

const ACCOUNT_ID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const API_KEY = "your_auth_token";
const client = new twilio(ACCOUNT_ID, API_KEY);
Create body and send SMS,
client.api.messages.create({
        body: data, //This is SMS body, returned from API
        to: 'your_mobile_number',
        from: +12569789527
      }).then(data => {
        return res.status(200).send('SMS has been sent' + data);
      }).catch(error => {
        return res.status(404).send(error);
      });
}
Enter fullscreen mode Exit fullscreen mode

Code:
https://github.com/pprathameshmore/Corona-SMS-Tracker

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (1)

Collapse
 
nawazmujawar profile image
Nawaz Mujawar

Good work

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay