How can my weak user team create / remind me of links

I am writing a custom slack command that implements a task manager such as an interface (I know ... there are many :-), my interfaces are with odesk / upwork to outsource my micro tasks :-)).

In any case, I really like how the / remind command included Complete Delete, etc. in its output. links to facilitate subsequent interactions with the user who entered the command, and I'm trying to figure out how to do the same trick.

What I was thinking so far is to include links in my output that are ... GET /slack-link?method=POST&token=xxx&team_id=xx&command=.. i.e. carry in their query string the full json payload that slack will produce from a regular user command. slack-link acts like a "proxy" whose only role is to send the POST back to my normal endpoint. I can even reuse the same response_url for these link commands.

I have not tried, but I think that these URLs will simply open another window, so the path will not work exactly ...

Has anyone tried something like this before?

+5
source share
2 answers

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.

+4
source

I got a response from Slack support:

As for your initial question: Slack currently does not provide the ability to embed action links in our user integration. Only built-in functions like / remind can use them at this time. For external services, you will need to set a link to the URL that opens in an external web browser.

We hope to provide a similar feature for custom integrations into the future that allows the use of interactive messaging.

Thanks,

Ben

+3
source

Source: https://habr.com/ru/post/1237015/


All Articles