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 create Audiences by uploading a CSV sheet that contains the contact numbers of the customers you want to send out the notification to

  • However, for a Webhook Campaign, you do not need to define an Audience as it will be provided in the request to the Webhook URL.

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:

  • 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. You may leave the parameters empty and populate them while creating the Webhook campaign from your backend system

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 be taken to this page

Accessing the Token for Webhook Campaign

  • This is the only place where you can access the token, so do not close/go back to another page without clicking on the green Copy button.

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

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

  • It is advisable to export the Postman collection that is shared on this page.

  • If not, make sure you copy the EndPoint URL (below the API token) of the Webhook campaign in order to trigger the notifications

Creation of the Webhook Campaign URL

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

  • In the Status column you will see On Going which means that the campaign is live

  • 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.

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.

  • 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

Possible error events that could occur while sending Webhook Campaigns:

Error Code

Error Message

Description

401

The campaign not found for the given campaign id

Webhook Campaign not found based on the campaign_id provided in the request

401

Account not found for the provided campaign

The account associated with the Webhook Campaign was not found

401

Chatbot not found for the provided campaign

Chatbot associated with the Webhook Campaign not found

401

Kindly provide the campaign's auth token as a Bearer token in the request header

when the Authorization Bearer token is not provided in the webhook campaign request headers

400

kindly provide the WA Number (wa_number) in the request body to continue

when the end user number is not provided in the webhook campaign request body as wa_number attribute

400

Unable to send a notification to this number

when the end user number provided in the webhook campaign's request body is either incorrect/invalid or belongs to a banned region (CU, IR, KP, SY)

401

Whatsapp integration not found in the account

when the WhatsApp integration on which the webhook campaign was created is not found in the account object.

401

Whatsapp template not found

when the message template on which the webhook campaign was created is not found.

400

no chatbot is published on the business number for the given aac_id

when the business number on which the webhook campaign was created is not published with any chatbot.

400

the webhook campaign does not require any media message

when media_url is provided in the webhook campaign request but the template on which it was created does not accept any.

400

an error occurred while uploading an image to s3 for the webhook campaign

when media_url is provided in the webhook campaign request and an error occurs while uploading to the Tars S3 bucket.

400

Could not send notification due to some error

General error message if an unknown error occurs during the initial stages of processing of webhook campaign execution.

400

Failed to send notification

When an error occurs while sending webhook notification to the end user from the 360D side (their server is down, template expects parameters but not provided, etc).

400

Could not send notification due to some error

General error message if an unknown error occurs during the final stages of processing of webhook campaign execution.

Did this answer your question?