dynamic_cast
dynamic_cast

Reputation: 1105

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 ?

Upvotes: 5

Views: 1439

Answers (2)

B Best
B Best

Reputation: 1166

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.

Upvotes: 1

Brian B
Brian B

Reputation: 35

I think selected_options can only be included in the original interactive message request. This doesn't really make sense to me because since you're generating the options dynamically, you wouldn't necessarily know which ones are coming back beforehand, but at the moment it's the only way I've gotten it to work.

Upvotes: 0

Related Questions