As you know, they are currently only available for built-in commands. However, since I was curious and wanted to know how to do this, I looked at the API and found out that the URLs were just formatted normally, but had a special “protocol”:
You asked me to remind you to "test". _<slack-action://BSLACKBOT/reminders/complete/D01234567/1234//0/0/5678|Mark as complete> or remind me later: <slack-action://BSLACKBOT/reminders/snooze/D01234567/1234//0/0/5678/15|15 mins> [...]
Clicking on such a link leads to an API request to the chat.action method with the following parameters:
bot: BSLACKBOT payload: reminders/complete/D01234567/1234//0/0/5678 token: xoxs-tokenhere-nowayiampostingithere
So it looks like these URLs have three parts:
<slack-action://BSLACKBOT/reminders/complete/[...]|Mark as complete>
slack-action:// : "protocol" as a prefix so that Slack knows that this is the URL of the chat action.BSLACKBOT : a bot that (who?) BSLACKBOT get the payload. It can only be a bot user, and the identifier must start with B, or the API request will fail with invalid_bot .- rest of URL: payload passed to bot. It seems that this is not parsed or processed specifically by Slack.
This is actually not a new feature, as they used the API URLs back in late 2013 or early 2014 (I don’t remember exactly), which they removed for security reasons.
It would be interesting to see if we can use chat actions with custom bots, and if so, what can we do about it.
source share