node.jsslackslack-apislack-block-kitslack-dialog

How to create message shortcut in slack app?


I am creating slack app using bolt javascript library, I want to create message shortcut and when the user clicks on that shortcut I want to capture the message details. how can I do that using slack's blot library for javascript?

like this enter image description here


Solution

  • This is described in a Slack API docs on shortcuts. You should go to https://api.slack.com/apps, pick your app and open application admin, choose Features -> Interactivity & Shortcuts, enable this feature, then "Create New Shortcut" in Shortcuts section.

    There are basically two options for shortcuts: global and on message, pick message, Callback ID is an action identifier where application should filter your action.

    You should add a shortcut listener in your application, if you are using Slack BoltJS framework, see the Listening and responding to shortcuts, use the "Callback ID" as an identifier for your application shortcut business logic.

    You probably also enable a socket mode for your app or set an interactivity endpoint in a "Request URL" form, see the Sending and responding to actions.