WhatsApp Integration
Establishing communication via social media platforms like WhatsApp is essential in handling customer requirements and it also helps answer basic inquiries, build the engagement activities easily.
Now Kommunicate allows to integrate with WhatsApp business account and handle the queries via Kommunicate chatbot and with the help of human agents.
We offer integration with WhatsApp using 3 ways
- Integration using 360Dialog
- Integration using Twilio
- Integration using WhatsApp Cloud API
Send Template Message using API
Step 1: Create the Template Object
Create a template object with name, language, and components as mentioned in WhatsApp template API page.
{
"template": {
"name": "account_update_whatsapp",
"language": {
"code": "en_US",
"policy": "deterministic"
},
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "your-text-string"
},
{
"type": "text",
"text": "your-text-string"
}
]
},
{
"type": "header",
"parameters": [
{
"type": "text",
"text": "your-text-string"
}
]
}
]
}
}
As per the above object, "account_update_whatsapp" is the pre-approved template name. In components there are two parameters and one parameter is in Header.
Step 2: Convert it into String and use API to send Template
After creating object, convert it to string using JSON to String Online Converter. Add the string in the “WHATSAPP_TEMPLATE” of send message API.
Below is the example of using API for sending an approved Template named "sample_issue_resolution".
Headers:
api-key: API_KEY_FROM_INSTALL_SECTION'
of-user-id: PASS_SUPER_ADMIN_EMAIL_HERE'
Content-Type: application/json
You can find it in the install section, click here.
POST: https://services.kommunicate.io/rest/ws/conversation/message/send
BODY:
{
"groupName": "Conversation",
"platform": "whatsapp",
"source": "WHATSAPPDIALOG360",
"senderId": "+91xxxxxxxxxx",
"receiverId": "+91xxxxxxxxxx",
"messagePxy": {
"type": 5,
"contentType": 0,
"message": "TEMPLATE MESSAGE",
"metadata": {
"skipBot": true,
"WHATSAPP_TEMPLATE": "{\n \"template\": {\n \"name\": \"sample_issue_resolution\",\n \"language\": {\n \"code\": \"en_US\",\n \"policy\": \"deterministic\"\n },\n \"components\": [\n {\n \"type\": \"body\",\n \"parameters\": [\n {\n \"type\": \"text\",\n \"text\": \"Name - test\"\n }\n ]\n }\n ]\n }\n}"
},
"source": 1
}
}
Note: Please change the
"source"
to"WHATSAPPCLOUDAPI"
if you are using WhatsApp Cloud API and"WHATSAPPTWILIO"
if you are using Twilio integration.
This is how it will look:
We can check the same on the Kommunicate dashboard, it will show as Template Message and user has received the message as well.
WhatsApp Rich Messages
List Message
If you are looking to present customers with multiple choices, you can use this payload.
{
"metadata": {
"templateId": "7",
"contentType": "300",
"payload": {
"headerText": "Options",
"buttons": [
{
"name": "Viral",
"action": {
"text": "Viral",
"type": "quick_reply"
}
},
{
"name": "Bacterial",
"action": {
"type": "quick_reply",
"text": "Bacterial"
}
},
{
"action": {
"type": "quick_reply",
"text": "Parasitic"
},
"name": "Parasitic"
},
{
"name": "Fungal",
"action": {
"type": "quick_reply",
"text": "Fungal"
}
}
]
}
},
"platform": "kommunicate",
"message": "Select a type of infection."
}
Images on WhatsApp
Following is an example of adding an image with a caption and buttons (rich messages).
WhatsApp Limitations
Only certain media files are allowed to be sent or received. See more info here
Only template messages will be allowed if more than 24 hours have passed since the last user message.
WhatsApp does not support more than 3 buttons at a time, to optimize your messages for WhatsApp, Kommunicate automatically converts any extra buttons to a list. Additionally, button titles should be equal to or less than 20 characters and non-repeating.
Detailed information on WhatsApp Limitation: