Response format
Response format for sending dynamic messages:
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text"
},
{
...Another messages
}
],
"actions": [ //optional
{
"action": "add_tag",
"tag_id": 12345
},
{
"action": "set_custom_field",
"action_id": 17,
"action_value": "abcd"
},
{
...Another actions
}
],
"quick_replies": [ //optional
{
"type": "flow",
"caption": "Go",
"flow_id": 12345
},
{
...Another quick replies
}
]
}
}
Dynamic block API current version v2
Dynamic block has a limit to have not more than 10 messages in messages
block, 11 quick replies and 5 actions. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Messages format
Sending text
Use this response for sending text messages. url
, flow
and call
buttons can be used with text message. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
Sending image
This response is used to send image files. Messenger supports JPG, PNG and GIF images. You can use url
, call
, flow
buttons. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "image",
"url": "https://statics.pancake.vn/user-content.pancake.vn/photo/xyz.png",
"buttons": []
}
],
"actions": [],
"quick_replies": []
}
}
Sending video file
This response is used to send video files. Messenger supports videos, which are up to 25MB
in size. You can use url
, call
, flow
buttons. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "video",
"url": "https://statics.pancake.vn/user-content.pancake.vn/video/xyz.mpg",
"buttons": []
}
],
"actions": [],
"quick_replies": []
}
}
Sending audio file
This response is used to send audio files. Messenger supports audio, which are up to 25MB
in size. You can use url
, call
, flow
buttons. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "audio",
"url": "https://statics.pancake.vn/user-content.pancake.vn/audio/xyz.mp3",
"buttons": []
}
],
"actions": [],
"quick_replies": []
}
}
Sending files
This response is used to send any other files, which are no larger than 25 MB. The "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "file",
"url": "https://statics.pancake.vn/user-content.pancake.vn/file/xyz.pdf"
}
],
"actions": [],
"quick_replies": []
}
}
Sending gallery cards
On WhatsApp, it requires at least 1 button in gallery
This response is used to send a horizontal scrollable gallery. You can use url
, call
, flow
buttons. The "buttons"
, "actions"
, "quick_replies"
properties are optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "cards",
"elements": [
{
"title": "Card title",
"subtitle": "card text",
"image_url": "https://statics.pancake.vn/user-content.pancake.vn/photo/xyz.png",
"buttons": []
}
],
"image_aspect_ratio": "horizontal"
}
],
"actions": [],
"quick_replies": []
}
}
We strongly suggest to use HTTPS protocol for your URLs.
image_aspect_ratio
- The aspect ratio used to render cards. You can use horizontal
or square
(default horizontal
).
Buttons
You can use buttons with each types: call
, url
, flow
. You can provide custom action to be performed with the button.
Actions can only be attached to url
, flow
button types. Actions for buttons must comply with same format and restrictions as described in Actions format bellow. The "actions"
property is optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
},
{
...Another buttons
}
]
},
{
...Another messages
}
],
"actions": [ //optional
{
"action": "add_tag",
"tag_id": 12345
},
{
...Another actions
}
],
"quick_replies": [ //optional
{
"type": "flow",
"caption": "Go",
"flow_id": 12345
},
{
...Another quick replies
}
]
}
}
Call button
Not available on WhatsApp
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "call",
"title": "Call me",
"phone": "+1 (555) 555-55-55"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
Url button
Not available on WhatsApp
There are 3 options of webview_size
:
full
- (100%),
medium
- (75%),
compact
- (50%)
The "webview_size"
property is optional.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io",
"webview_size": "full"
}
]
}
],
"actions": [],
"quick_replies": []
}
}
Go to flow button
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "flow",
"title": "Go",
"flow_id": 12345
}
]
}
],
"actions": [],
"quick_replies": []
}
}
flow_id
needs flow ID (it can be found in URL when flow is opened)
Actions format
actions
property of server response is optional.
Action add tag
Use this response to add a tag to a subscriber. Tag with the same name must exist in your bot:
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [
{
"action": "add_tag",
"tag_id": 12345
}
],
"quick_replies": []
}
}
Tag ID sent using tag_id
parameter should match one of existing tags within Botcake bot
Action add custom field
Use this response to add a custom field to a subscriber.
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [
{
"action": "set_custom_field",
"action_id": 17,
"action_value": "abcd"
}
],
"quick_replies": []
}
}
Action remove tag
Use this response to remove a tag from a subscriber. Tag with the same name must exist in your bot:
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [
{
"action": "remove_tag",
"tag_id": 12345
}
],
"quick_replies": []
}
}
Quick replies
Go to flow quick reply
Only available on Messenger or Instagram
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [],
"quick_replies": [
{
"type": "flow",
"caption": "Go",
"flow_id": 12345
}
]
}
}
flow_id
needs flow ID (it can be found in URL when flow is opened)
Go to phone number quick reply
Only available on Messenger
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [],
"quick_replies": [
{
"type": "user_phone_number"
}
]
}
}
Go to email quick reply
Only available on Messenger
Copy {
"version": "v2",
"content": {
"messages": [
{
"type": "text",
"text": "simple text with button",
"buttons": [
{
"type": "url",
"title": "External link",
"url": "https://botcake.io"
}
]
}
],
"actions": [],
"quick_replies": [
{
"type": "user_email"
}
]
}
}
Variables
In dynamic block request body, you can use Full Subscriber Data
variable, that contains all subscriber’s information:
Copy {
"user_first_name": "Firstname",
"user_last_name": "Lastname",
"user_full_name": "Subscriber",
"#GENDER{{MALE|FEMALE|UNKNOWN}}": "MALE",
"psid": "123456xxxxxx",
"ad_id": "123456xxxxx",
"page_name": "Botcake",
"{{SPIN_1|SPIN_2}}": "SPIN_1",
"email": "abc@gmail.com",
"phone": "+8438409xxxx",
"address": "Ha Noi",
"current_date": "2018-07-02T00:00:00+00:00",
"CONVERSATION_LINK": "https://pages.fm/323087334762615?c_id=323087334762615_xxxxxxxxxx",
}