Chatlayer.ai supports different types of chat messages, each with his own object structure. Chat messages can be sent
As a 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
A text message includes an array of text messages.
const textMessage = {config: {textMessages: [{ text: '1st random text' }, { text: '2nd random text' }],},type: 'text',};
Property | type | Description |
textMessages | Array | A list of text message objects |
Property | type | Description |
text | String | A text message |
A button template includes an array of buttons and an array of text messages. A button can have three types
postback: redirects the user to a new dialog state. It is possible to save key values in the user session.
web_url: opens the website for this url.
phone_number: starts a telephone call.
{config: {buttons: [{payload: {nextDialogstateId: 'eedeb3df-ebb1-46c0-836f-b85b784c42b1',params: [{ key: 'location', value: 'meulebeke' }],},title: 'gottotest',type: 'postback',},{title: 'URL button',type: 'web_url',url: 'https://www.google.com',},{payload: '193248u9',title: 'tel',type: 'phone_number',},],textMessages: [{ text: '1st random text' }, { text: '2nd random text' }],},type: 'buttons',}
Property | type | Description |
textMessages | Array | A list of text message objects |
buttons | Array | A list of button objects |
Property | type | Description |
text | String | A text message |
Property | type | Description |
title | String | Title |
type | String | Button type: postback / web_url / call |
payload (only for type postback and phone_number) | String for type phone_number Object for type | The button payload. An object with next dialog state and parameter key/value combinations for type postback. A telephone number for type phone_number. |
url (only for type web_url) | String | The website url to open |
call (only for type phone_number) | String | The phone number to call |
Property | type | Description |
nextDialogstateId | String | Redirect the user to this dialog state |
params | Array | A list of parameter objects. A parameter object has a key and value property |
A quick replies template includes an list of quick replies and a list of text messages.
const QR = {type: 'quickReplies',config: {textMessages: [{ text: '1st random text' }, {text: '2nd random text' }],quickReplies: [{imageUrl: 'https://www.faviconurl.jpg',payload: { nextDialogstateId: '1f51bo05-0510-11e03-0030-1f0d0040sd' },title: 'go to button',type: 'postback',},],},};
Property | type | Description |
textMessages | Array | A list of text message objects |
quickReplies | Array | A list of quick reply objects |
Property | type | Description |
text | String | A text message |
Property | type | Description |
title | String | Title |
type | String | Quick reply type: postback / location |
payload | Object | The payload object with a next dialog state |
imageUrl | String | The quick reply icon url |
Property | type | Description |
nextDialogstateId | String | Redirect the user to this dialog state |
params | Array | A list of parameter objects. A parameter object has a key and value property |
A carousel includes a list of carousel elements.
const carousel = {config: {elements: [{imageUrl: 'https://www.chatlayer.ai/image.jpg',subTitle: 'subtitle',title: 'title',webUrl: 'https://www.chatlayer.ai',buttons: [{type: 'web_url',title: 'url button test',url: 'https://www.chatlayer.ai',},],},],},type: 'carousel',};
Property | type | Description |
elements | Array | A list of carousel elements |
Property | type | Description |
title | String | Title |
subTitle | String | Subtitle |
webUrl | String | The url to redirect the user to when a carousel element is tapped |
imageUrl | String | The url of the carousel element image |
buttons | Array | A list of buttons |
Property | type | Description |
title | String | Title |
type | String | Button type: postback / web_url / call |
payload (only for type postback and phone_number) | String for type phone_number Object for type | The button payload. An object with next dialog state and parameter key/value combinations for type postback. A telephone number for type phone_number. |
url (only for type web_url) | String | The website url to open |
call (only for type phone_number) | String | The phone number to call |
Property | type | Description |
nextDialogstateId | String | Redirect the user to this dialog state |
params | Array | A list of parameter objects. A parameter object has a key and value property |
Media supports three types:
image
video
audio
const media = {config: {media: {type: 'image', //or video, attachment, audiourl: 'https://www.chatlayer.ai/image.jpg',},},type: 'media',};
Property | type | Description |
media | Media object | A media object |
Property | type | Description |
isCache | Boolean | A flag to indicate if the media should be cached for performance optimization. |
type | String | The media type: video / audio / image |
url | String | The media url |