Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot select options on slack dynamic message menu

Working on a Slack command I want to have some message menus as attachment. Those need to be dynamically populated, so I registered an options load URL and added the following attachments to my message:

[{
  "text": "Request's attributes",
  "fallback": "Upgrade your Slack client to use message like these.",
  "color": "#3AA3E3",
  "attachment_type": "default",
  "callback_id":"some ID",
  "actions": [{
    "name": "priority_list",
    "text": "Select a priority",
    "type": "select",
    "data_source": "external",
  }, {
      "name": "status_list",
      "text": "Select a status",
      "type": "select",
      "data_source": "external",
    }]
  }]

My options load URL is properly called by slack and here is what my server responds:

{
  options: [{
        text: 'Low',
        value: 'low'
    },
    {
        text: 'Medium',
        value: 'medium'
    },
    {
        text: 'High',
        value: 'high'
    }
],
  selected_options: [{
    text: 'High',
    value: 'high'
}]}

Looking in Slack I can see the options are dynamically populated. However, none of them are selected.

I am missing something when describing the selected_options ?

like image 946
dynamic_cast Avatar asked Nov 08 '22 20:11

dynamic_cast


1 Answers

Probably figured it out by now but you need to pass a header in the JSON with Content-Type as application/json in order for it to populate.

like image 186
B Best Avatar answered Nov 15 '22 08:11

B Best