Action Object — Message
A Message action sends a given text message on the user's behalf.
Basic usage
A Message action makes tapping a button send text to the bot, exactly as if the user had typed it. It supports plain text and can carry a payload.
Structure
JSON
{
"type": "MESSAGE",
"text": "I'd like to book a table",
"payload": {
"action": "reservation"
}
}
Properties
type (required)
The action's type, always "MESSAGE".
text (required)
The text sent when the button is tapped.
payload (optional)
Additional data, carrying structured values through to later processors.
Examples
To send a button with a Message action from Push Message:
- Choose
Expressionin the Template field's dropdown. - Enter the following JavaScript in the editor.
A support menu
(() => {
return {
type: 'BUTTON',
title: 'Support',
text: 'Which service do you need?',
buttons: [
{
label: 'Order status',
action: {
type: 'MESSAGE',
text: 'I want to check my order',
},
},
{
label: 'Book a table',
action: {
type: 'MESSAGE',
text: "I'd like to book a table",
},
},
],
};
})()
Carrying a payload
(() => {
return {
type: 'BUTTON',
title: 'Product questions',
text: 'Which product would you like to know about?',
buttons: [
{
label: 'Specifications',
action: {
type: 'MESSAGE',
text: 'Please give me the full specifications',
payload: {
product_id: 'laptop_001',
inquiry_type: 'specifications',
},
},
},
{
label: 'Pricing',
action: {
type: 'MESSAGE',
text: 'Please give me the pricing',
payload: {
product_id: 'laptop_001',
inquiry_type: 'pricing',
},
},
},
],
};
})()