Open URL in browser from Message Button using Slack API

淺唱寂寞╮ 提交于 2020-07-20 07:04:54

问题


I am sending the users a slack message with a button through a Slack App. On every click of the button, I generate a new URL.

At the moment, I am able to return the URL back as a message. The user clicks on the message to open the URL in the browser.

Instead of the sending a message back, I want to open the URL directly in the browser using slack API.

How can I accomplish it? I can't seem to find anything in the documentation that does that.

Thanks

PS: Google Drive integration does that already.


回答1:


Unfortunately slack does not support opening urls from message buttons. You can monitor what slack is planning on releasing here though: https://trello.com/b/ZnTQyumQ/slack-platform-roadmap-for-developers :)




回答2:


It appears Slack introduced this feature recently.

As documented in https://api.slack.com/docs/message-attachments#link_buttons

  "actions": [
    {
      "type": "button",
      "text": "Book flights 🛫",
      "url": "https://flights.example.com/book/r123456"
    }

It's possible to preview in Slack's interactive message builder




回答3:


According to Slack, message attachments is the "old way" of composing messages, which will be deprecated in favour of the new Block Kit API.

I found this example on how to do button links on their docs, using the actions object in the message payload.

I haven't implemented it yet, but you can send the message to a channel in your workspace straight from the docs and try it, and it does open the link in the browser as expected.



来源:https://stackoverflow.com/questions/40404788/open-url-in-browser-from-message-button-using-slack-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!