WhatsApp Template Messages are specific message formats that you as a business can use to send out notifications to a large customer base on WhatsApp. If you are just starting off, here's a guide on how you can setup WhatsApp Template Campaigns with TARS.

Now let's jump to Webhook Campaigns

Creating a Webhook Campaign

Adding Details

The campaign creation modal is mostly the same but now with the addition of a dropdown to select the type of campaign.

Here, you need to select the type of campaign you want run:

  • Standard Campaign: The type of campaign where you need to upload a CSV sheet and provide the input parameters of the template message.

  • Webhook Campaign: The newly added programmatic campaign in which you can use an API to send notification to a single end-user WhatsApp numbers

Standard Campaign vs Webhook Campaign

  • For a standard campaign, it is mandatory for you to upload a CSV sheet that contains the contact numbers of the customers you want to send out the notification to

Campaign Creation Modal
  • However, for a Webhook Campaign, you do not need to upload such CSV sheets as it will be provided in the request to the Webhook URL.

Selecting Webhook Campaign

Input Parameters for the Message Template

  • If a message template requires input parameters then for a Webhook campaign there's no need to provide the input parameters in the campaign creation modal as they will be provided in the request body.

  • Input parameters for a standard campaign are provided in the campaign creation modal as:

Input Parameters for a Standard Campaign
  • This is not needed during the creation of a Webhook Campaign as the input parameters will be provided in the request to the Webhook URL.

Input Parameters for a Webhook Campaign

Webhook Campaign Token

  • A token is needed to access the Webhook Campaign.

  • After clicking on the Create Campaign button and after the Webhook Campaign is created you will see a Copy Token button in the campaign creation modal.

Accessing the Token for Webhook Campaign

  • This is the only place where you can access the token, so do not close the modal without clicking on the Copy Token button.

  • Clicking on the Copy Token will automatically copy the token to the clipboard.

  • Keep the token somewhere safe since without it you can not access the Webhook Campaign.

Creation of the Webhook Campaign URL

  • After creating a Webhook Campaign, you can view it in the campaigns table

Campaigns Table
  • Here, you can view stats of the Webhook Campaign and other campaign details.

  • You can also download the CSV sheet after you have used the Webhook Campaign to get additional details regarding the user response data.

  • In the Progress column you will see the Webhook URL which holds the Webhook Campaign's URL.

  • Right click on it and select Copy link address to copy the the Webhook Campaign's endpoint where you would send the request to send the notification

Webhook Campaign URL in Campaigns Table

Sending Request to Webhook Campaign's URL

Setting up the token in request header

  • The token that was copied after the creation of the Webhook Campaign needs to be passed in the request header as a bearer token.

  • You can pass the token in the Authorization value in the request header in the format

→ bearer {token}

  • Example:

i) In Headers

Setting token as Bearer Token in Headers

OR

ii) in Authorization

Setting token as Bearer Token in Authorization

Request Body Format

  • The variable names that will be sent in the request body to the Webhook URL are:

  1. wa_number (required):

  • A string variable

  • Contains the end-users' WhatsApp number in format → 918105071500 (without '+' sign).

  • Example:

Setting Whatsapp Number in the Request Body

2. parameters (optional):

  • An array of string variables.

  • Contains the input parameters for the template message.

  • For a template message with no input parameters, there's no need to pass this variable otherwise the server will respond with an error.

  • For a template message with two input parameters, you need to pass an array of two elements.

  • The order of values inside the input_parameters array should be in order with respect to the template message’s {{1}} {{2}} ... etc.

A Message Template with Two Input Parameters
  • So, the first element in the array will represent {{1}} of the template and so on.

  • Example:

i) for a message template without any input parameters

Request Body for a Message Template without input parameters

ii) for a message template with one input parameter

Request Body for a Message Template with Single Input Parameter

iii) for a message template with two input parameters

Request Body for a Message Template with Two Input Parameters

Response

  • The server will respond in the following format based on whether the request was successful or not.

  1. Successful:

    1. Template_name: The template name that was used for the Webhook Campaign

    2. Status: The status of the notification, in this case it would be 'sent'. message_id: unique_id of the notification

    3. Receiver: The receiver's WhatsApp number that was provided in the request body

    4. Cost: Cost of the notification

    5. Available_balance_in_account: WhatsApp credits balance available after sending the notification

  2. Failure:

    1. Status: The status of the notification, in this case it would be 'error'

    2. Message: The reason for the failure to send the notification

Did this answer your question?