
How to send an SMS using Node JS

Africa’s Talking is a company that was founded in 2010, Africa’s Talking has grown to be a company that is fueled by the need to empower developers building for Africa. Over the years, they have worked on creating a platform that fully supports a growing community of over 25,000 developers, spread across the continent and beyond.
The company has remained among the top companies offering SMS, and USSD preferred by programmers. It also offers other services such as Voice calls, Airtime, and Internet of Things(IoT).
We need to send SMSs everyday from our systems to mobile phones, be it OTP, verification codes, notifications, etc.
We will be using Node Js as our backend programming language to send SMSs to mobile phone using Africa’s Talking restless gateway.
What do we need to send SMS?
- A laptop with installed Node Js. Download Node Js Here.
- An account at Africa’s Talking. Visit here to register.
- Visual Studio Code Editor: Download Here
- A cup of coffee. (:
Let us get started.
- Create a blank directory in your laptop/pc.
- Open VS Code and navigate to file, open folder. Locate the folder/directory you had created.
- Initialize your application by running the following command on the console.
A new file “package.json” will be created inside the folder.
4. Install the following required dependencies by running the commands on the console.
Below is how our new “package.json” file will be looking like:
5. Create a new file “index.js” and add the following content in it.
6. Create a new file “main.ejs” inside the “views” folder and add the following content.
Run the following command on the console. Open your browser and visit http://localhost:3000, enter your phone number, message and hit submit. Wait for the magic!
Download the source code from https://github.com/alboom25/node-send-sms-africas-talking
HAPPY CODING!!!