API REFERENCE DOCS
Gautam Rajesh Shelley avatar
Written by Gautam Rajesh Shelley
Updated over a week ago

Wish to automate WhatsApp campaigns by connecting your CRM with AiSensy?

In this doc, we'll tell you the exact steps you need to perform 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, you would need your development team to help you out 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 case of a new user (i.e. the user doesn’t exist on your contact list in AiSensy Platform) then a new contact will get created with the incoming details.

Populate the Jason key strings against each attribute according to the table below

Fields

Description

apiKey

string

Required. API key generated from the dashboard.

Go to manage> API Key >Copy the key

campaignName

string

Required. Name of the campaign which has to be sent to the user. The status of the campaign should be ‘Live’.

Go to campaigns> Copy the name of the API campaign created

destination

string

Required. Mobile number of users with country dial-code to whom the campaign has to be sent.
e.g. – +917428526285 (India)
It's recommended to provide it in +(country code)(phone number) format. If a phone number can't be resolved to any country then, it is by default considered to be from India(+91).

userName

string

Required Name of the user to whom the campaign has to be sent.

source

string

Optional. Source of lead. It is to create a source-based segment to re-target.
e.g.- ‘Facebook forms’, ‘Website lead’, ‘Youtube lead’

media

object

Optional. URL & filename of media that has to be sent with the template message.

location

string


Required. latitude, longitude, name & address of location that has to be sent with the template message.

templateParams[]

string

Optional. An array of parameter values to fill in a template message

If there is any dynamic value included in the template message enter the details of it. Multiple values are separated by comma

tags[]

string

Optional. An array of tag names to assign to the user.

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 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 medial URL provided in the media object should be publically accessible, otherwise, the request will be rejected

  • The length of the template params array should be equal to the number of params required in the campaign whose name is provided in 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 successful, the response body will return a status of 200.

Prerequisites

  1. You have verified WhatsApp Business API. How?

  2. You have template messages approved.

  3. You have already created an API Campaign. How to create API Campaign?


Did this answer your question?