Suggested replies in slack json payload

Viewed 325

I have been working on s chat bot using dialog flow to work with different voice assistants, and messaging services. I am working on the slack integration and am wondering if anyone has any hints to adding 'suggested reply buttons' - This would be similar to the suggestion chips on google assistant.

I have looked through the API docs for slack, and have tried adding buttons without urls, but from what I Can see these can only link to external urls, or postback to a service. The latter seems very overkill for something that is standard in other messaging platforms.

Issue

Add buttons to a slack message which when clicked will then post that message from the user who clicks it. EG clicking 'More Info' would be the same as them typing and sending the message 'More Info'

Tried Solution

I have tried adding text as the url in a button, or not sending a url and sending the value. If I have a value, and name to a button it displays, but as no callback is set then it crashes.

Example Payload

"slack": {
  "attachments": [
    {
      "fallback": "Here is my answer",
      "pretext": "Here is my answer",
      "title": "Hello There",
      "title_link": "http:\/\/www.google.com",
      "text": "Test Custom Card",
      "actions": [
        {
          "type": "button",
          "text": "Boo",
          "url": "http:\/\/www.google.com"
        },
        {
          //Does not show as not valid url
          "type": "button",
          "text": "Ask this next",
          "url": "Ask this next",
          "value": "Ask this next"
        },
        {
          //Does show but stops responding when clicked as no callback in attachment
          "type": "button",
          "text": "Or ask this",
          "name": "Or ask this",
          "value": "Or ask this"
        }
      ],
      "color": "#F35A00"
    }
  ]
}

Potential Solution

  • I was hoping there would be a url prefix/protocal I could add which would then post/send the message rather than opening an external url : Cannot find docs on this if anyone knows of anyway this is possible.
  • I was hoping there was a markup I could use in the actual message it self, for example add some line breaks, with the options in bold, and when clicked it would send the message : Cannot find reference to this existing in the slack markup if anyone knows if it is possible
1 Answers

Sorry, but none of the proposed "solution" are compatible with how message buttons are working on Slack.

You can of course create an app with the functionality you described. But to enable any functionality - like sending a message after the user clicks a button - you need an app that can receive and react to HTTP POST requests from Slack, which are created after a button is pressed (as specified in the official documentation).

This is the only way.

Related