What is Whatsapp? π€·
WhatsApp is a mobile messaging application which allows you to send and receive messages without having to pay for SMS.
WhatsApp is the most popular messaging app in the world with over 1 billion monthly active users.
WhatsApp's end-to-end encryption ensures that your messages are secure from third parties like hackers and government surveillance programs.
What can you do with WhatsApp API? π
Usage Scenarios for the API
- Sending programmatic responses to contacts.
- Providing Customer support to a Business.
- Marketing.
- etc.
Let's Begin π
Note: Install Node.js v16+ if you havenβt already.
We are going to use whatsapp-api-nodejs that converts users WhatsApp account into an API.
In addition, whatsapp-api-nodejs can π€―:
- send media message such as image, video, document etc
- send response message data to a specified webhook URL
- send messages to groups
- downloads contacts profiles pic
- send template message
- create, delete and join a group
- etc.
To get started clone the repository from Github:
git clone https://github.com/salman0ansari/whatsapp-api-nodejs.git
Change directory into the project and run
npm install
It will take some time to install the dependencies.
If you going to use webhook make sure to create a .env
file in the project root. Inside the file add:
WEBHOOK_URL=https://your webhook url
Finally, run npm run start
in the project root to start the server. Our applications will be accessed at
http://localhost:3333
Init Instance π
To initialise a server make a GET request
Note: Don't forgot to save KEY value.
ENDPOINT: /init
Scanning QR Code π±
To scan QR code make a GET request
ENDPOINT: /qrcode?key=KEY
QUERY -> KEY = Instance Key
Note: make sure to scan QR ASAP after you init a Instance.
Sending a Message π¨
To send a Text message make a POST request
ENDPOINT: /sendText?key=KEY
QUERY -> KEY = Instance Key
REQUEST BODY:
{
"msg_data": {
"id": "919999999999",
"message": "Hello World"
}
}
API-Docs π
To check more enpoint make a GET request
ENDPOINT: /api-docs
THAT'S IT π
In the next tutorial we will learn how can we use this API to send memes daily to your friend.
Links π
whatsapp-api-nodejs: https://github.com/salman0ansariwhatsapp-api-nodejs
nodejs: https://nodejs.org
Top comments (0)