Simple Steps to Send WhatsApp Messages using API

Sayantan Sarkar
4 min readSep 9, 2023

--

Helpful Tips for small businesses to connect with their customers

Photo by Mariia Shalabaieva on Unsplash

WhatsApp has undeniably become an indispensable tool in our day-to-day lives, transforming the way we communicate. Its meteoric rise to popularity can be attributed to its user-friendly interface, instant messaging capabilities, and wide accessibility across various devices. However, it’s not just a platform for personal connections; WhatsApp has evolved into a crucial communication channel for businesses as well. With the ability to send bulk messages through API calls, it offers a more interactive and immediate way for businesses to engage with their customers. Unlike traditional SMS and email, WhatsApp provides a richer, multimedia experience that fosters stronger customer relationships. This shift has allowed businesses to send personalized messages, share updates, and even provide customer support seamlessly, making WhatsApp a vital tool for modern businesses to connect and engage with their audience effectively.

Throughout this article, I will guide you through the process of implementing WhatsApp bulk messaging via API calls in a straightforward and user-friendly manner. I understand that complex technical procedures can seem daunting, but fear not; I’ll break it down step by step, ensuring that even those new to this concept can follow along with ease.

Moreover, stay tuned until the end of the article, where I’ll share a valuable tip that can make a significant difference in your WhatsApp messaging strategy. So, let’s get started on this journey towards harnessing the power of WhatsApp for your communication needs!

Before starting, make sure you have a developer account and an app in Facebook. If not, give it a read-

Now, once you have it, Add Product -> Choose WhatsApp and click set up.

Under API set up you will get this page -

Here adding a recipient number, if you click Send message you would receive a message from the test number.

Now, let’s start to configure to suit our needs.

First, we would need to add a number from where we need to send message to customers.

Scroll down the same page, you would find -

Fill out necessary details to Add phone number.

Second step would to create a message template. Message template are of three types — Marketing, Utility, Authentication.

Marketing — Promotions and information about you business, product or services.

Utility — Messages about specific transaction, account, order or customer request.

Authentication — One time password that your customer use to authenticate a transaction or login.

To create a message template, visit App Dashboard -> WhatsApp Manager -> Account tools -> Message Templates -> Create Template

Let’s choose a message template and proceed —

After that, edit the template details as per your requirements —

Once you are done with this, Submit the template. It will be put for review.

Generally, it takes few hours. After it passes the quality check it can be used for sending message to customers.

To use the new template ‘demo_wa’ in message, the body of the POST call would be like —

{
"messaging_product": "whatsapp",
"to": "918888888888",
"type": "template",
"template": {
"name": "demo_wa",
"language": {
"code": "en_US"
},
"components": [

{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Business Name"
}
]
}
]
}
}

Another suggestion would be how to get permanent access token. For that, Go to Business Settings -> Accounts -> WhatsApp Accounts. Add a user by clicking Add People.

Then, Go to Users -> System Users -> Generate New Token -> Select App -> Check whatsapp_business_messaging and whatsapp_business_management for available permissions -> Generate Token.

Tip: I was looking for option to add line break in the variable parameters that I am passing to body. So, I read through a lot of articles (Ex- https://stackoverflow.com/questions/27780542/create-line-break-in-whatsapp-message, https://github.com/kriskbx/whatsapp-sharing/issues/16). But none of the suggestions worked for me.

Instead adding “\\n” , did the work for me. I hope it helps.

To get more articles like this -

Follow me on Medium.

Follow me on Twitter.

--

--

Sayantan Sarkar

Software Engineer 2 at Lexmark (India), Passionate about Technology, Startup and Love to travel