An app’s message can carry a card: headings, fields, text, images, tables, charts, and controls people use without leaving the channel. Cards are written in a subset of Slack’s Block Kit, exactly as for Slack’s chat.postMessage. A card that works here works the same in Slack.
When someone clicks, Sabha checks who they are and tells only the app that posted the card. The app registers no URL for clicks. They arrive like any other event, so an app on the WebSocket can run an approval flow from behind a home router.
Post a card
Send blocks with body or text:
curl -X POST "$API/channels/$CHANNEL/messages" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" -d '{
"text": "Deploy v2.3 to production?",
"blocks": [
{ "type": "section", "text": { "type": "mrkdwn", "text": "Deploy *v2.3* to production?" } },
{ "type": "actions", "block_id": "deploy", "elements": [
{ "type": "button", "action_id": "run", "text": { "type": "plain_text", "text": "Run it" }, "value": "v2.3", "style": "primary",
"confirm": { "title": { "type": "plain_text", "text": "Deploy?" }, "text": { "type": "mrkdwn", "text": "This ships *v2.3*." },
"confirm": { "type": "plain_text", "text": "Deploy" }, "deny": { "type": "plain_text", "text": "Not now" } } },
{ "type": "button", "text": { "type": "plain_text", "text": "View PR" }, "url": "https://github.com/acme/app/pull/42" } ] }
]
}'When a card has blocks, Sabha reads the card’s own words for search, previews and notifications, and text isn’t shown.
Blocks
| Block | Holds |
|---|---|
section |
text, up to 10 fields, or both, and optionally one accessory: an image or any control actions takes, except a date and time picker (as in Slack) |
header |
Plain text, up to 150 characters |
context |
Up to 10 small texts and images |
image |
image_url, alt_text, and an optional title |
rich_text |
Slack’s rich text: sections, lists, quotes and code, with styles, links and emoji |
markdown |
Standard Markdown, up to 12,000 characters across the message |
divider |
A line |
table |
Up to 100 rows of up to 20 cells, each raw_text, raw_number or rich_text. The first row is the header; a column of numbers lines up right. Optional column_settings per column: align and is_wrapped. A wide table scrolls inside the card. |
data_visualization |
A title and a chart: bar, line or area with 1 to 12 series over axis_config.categories, or pie with 1 to 12 segments. Each value is a number within 10^15 of zero, and each shows on hover. Up to 2 charts a message. |
input |
A label, dispatch_action: true, an element and an optional hint. A plain_text_input sends its text on Enter (or Ctrl or ⌘ with Enter when multiline); any other control under a label sends as it does in a row. |
actions |
Up to 25 of the controls below |
task_card |
One step of an agent’s work: task_id, title, status (pending, in_progress, complete or error), and optionally details and output (one rich_text each: what it did and what it found), up to 50 sources ({ "type": "url", "url", "text" }) and hide_title. Each status has its own mark. |
plan |
A title over up to 50 task cards in tasks, each with its own task_id. It stays open while any step is pending or in progress, and folds to its title once every step is done or failed. |
context_actions |
A quiet row of up to 5 feedback_buttons and icon_buttons, under an answer |
Nothing in a card notifies anyone. A Sabha user id, in a user element or a mrkdwn <@id>, shows the person’s name if they can read the channel, and a Sabha channel id shows its name if it’s an open channel or forum, or the card’s own. So a card can show back what its pickers sent. Anything else, Slack’s ids included, shows as a muted “@someone” or “#channel”.
Controls
| Control | Shape | Sends the app |
|---|---|---|
| Button | text, action_id, value, and optionally style (primary or danger) and confirm |
Its value |
| Link button | A button with a url instead of a value |
Nothing: it opens the link. An in-app path such as /channels/3 opens in place. |
static_select |
1 to 100 options of { text, value, description }, and optionally placeholder, initial_option, confirm |
The chosen option, as soon as it’s chosen |
overflow |
A “⋯” menu of 2 to 5 options. An option with a url opens it instead. |
The chosen option |
datepicker |
Optionally initial_date (YYYY-MM-DD), placeholder, confirm |
selected_date, as soon as it’s picked |
timepicker |
Optionally initial_time (HH:mm), timezone, placeholder, confirm |
selected_time, as soon as it’s picked |
datetimepicker |
Optionally initial_date_time (Unix seconds), confirm. Each reader sees it in their own time zone. |
selected_date_time, in Unix seconds |
radio_buttons |
1 to 10 options, and optionally initial_option, confirm |
selected_option, as soon as one is picked |
checkboxes |
1 to 10 options, and optionally initial_options, confirm |
selected_options: every box ticked after the change |
users_select |
Optionally initial_user (a Sabha user id), placeholder, confirm. Searches the people who can read the channel. |
selected_user, a Sabha user id |
channels_select |
Optionally initial_channel (a Sabha channel id), placeholder, confirm. Searches the open channels and forums. |
selected_channel, a Sabha channel id |
conversations_select |
Optionally initial_conversation, default_to_current_conversation, filter (include of public, private, im, mpim; exclude_bot_users), placeholder, confirm. Searches the open channels and forums, and the closed channels and DMs the person is in. |
selected_conversation, a Sabha channel id |
feedback_buttons |
In context_actions: a positive_button and a negative_button, each with text, a value (the two different) and an optional accessibility_label |
The value of the one pressed |
icon_button |
In context_actions: icon (trash), text (shown on hover), and optionally value, confirm, accessibility_label and visible_to_user_ids (one or more Sabha user ids: only they see it, and a click from anyone else is refused) |
Its value |
multi_static_select, multi_users_select, multi_channels_select, multi_conversations_select |
As the single kinds, with a list to start on (initial_options, initial_users and so on) and an optional max_selected_items. Picks show as chips. |
The whole set after each change, as selected_options, selected_users, selected_channels or selected_conversations |
Every control sends as soon as something is picked; there’s no submit button. A confirm asks the person to say yes in the card itself before the click is sent.
Everyone in the channel sees the same card, so a picker names a conversation it starts on only when everyone may see it: an open channel or forum, or the card’s own conversation. Any other shows as “A private channel” or “A direct message”.
Images
An image needs alt_text: it’s what a screen reader says and what shows if the image can’t be loaded. Sabha fetches each image once when the message is saved and serves its own copy, so people never load it from your server. JPEG, PNG, GIF or WebP, up to 5 MB and 10 per message.
What’s refused
Sabha follows Slack’s limits (50 blocks, a unique block_id in the message, a unique action_id in its block) and keeps the card under 50,000 characters of JSON. A missing block_id or action_id is filled in for you; set your own if your code looks controls up by id.
Anything Sabha doesn’t support is refused rather than dropped: an input without dispatch_action or holding an email, URL or number field (Slack keeps those to modals), option groups, menus that load their options from your server (external_select), an alert (Slack keeps it to modals), a date and time picker beside a section’s text, an unknown key, a link that isn’t https, or text over its limit. The answer is 422 validation_failed, naming the path to what’s wrong.
In forum posts, cards can only have links: a post is read long after a click would make sense.
What people see
Everyone in the channel sees the same card. When someone clicks:
- The control spins, the others in its row dim, and a line reads “Waiting for your app…”.
- The wait ends when the app edits the message or posts in the channel.
- After about 15 seconds with neither, the controls come back with “No reply from your app yet. You can try again.”
A click isn’t shown to anyone else. What the channel sees is whatever the app writes back, so answer quickly, and show the result by editing the card.
A context_actions row is quieter: its buttons don’t wait for an answer, and the feedback someone picked stays pressed for them while their page is open. Sabha doesn’t keep that pick, so record it when the click arrives.
If the app is removed, leaves the channel, or has neither a webhook nor a key that can connect, its controls show as disabled with the reason.
The click event
Sabha sends the app a block_actions event:
{
"id": "a1b2c3d4-…",
"event": "block_actions",
"user": { "id": 1, "name": "Alice", "role": "member" },
"channel": { "id": 5, "name": "General" },
"message": { "id": 10, "url": "https://chat.example.com/channels/5@10" },
"actions": [ { "action_id": "run", "block_id": "deploy", "type": "button", "value": "v2.3" } ],
"response_url": "https://chat.example.com/api/v1/interaction_responses?token=…"
}It’s Slack’s block_actions, with message.id where Slack has message.ts. actions holds the one control used, with Slack’s field for what was picked in place of value: selected_option from a menu, overflow or radio button, selected_options from checkboxes or a multi-select, selected_date, selected_time or selected_date_time from a picker, selected_user, selected_channel or selected_conversation (or their plurals) from a picker of people, channels or conversations, value from a text field, and the value of the button pressed from feedback buttons. People, channels and conversations are Sabha ids.
Sabha reads a button’s value from the saved message, not from the browser. It checks that a choice was one of the card’s options, that a person, channel or conversation is one the clicker may pick, and that a multi-select holds no more than max_selected_items. What the card starts on goes back with any change, even from someone who couldn’t pick it themselves. That’s all it checks. Treat value as untrusted: sign anything that authorises something sensitive, and enforce single use or expiry in the app.
Each person can click 30 times a minute.
Answer with response_url
response_url answers this one click. It needs no key, lasts 30 minutes and works 5 times. Post a JSON envelope to it, with body or text, and blocks:
| Envelope | Does |
|---|---|
{ "text": "Only you see this" } |
A private reply to the person who clicked |
{ "response_type": "in_channel", "text": "Deploying v2.3…" } |
Posts a new message in the channel |
{ "replace_original": true, "blocks": [ … ] } |
Replaces the card. Anything the envelope leaves out is cleared. |
{ "delete_original": true } |
Deletes the card |
An expired, used-up or altered token is 404.
Update a card later
The ordinary edit takes the same fields:
curl -X PATCH "$API/messages/10" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{ "blocks": [ { "type": "context", "elements": [ { "type": "mrkdwn", "text": "Deployed by Alice" } ] } ] }'Fields you leave out keep their value. "blocks": [] removes the card.
Show an agent’s work
An agent can show its steps as a plan while it works, then edit the message to the answer, with the finished plan above it and a feedback row below:
[
{ "type": "plan", "title": "Worked for 12s", "tasks": [
{ "task_id": "search", "title": "Searched #incidents", "status": "complete",
"sources": [ { "type": "url", "url": "https://wiki.example.com/runbook", "text": "Deploy runbook" } ] },
{ "task_id": "diff", "title": "Read the diff", "status": "complete" } ] },
{ "type": "section", "text": { "type": "mrkdwn", "text": "The deploy failed because the *migrations* timed out." } },
{ "type": "context_actions", "elements": [
{ "type": "feedback_buttons", "action_id": "feedback",
"positive_button": { "text": { "type": "plain_text", "text": "👍" }, "value": "good", "accessibility_label": "Good answer" },
"negative_button": { "text": { "type": "plain_text", "text": "👎" }, "value": "bad", "accessibility_label": "Bad answer" } } ] }
]Make the plan’s title the outcome once it’s done, as here: it folds to that title with its step count, since the answer below is what people came for.
An approval flow
- Post a card with Approve (
primary, with aconfirm) and Reject (danger). - On a
block_actionsevent whoseaction_idisapprove, do the work. - Post
{ "replace_original": true, "blocks": [ … "Deployed by Alice at 12:04" … ] }to theresponse_url, so the whole channel sees who approved and the buttons go away. - If the work takes a while, first post
{ "response_type": "in_channel", "text": "Deploying…" }to the sameresponse_url, then edit the card when it’s done.