使用Slack Blocks API创建一个链接按钮。

huangapple go评论60阅读模式
英文:

Create a link button with slack blocks api

问题

我想要一个Slack按钮,它将表现得像一个链接,当用户点击它时,它会将用户发送到我的网站。这在Slack的新API中是否可能?

英文:

I want to have a slack button that will behave as a link, it will send user to my website when it clicked.
Is that possible with slack new api?

答案1

得分: 11

是的,可以通过使用block kit实现。您只需要在actions内部添加一个button并提供url即可。单击它将重定向到https://google.com,并同时发送请求到Slack API。

Block Kit 代码:

{
	"blocks": [
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "点击我"
                        
                    },
                    "style": "primary",
                    "value": "click_me",
                    "url":  "https://google.com"
                }
            ]
        }
    ]
}

输出:
使用Slack Blocks API创建一个链接按钮。

英文:

Yes, it is possible by using block kit.
All you have to do is add a button inside actions and provide the url. On click it will redirect to https://google.com and also sends a request to slack api.

Block Kit Code:

{
	"blocks": [
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "Click me"
                        
                    },
                    "style": "primary",
                    "value": "click_me",
                    "url":  "https://google.com"
                }
            ]
        }
    ]
}

Output:
使用Slack Blocks API创建一个链接按钮。

huangapple
  • 本文由 发表于 2020年1月6日 18:48:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/59610730.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定