我的松弛自定义命令如何生成/提醒我链接

How can my slack custom command produce /remind me like links

我正在编写一个自定义的松弛命令来实现 任务管理器喜欢界面(我知道......那里有很多 :-),我的界面与 odesk/upwork 外包我的微任务 :-))。

无论如何,我非常喜欢 /remind 命令在其输出中包含 Complete Delete 等链接的方式,以促进与输入命令的用户的后续交互,我正在尝试找出如何做同样的技巧。

到目前为止我的想法是在我的输出中包含链接,这些链接是... GET /slack-link?method=POST&token=xxx&team_id=xx&command=.. 即在他们的查询字符串中携带完整的 json 有效负载,slack 会从正常的自定义命令。 slack-link 充当 "proxy",其唯一作用是将 POST 提交回我的正常松弛端点。我什至可以为这些命令链接重复使用相同的 response_url。

我还没有尝试过,但我认为这些 URL 只会打开另一个 window,因此该路径将无法正常工作...

以前有人试过类似的东西吗?

我从 Slack 支持那里得到了答案:

In regard to your original question: currently Slack doesn't provide the ability to embed 'action' links in our custom integrations. Only built-in features like /remind can utilize these at the moment. For external services, you'll need to link to a URL that opens in an external web browser.

We do hope to provide a similar function for custom integrations in the future, allowing for interactive messages.

Thanks,

Ben

如您所知,这些目前仅适用于内置命令。然而,由于我很好奇并且想知道这些是如何完成的,我查看了 API 并发现 URL 只是正常格式化但有一个特殊的 "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> [...]

单击这样的 link 会导致对方法 chat.action 的 API 请求,其中包含以下参数:

bot: BSLACKBOT
payload: reminders/complete/D01234567/1234//0/0/5678
token: xoxs-tokenhere-nowayiampostingithere

所以看起来那些 URL 分为三个部分:

<slack-action://BSLACKBOT/reminders/complete/[...]|Mark as complete>
  1. slack-action://: "protocol" like 前缀让 Slack 知道这是一个聊天动作 URL.
  2. BSLACKBOT:将接收有效负载的机器人(谁?)。只能是bot用户,ID必须以B开头,否则API请求会失败invalid_bot.
  3. URL 的其余部分:传递给机器人的负载。看起来这并没有被 Slack 专门解析或处理。

这实际上不是新功能,因为他们曾经在 2013 年底或 2014 年初(我记不清了)有 API URLs,但他们删除了 "security reasons".

看看我们是否可以对自定义机器人使用聊天操作,如果可以,我们可以用它做什么。