英文:
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"
                }
            ]
        }
    ]
}
英文:
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"
                }
            ]
        }
    ]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。



评论