'Response from interactive button POST is ignored in Mattermost

I'm building a slash command. The flow I imagine is:

  1. User triggers slash command in client
  2. My server handles request and returns interactive dropdown
  3. User selects option from dropdown in client
  4. My server handles the POST request from the selection and returns an interactive button
  5. User presses the button

Something seems to go wrong between steps 4 and five. The server handles the selection and returns the desired response:

{ 
  "update": {"message": "Updated!"}, 
  "ephemeral_text": "You updated the post!", 
  "attachments": [{
    "text": "Ready?", "actions": [{
      "name": "Go!", 
      "integration": {
        "url": "https://somewhere.com?foo=bar"
        "context": {"action": "event_submitted"}
      }
    }]
  }]
}

...but nothing shows up in the client.

Is something wrong with that JSON? I have tried other things like only returning a text message.

I wonder, if I have misunderstood the docs and the client will never even evaluate a response from a POST triggered by an interactive message. In that case I would have to make a new request back from my server to the Mattermost API in order to get to the next step in my workflow. Is that correct?



Solution 1:[1]

I misunderstood how Mattermost works in this case. You can't handle a POST from Mattermost and return another interactive button, because Mattermost doesn't evaluate the response body. You have to make a request to the API (or a Webhook) to continue.

Solution 2:[2]

It is possible to update the attachments on a POST from Mattermost. The relevant section in the documentation: How do I manage properties of an interactive message?. The solution is to wrap the new attachment inside update.props like so:

{
    "update": {
        "message": "Updates messsage",
        "props": {
            "attachments": [
                {
                    "text": "Updated attachment text",
                    "actions": [
                        {
                            "name": "Updated action.",
                            "integration": {
                                "url": "...",
                                "context": {
                                    "action": "do something"
                                }
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 EagleBeak
Solution 2 bfontaine