Sending the Message Template

This page will cover everything you need to know in order to initiate the conversation with your customer.

The message template is predefined and initial message towards your users at any time. All message templates are created in WhatsApp Manager and this process is completed by Infobip team on behalf of the Client. Messages are reviewed and checked to ensure that they do not violate or harm WhatsApp policies. After the approval process is completed, every Client/Business will have their own namespace where all message templates will be stored and available.  

 

Example: 

Welcome message named welcome_message could look like the following:

Hello {{1}}! Welcome to Infobip WhatsApp Use Cases.  
 
To find out what we can do for you, type Info. 

INFO

For template registration contact us. The registration process can take more than one day.

Since WhatsApp doesn’t want for end-users to be spammed on their channel, there are rules on the type of content that can be shared over WhatsApp channel and they’ve introduced the opt-in procedures in order to provide an option to the users to choose what type of information they would like to receive and from whom. Infobip is providing a guideline with details on how to collect and manage opt-ins on your side. 

NOTE

Enterprise is completely in charge of collecting and managing opt-in database on their side.

Send WhatsApp template message 

If you would like to send WhatsApp template messages, please check the example provided below.

Parameters

Body Params

Parameter Type Description
templateName string Template name 
templateNamespace string Template namespace
templateData array of strings Template parameters values ordered as registered in template 
language   The code of the language or locale to use. Needs to be exactly the code with which the template was registered.
policy  

The language policy the message should follow -deterministic or fallback. 

deterministic — Deliver the Message Template in exactly the language and locale asked for. 
fallback — Deliver the Message Template in the language that matches the user's language/locale setting on the device. If one can't be found, deliver using the specified fallback language. 

This field is optional and defaults to deterministic

IMPORTANT

When sending WhatsApp template message, templateName, templateNamespace, templateData, and language are mandatory fields!

In order to successfully send the message, all parameters need to be matched. If the message template contains 2 placeholders, then template data needs to be an array of exactly 2 parameters. Otherwise, the message template will not be formed successfully on the end user’s device and the message will not be displayed.

 

NOTE:

Pay attention to match the number of parameters in the registered template and the number of parameters specified in API call. 

 

WhatsApp template message request example: 

POST /omni/1/advanced HTTP/1.1 
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== 
Content-Type: application/json 
 
{
    "scenarioKey": "CC9F01A5DC7BEE2C2B829D203482A654",
    "destinations": [
        {
            "to": {
                "phoneNumber": "41793026727"
            }
        }
    ],
    "whatsApp": {
        "templateName": "template_name",
        "templateNamespace": "whatsapp_templatenamespace",
        "templateData": [
            "Jennifer",
            "$2543.56"
        ],
        "language": "en"
    },
    "sms": {
        "text": "This text will be received via SMS if WhatsApp message is not delivered.",
        "validityPeriod": 1
    }
}	
  

Response format 

If successful, the response header HTTP status code will be 200 OK and the message will be sent. 

If you try to send the message without authorization, you will receive a 401 Unauthorized error. 

HTTP/1.1 200 OK 
Content-Type: application/json 
 
{
    "messages": [
        {
            "to": {
                "phoneNumber": "41793026731"
            },
            "status": {
                "groupId": 1,
                "groupName": "PENDING",
                "id": 7,
                "name": "PENDING_ENROUTE",
                "description": "Message sent to next instance"
            },
            "messageId": "50c24400-124f-4678-9f4b-309e994a4deb"
        }
    ]
}