Search code examples
callbackborderblockattachmentslack

Pass callback_id without attachments in Slack


I'm using Slack Api to send message.
So, I have this block message:

{
    "blocks": [
        {
            "type": "divider"
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Do you have access ?"
            }
        },
        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "Yes"
                    },
                    "style": "primary",
                    "value": "click_me_123"
                },
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "Skip"
                    },
                    "style": "danger",
                    "value": "click_me_123"
                }
            ]
        }
    ]
}

As you see, this is block message and it have no any attachments. So, it doesn't send any callback_id when click button Yes or No. But I need send callback_id when click button Yes or No. How can do that?
Or another hack. Anyway to remove border left of attachments?
Thanks.


Solution

  • Am assuming you are looking to have a way to let your code parse the choices when the button is pressed. You need to assign the unique value that you can parse and determine the choice. Something like

        {
            "type": "actions",
            "elements": [
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "Yes"
                    },
                    "style": "primary",
                    "value": "yes"
                },
                {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "emoji": true,
                        "text": "Skip"
                    },
                    "style": "danger",
                    "value": "skip"
                }
            ]
        }