Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a link button with slack blocks api

Tags:

slack

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?

like image 609
Petran Avatar asked Mar 02 '23 23:03

Petran


1 Answers

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:
Link Button

like image 106
stud3nt Avatar answered Mar 05 '23 12:03

stud3nt