Skip to main content

buttons

To display buttons in a chat, use the buttons reply type.

tip
You can also use the buttons DSL tag or the $reactions.buttons method to create buttons. Such buttons have extended functionality: you can set transitions to other states and also transfer various objects for requesting a user location or phone number.

Properties

The buttons replies accept a buttons property, an array of objects that describe the buttons. Each object contains a text string property, the text of the button.

Syntax

{
"type": "buttons",
"buttons": [
{"text": "Button 1"},
{"text": "Button 2"}
]
}

Usage details

  • When a button is selected, the text of the button will be sent to the chat.
  • If you add multiple buttons, they will be displayed on one line.

Channel restrictions

buttons is not supported in the phone channel.

How to use

state: Question
a: What kind of question do you have?
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "buttons",
"buttons": [
{"text": "About products"},
{"text": "About my order"},
{"text": "Contact support"}
]
});

state: ContactSupport
q: * Contact support *
a: Just a moment, please… I’m transferring you to an agent.
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "switch",
"firstMessage": $jsapi.chatHistory(),
"closeChatPhrases": ["/closeLiveChat", "Close chat"]
});