Wish to automate WhatsApp campaigns by connecting your CRM with AiSensy?
In this document, we'll explain the exact steps to automate WhatsApp notifications via API campaigns using AiSensy.
Step: 1- Create an API campaign in AiSensy.
1. In AiSensy App, go to Campaigns, click on +Launch & select API Campaign
2. Add a Campaign Name, select a pre-approved template to which you wish to send using the campaign & set the API campaign live
Note: Make sure your WhatsApp template message is created & approved before creating the API Campaign. For reference, check out how to create WhatsApp templates in AiSensy.
Step 2: Integrating AiSensy with your CRM
For this step, it will be necessary for your development team to assist you with the integration process.
1. Connect your trigger point of your CRM/ website/ 3rd party software using JSON key format & endpoint URL given below
HTTP Request
{
"apiKey": string,
"campaignName": string,
"destination": string,
"userName": string,
"source": string,
"media": {
"url": string,
"filename": string
},
"templateParams": [
string
],
"tags": [
string
],
"attributes": {
"attribute_name": string
}
}
Send notifications to users through API:
NOTE: In the case of a new user (i.e. a user who does not exist in your contact list in the AiSensy Platform), a new contact will be created using the incoming details.
Populate the JSON key strings against each attribute according to the table below:
Fields | Description |
apiKey | string Go to Developer > API Campaign key > Generate the key and copy the key. |
campaignName | string
Go to Campaigns > Copy the name of the API campaign created. |
destination | string For all numbers outside India, it's mandatory to provide it in +(country code)(phone number) For Indian numbers, it's optional to provide it in +(country code)(phone number) If a phone number can't be resolved to any country then, it is by default considered to be from India(+91). |
userName | string |
source | string |
media | object |
location | string
|
templateParams[] | string
If there is any dynamic value included in the template message enter the details of it. Multiple values are separated by comma |
tags[] | string |
attributes | object with key-value pairs. The only string is allowed as the key's value.
Optional. The object should contain keys already added as assistant attributes paired with values that you want to set as the user's attributes. |
Example Postman Request
Step 1 - Setup request type to "POST"
Step 2 - Setup URL
Step 3 - Choose body type "raw"
Step 4 - Select "JSON" type
Step 5 - Set content of the request
You can find more examples here - Open in Postman
NOTES:
Optional fields are not necessary for the request payload
The media URL provided in the media object should be publicly accessible, otherwise, the request will be rejected
The length of the template params array should be equal to the number of parameters required in the campaign whose name is provided in the campaignName field. Otherwise, the request will be rejected
Tags should be created in your project before using them. It can be done by anyone with manager level access
If a tag doesn't exist in your project, it will be ignored
Attributes should be added to the project before using them. It can be done by anyone with manager level access
If an attribute doesn't exist in your project, it will be ignored
Response Body
If the request is successful, the response body will return a status of 200.
Prerequisites
You must have verified WhatsApp Business API. How?
You must have approved template messages.
You have already created an API Campaign. How to create API Campaign?
Example cURL request
curl -X POST -H "Content-Type: application/json" -d '{
"apiKey": "<YOUR_API_KEY>",
"campaignName": "outmissedcall",
"destination": "8130740348",
"userName": "New Customer Support",
"templateParams": [
"$FirstName"
],
"source": "new-landing-page form",
"media": {},
"buttons": [],
"carouselCards": [],
"location": {},
"attributes": {},
"paramsFallbackValue": {
"FirstName": "user"
}
}' https://backend.aisensy.com/campaign/t1/api/v2



