Actions
Actions let you handle button clicks, dropdown selections, and other interactive events from cards. Register handlers with onAction to respond when users interact with your cards.
Handle a specific action
Handle multiple actions
Catch-all handler
Register a handler without an action ID to catch all actions:
ActionEvent
The event object passed to action handlers:
| Property | Type | Description |
|---|---|---|
actionId | string | The id from the Button or Select component |
value | string (optional) | The value from the Button or selected option |
user | Author | The user who clicked |
thread | Thread | null | The thread containing the card (null for view-based actions like home tab buttons) |
messageId | string | The message containing the card |
threadId | string | Thread ID |
adapter | Adapter | The platform adapter |
triggerId | string (optional) | Platform trigger ID (used for opening modals) |
openModal | (modal) => Promise<{ viewId: string } | undefined> | Open a modal dialog. Resolves to undefined if the adapter doesn't support modals |
values | Record<string, string> (optional) | The card's own input values, keyed by input ID |
raw | unknown | Platform-specific event payload |
Pass data with buttons
Use the value prop on buttons to pass extra context to your handler:
Read a text box on the card
On Teams, a card can carry a TextInput. What the user typed arrives on the action as event.values, keyed by input ID, in the same shape as ModalSubmitEvent.values:
recordApproval stands in for your own storage or deploy logic. values is absent on platforms that cannot put an input on a card, and on cards that have none.
Treat event.values as untrusted user input. Teams enforces optional and maxLength in its own UI, but a value can still arrive missing, empty, or longer than the limit, so validate it in the handler. If you post a value back into the thread, the platform renders any markdown the user typed, such as a link, in a message that appears to come from the bot. Wrapping the value in a code span or sending it as { raw } does not prevent this, so store or process the value instead of echoing it.
Open a modal from an action
Use event.openModal() to open a modal in response to a button click:
Only the Slack and Teams adapters support modals. On other platforms, event.openModal()
logs a warning and resolves to undefined without opening anything.
Callback URLs
Buttons accept a callbackUrl prop. When a user clicks the button, the action data is POSTed to that URL in addition to firing any onAction handler. With a webhook-based workflow engine, you can build approval flows without an onAction handler:
Callback tokens are bound to the button action and conversation, expire after seven days, and are consumed on first use. A repeated click or an attempt to move the token to another conversation does not trigger the callback URL again.
Callback payload
The POST body sent to the callbackUrl:
If the button also has a value prop, it is included in the payload as "value".
If the card carried inputs, the payload includes what the user typed as "values", keyed by input ID. This is the same object the handler reads as event.values, and it is omitted when the card has no inputs:
receipt is an opaque identifier for a record of the click that Chat SDK stores in your state adapter for 24 hours, built from the platform's verified event rather than from this body. If Chat SDK can't store the receipt, it doesn't call the callback URL, and the button keeps working so the user can click again. Anyone who knows a callback URL can POST to it, so a request arriving at the URL doesn't prove that someone clicked the button, and a receiver that acts on who clicked shouldn't trust fields like user or actionId from the body. For approvals, use requestApproval, which redeems the receipt and verifies each click for you. Chat SDK doesn't export a way to redeem receipts in your own receivers.
Platform limits apply to encoded button data. Discord's custom_id has a
100-character limit, and posting the card throws a ValidationError if the
action ID plus callback token exceed it. Telegram's callback_data has a
64-byte limit, and buttons that exceed it also throw a ValidationError. Keep
action IDs short when using callbackUrl on these platforms.
For modals, see callbackUrl on modals.
Read more
Modals
Collect structured user input through modal dialogs with text fields, dropdowns, and validation.
Approvals
Pause a durable workflow until a human approves it in chat.
Cards
Send rich interactive cards with buttons, fields, and images across all platforms.
Slash Commands
Handle slash command invocations and respond with messages or modals.