Skip to main content

Approval request with action buttons

Every language builds the same message: a deployment question, Approve/Reject actions carrying release-42, and a Details link. The application authenticates and acknowledges callbacks through HTTP or Socket Mode and implements the approve/reject actions. No request is sent by these examples.

Output

Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.

Approve deployment?
Serialized output
{
"channel": "C1",
"mrkdwn": true,
"blocks": [
{
"type": "section",
"block_id": "<generated-block-id>",
"text": {
"type": "mrkdwn",
"text": "Approve deployment?"
}
},
{
"type": "actions",
"block_id": "<generated-block-id>",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Approve"
},
"action_id": "approve",
"style": "primary",
"value": "release-42"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Reject"
},
"action_id": "reject",
"style": "danger",
"value": "release-42"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Details"
},
"action_id": "details",
"url": "https://approvals.example.com/release-42"
}
]
}
],
"text": "Approval requested"
}

Code​

Shared example contract: The same release-42 approval message in every language: Approve, Reject and Details, with matching actions and fallback text.

from slackblocks import ActionsBlock, Button, Message, SectionBlock

message = Message(channel="C1", text="Approval requested", blocks=[
SectionBlock("Approve deployment?"),
ActionsBlock(elements=[
Button(text="Approve", action_id="approve", value="release-42", style="primary"),
Button(text="Reject", action_id="reject", value="release-42", style="danger"),
Button(text="Details", action_id="details", url="https://approvals.example.com/release-42"),
]),
])
print(message.json())