I need to display the list of items in button format on Mattermost. For this Javascript message is for mattermost channel is configured as:
var message = {};
var attachments = [];
var attachment = {
“pretext”: “Please select time slot”,
“text”: “Time slots available are:”,
“actions”: [
{
“name”: “9:00 AM - 11:00 AM”,
“type” : “message”,
“integration”: {
“context”: {
“action”: “Regular Message”
}
}
},
{
“name”: “11:00 AM - 1:00 PM”,
“type” : “message”,
“integration”: {
“context”: {
“action”: “Regular Message”
}
}
}
]
}
attachments.push(attachment);
message.attachements = attachments;
print(JSON.stringify(message));
The http request received is
{
“channel”: “kore”,
“text”: {
“attachements”: [
{
“pretext”: “Please select time slot”,
“text”: “Time slots available are:”,
“actions”: [
{
“name”: “9:00 AM - 11:00 AM”,
“type”: “message”,
“integration”: {
“context”: {
“action”: “Regular Message”
}
}
},
{
“name”: “11:00 AM - 1:00 PM”,
“type”: “message”,
“integration”: {
“context”: {
“action”: “Regular Message”
}
}
}
]
}
]
}
}
It generates 400 bad request as Mattermost is not able to parse the string in “text”.
If the response expected is not part of “text” key it is working (checked by passing the same json via postman).
Is there any way that it is possible to get the response in expected way or in some way display buttons on mattermost ?