[NEW] Add support to action buttons
- Your Rocket.Chat app version: 3.2.0 (221)
- Your Rocket.Chat server version: 0.74.3
- Device (or Simulator) you're running with: iPad
As the current state of Rocket.Chat Apps, they're using action buttons to interact with users, when clicking such buttons, a slash command is called.
This is how the app is currently rendering actions buttons:

This is the web version for comparison:

The buttons are on the second attachment.
Below is a compact version of a message object containing the relevant fields for action buttons:
{
"_id": "ryWoB9zYFzWEaPABs",
"rid": "XkhRGsh7SGkDJPkbj",
"msg": "_Is poll app working?_",
"attachments": [
{
"color": "#73a7ce",
"text": ":one: Yes `0`\n:two: No `0`\n:three: Some times `0`"
},
{
"color": "#73a7ce",
"button_alignment": "horizontal",
"actions": [
{
"type": "button",
"text": "1",
"msg_in_chat_window": true,
"msg": "/vote cf4169ea-cab1-46a3-b798-dfddea2db474 0"
},
{
"type": "button",
"text": "2",
"msg_in_chat_window": true,
"msg": "/vote cf4169ea-cab1-46a3-b798-dfddea2db474 1"
},
{
"type": "button",
"text": "3",
"msg_in_chat_window": true,
"msg": "/vote cf4169ea-cab1-46a3-b798-dfddea2db474 2"
}
]
}
]
}
The key points here are the following:
- the
button_alignmentof the attachment should be respected - if
msg_in_chat_windowistrue, thetextproperty should be used as the button value, and themsgproperty will be the slash command executed when tapped.
If you need more information, please just let me know.
There are even more action buttons now. We need to work on documentation.
I use RC API to post a button message but it was not displayed. Please tell me if it's available.