WhatsApp Endpoint: Message Types and Payload Examples – Cognigy.AI Help Center
WhatsApp Endpoint: Message Types and Payload Examples
On Cognigy.AI you are able to send messages to WhatsApp from the AI (default) channel, as well as from a WhatsApp channel for specific output that is highly customizable.
The WhatsApp channel supports “Text” and “Custom JSON” fields.
The “Custom JSON” field allows you to copy-paste JSON payloads.
Payload Examples
Text
- Body text is limited to 4096 characters.
{
"type": "text",
"text": {
"body": "Simple text message"
}
}
Rich Link
- Body text is limited to 4096 characters.
- http:// or https:// links are accepted - https:// URLs are preferred.
- Search Engine Optimized content will have rich meta-information to be shown.
- On-click opens in a new tab.
{
"type": "text",
"text": {
"body": "https://yourURL",
"preview_url": "true"
}
}
Quick Replies
Note that:
- Button "title" is limited to 20 characters.
- Button "id" is limited to 256 characters.
- Body text is limited to 1024 characters.
- Min. 1 and max. 3 "reply" buttons can be added.
- Reply "id" and "title" both must be non-empty and unique.
- If the header is of type "text", the text is limited to 60 characters.
- If the header is of type image/video/audio it does not accept caption. Important to also change the "type" value accordingly.
{
"type": "interactive",
"interactive": {
"type": "button",
"body": {
"text": "This is my Text"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "123",
"title": "Button1"
}
},
{
"type": "reply",
"reply": {
"id": "1234",
"title": "Button2"
}
}
]
}
}
}
Image
- Image file extensions supported - .png, .jpg.
- Downloadable link or freely accessible content.
{
"type": "image",
"image": {
"link": "https://imageURL",
"caption": "Image caption"
}
}
Gallery Card
- Body text is limited to 1024 characters.
- Button "title" is limited to 20 characters.
- Button "id" is limited to 256 characters.
- Reply "id" and "title" both must be non-empty and unique.
- If the header is of type "text", the text is limited to 60 characters.
- If the header is of type image/video/audio it does not accept caption. Important to also change the "type" value accordingly.
- Footer "text" value is limited to 60 characters.
{
"type":"interactive",
"interactive":{
"type":"button",
"header":{
"type":"image",
"image":{
"link":"https://imagesURL"
}
},
"footer":{
"text":"*subtext*"
},
"body":{
"text":"*this is text*"
},
"action":{
"buttons":[
{
"type":"reply",
"reply":{
"id":"1",
"title":"quickReply.title1"
}
},
{
"type":"reply",
"reply":{
"id":2,
"title":"quickReply.title2"
}
},
{
"type":"reply",
"reply":{
"id":3,
"title":"quickReply.title3"
}
}
]
}
}
}
Video
- Video file extensions supported: .mp4
- Downloadable link or freely accessible content (e.g. Youtube links are unsupported).
- For unsupported links use "Rich Link" output type above.
{
"type": "video",
"video": {
"link": "https://videoURL",
"caption": "Video caption"
}
}
Audio
- Audio file extensions supported: .mp3
- Does not support the caption field.
- Downloadable link or freely accessible content.
- For unsupported links use "Rich Link" output type above.
{
"type": "audio",
"audio": {
"link": "https://audioURL"
}
}
Document
Note that the linked document gets downloaded when clicked.
{
"type": "document",
"document": {
"link": "http://documentURL",
"filename": "Name of the file"
}
}
Location
- Latitude of the location in number (Min: -90 and Max: 90).
- Longitude of the location in number (Min: -180 and Max: 180).
{
"type": "location",
"location": {
"latitude": 51.214005624409445,
"longitude": 6.748941454406442,
"name": "Cognigy GmbH",
"address": "Speditionstraße 1, Düsseldorf, North Rhine-Westphalia 40221"
}
}
Contact
- "contacts" array can contain multiple contact objects.
- "formatted_name" field is required.
- "birthday", if given, must be
YYYY-MM-DDdate format.
{
"type": "contacts",
"contacts": [
{
"addresses": [
{
"street": "Speditionstraße 1",
"city": "Düsseldorf",
"state": "North Rhine-Westphalia",
"zip": "40221",
"country": "Germany",
"country_code": "de",
"type": "HOME"
},
{
"street": " Speditionstraße 1",
"city": "Düsseldorf",
"state": "North Rhine-Westphalia",
"zip": "40221",
"country": "Germany",
"country_code": "de",
"type": "WORK"
}
],
"birthday": "2017-12-10",
"emails": [
{
"email": "test@cognigy.com",
"type": "WORK"
},
{
"email": "test@whatsapp.com",
"type": "HOME"
}
],
"name": {
"formatted_name": "John Doe",
"first_name": "John",
"last_name": "Dow",
"middle_name": "D.",
"suffix": "Jr",
"prefix": "Dr"
},
"org": {
"company": "Cognigy",
"department": "Conversational AI",
"title": "Manager"
},
"phones": [
{
"phone": "+49 (940) 555-1234",
"type": "HOME"
},
{
"phone": "+49 (650) 555-1234",
"type": "WORK",
"wa_id": "16505551234"
}
],
"urls": [
{
"url": "https://www.cognigy.com",
"type": "WORK"
},
{
"url": "https://www.whatsapp.com",
"type": "HOME"
}
]
}
]
}
List
"sections" field is required for List Messages. An array of
sectionobjects can be min. of 1 and max. of 10."sections.title" value is limited to 24 characters.
"rows" field is required for List Messages. An array of
rowsobjects can be min. of 1 and max. of 10."id" in a row object value is limited to 24 characters.
"title" in a row object value is limited to 200 characters.
"description" in a row object value is limited to 72 characters.
Body text is limited to 1024 characters.
"button" value is limited to 20 characters.
Row object "id" and "title" both must not be empty and unique.
The header can only be of type "text" and text is limited to 60 characters.
Footer "text" value is limited to 60 characters.
{
"type": "interactive",
"interactive": {
"type": "list",
"header": {
"type": "text",
"text": "This is the name of the list"
},
"footer": {
"text": "Subtext of the list"
},
"body": {
"text": "This is text*"
},
"action": {
"button": "Send",
"sections": [
{
"title": "<List Category Item>",
"rows": [
{
"id": "<Item ID>1",
"title": "<Item Title>",
"description": "<Item Description>"
},
{
"id": "<Item ID>2",
"title": "<Item Title>",
"description": "<Item Description>"
},
{
"id": "<Item ID>3",
"title": "<Item Title>",
"description": "<Item Description>"
}
]
}
]
}
}
}