Message types
Chatlayer.ai supports different types of chat messages, each with its own object structure. Chat messages can be sent:
  • In the response from the API plugin
  • From your webhook to Chatlayer.ai
Each message has two mandatory fields:
  • type: the messages type (carousel, buttons, list, media, text, …)
  • config: the message configuration

Text

A text message includes a simple bot text message.
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"text": "Hi, I'm a chatbot"
5
},
6
"messageCounter": 1,
7
"verifyToken": "8wMsLZkdDPT64nqh"
8
}
Copied!
Property
Value
Description
text
string
The user test message.

Button Template

A button template includes a simple bot text message and an array of button objects.
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"attachment": {
5
"type": "template",
6
"payload": {
7
"template_type": "button",
8
"text": "Hello, in which language can I help you?",
9
"buttons": [
10
{
11
"type": "postback",
12
"title": "Nederlands",
13
"payload": "437a034cde170b50de1b6a87d1cba104e39b1f6e"
14
},
15
{
16
"type": "postback",
17
"title": "English",
18
"payload": "a6a318dd6afe997f282b3c7472e038a2e0f4046a"
19
},
20
]
21
}
22
}
23
},
24
"messageCounter": 1,
25
"verifyToken": "8wMsLZkdDPT64nqh"
26
}
Copied!
Message object for button template:
Property
Value
Description
attachment
object
The attachment object.
Attachment object:
Property
Value
Description
type
string
The attachment type (template)
payload
object
The attachment payload object. The object structure depends of the attachment type
Attachment payload object:
Property
Value
Description
template_type
string
The template type (button)
text
string (optional)
The text above the buttons ( only for a button template type)
buttons
array
An array of button objects
Button object:
Property
Value
Description
type
string
The button type (web_url - postback - phone_number - element_share)
title
string
The button caption
payload
string (will contain the phone number when type is phone_number) - optional
The button payload. Only for postback type buttons. This is an Opaque identifier please don't try to change or extract meaning out of it.
url
string - optional
The button url. Only for url type buttons

Quick replies

A quick reply message includes a simple bot text message and an array of quick reply objects.
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"text": "Hello, in which language can I help you?",
5
"quick_replies": [
6
{
7
"content_type": "text",
8
"title": "Nederlands",
9
"payload": "c3e30be2f30687fea0ae419acaeb9d77261631a9",
10
"image_url": "https://domain/logo.png"
11
},
12
{
13
"content_type": "text",
14
"title": "English",
15
"payload": "2e29412e82c8eea8c8b0c170661070d28929a900",
16
"image_url": "https://domain/logo.png"
17
},
18
]
19
},
20
"messageCounter": 1,
21
"verifyToken": "8wMsLZkdDPT64nqh"
22
}
Copied!
Message object for quick replies:
Property
Value
Description
text
string
The text before the quick replies.
quick_replies
array
An array of quick reply objects
Quick reply object:
Property
Value
Description
content_type
string
The quick reply content type (text)
title
string
The button caption
payload
string
The quick reply payload. This is an Opaque identifier please don't try to change or extract meaning out of it.

Generic template

A generic template (carousel) includes a list of generic template elements. The generic template element is a simple structured message that includes a title, subtitle, image, and up to three buttons
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"attachment": {
5
"type": "template",
6
"payload": {
7
"template_type": "generic",
8
"elements": [
9
{
10
"title": "Language",
11
"subtitle": "Please set your language",
12
"image_url": "https://domain/lang.png",
13
"item_url": "https://domain/lang",
14
"buttons": [
15
{
16
"type": "postback",
17
"title": "Nederlands",
18
"payload": "f0512bd2fcddc53963056dc0d63b52b8caa902ff"
19
},
20
{
21
"type": "postback",
22
"title": "English",
23
"payload": "4562ae76c34a13647fab90425c68a486b8acf356"
24
},
25
]
26
}
27
]
28
}
29
}
30
},
31
"messageCounter": 1,
32
"verifyToken": "8wMsLZkdDPT64nqh"
33
}
Copied!
Message object for generic template:
Property
Value
Description
attachment
object
The attachment object.
Attachment object:
Property
Value
Description
type
string
The attachment type (template)
payload
object
The attachment payload object. The object structure depends of the attachment type
Attachment payload object:
Property
Value
Description
template_type
string
The template type (generic)
elements
array
An array of generic template elements (carousel cards)
Generic template element object:
Property
Value
Description
title
string
The carousel card title
subtitle
string
The carousel card subtitle
image_url
string
The carousel card image
item_url
string
The carousel card url. When the user clicks the image the web page opens in a new browser tab.
buttons
array
An array of button objects
Button object:
Property
Value
Description
type
string
The button type (web_url - postback - phone_number - element share)
title
string
The button caption
payload
string (will contain the phone number when type is phone_number) - optional
The button payload. Only for postback type buttons. This is an Opaque identifier please don't try to change or extract meaning out of it.
url
string - optional
The button url. Only for url type buttons

List template

The list template is a list of 2-4 structured items with an optional global button rendered at the bottom. Each item may contain a thumbnail image, title, subtitle, and one button. You may also specify a default_action object that sets a URL that will be opened when the item is tapped.
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"attachment": {
5
"type": "template",
6
"payload": {
7
"template_type": "list",
8
"elements": [
9
{
10
"title": "Language",
11
"subtitle": "Select your language",
12
"image_url": "https://domain/lang.png",
13
"default_action": {
14
"type": "web_url",
15
"url": "default_url"
16
}
17
"buttons": [
18
{
19
"type": "postback",
20
"title": "Nederlands",
21
"payload": "76601d56d0619ef87552bbfbbfcd714c4fda513b"
22
}
23
]
24
}
25
],
26
"buttons": []
27
}
28
}
29
},
30
"messageCounter": 1,
31
"verifyToken": "8wMsLZkdDPT64nqh"
32
}
Copied!
Message object for list template:
Property
Value
Description
attachment
object
The attachment object.
Attachment object:
Property
Value
Description
type
string
The attachment type (template)
payload
object
The attachment payload object. The object structure depends of the attachment type
Attachment payload object:
Property
Value
Description
template_type
string
The template type (list)
elements
array
An array of list elements
buttons
array
An array of general list button objects
List template element object:
Property
Value
Description
title
string
The carousel card title
subtitle
string
The carousel card subtitle
image_url
string
The carousel card image
default_action
object
The default action when the user taps the list item.
buttons
array
An array of list item button objects
Default action object:
Property
Value
Description
type
string
The action type (web_url)
url
string
The action ur. When the user taps the list element this web page will open in a new browser tab.
Button object:
Property
Value
Description
type
string
The button type (web_url - postback - phone_numberl - element share)
title
string
The button caption
payload
string (type phone_number) - optional
The button payload. Only for postback type buttons. This is an Opaque identifier please don't try to change or extract meaning out of it.
url
string - optional
The button url. Only for url type buttons

Attachment

An attachment represents a file such as images and video.
Request format:
1
{
2
"senderId": "a7355930-fa92-11e7-8308-2f056e75d1ee",
3
"message": {
4
"attachment": {
5
"type": "image"
6
"payload": {
7
"url": "image_url",
8
}
9
}
10
},
11
"messageCounter": 1,
12
"verifyToken": "8wMsLZkdDPT64nqh"
13
}
Copied!
Message object for attachment:
Property
Value
Description
attachment
object
The attachment object.
Attachment object:
Property
Value
Description
type
string
The attachment type (image-video)
payload
object
The attachment payload object. The object structure depends of the attachment type
Attachment payload object:
Property
Value
Description
url
string
The attachment url