Chat cards
Confirm
Before a change that costs money, reaches other people or can’t be undone, the user sees what changes, before and after, and confirms it. The destructive tone adds an alert, an error-colored button and an optional word to type.
When to use it
Section titled “When to use it”Use it when: The agent is about to make a change the user should approve first: billing, permissions, bulk updates, deletes, anything sent to other people. The values are settled; the user only says yes or no.
Use something else when: The user still has values to fill in or correct (form with approval). A choice between options (picker). A change that is cheap to undo and was asked for in so many words (do it and show the result).
What the agent receives
Section titled “What the agent receives”| The template calls | The agent gets | When |
|---|---|---|
submit({ confirmed: true, result }) | FUNCTION_TOOL_SUBMITTED_BY_USER | After actions.confirm() succeeds. A confirm that throws keeps the card open with the error. |
cancel() | FUNCTION_TOOL_CANCELLED_BY_USER | The user pressed Cancel. Nothing changed. |
States
Section titled “States”Besides its data, the template draws these as itself, with mountState(). Pick one on the preview with State.
| State | When it shows |
|---|---|
| Loading | While the preview loads again in place, after Try again. While execute runs, the SDK shows its own loader. |
| Error | execute couldn’t preview the change and returned the failure as data. Try again loads the preview in place. Cancel reports cancel(), so the agent stops waiting. |
mountState({ root, head, title: "…", state: { kind: "error", text: "…", retry } });The hosted action and the in-page handler below show each case. The state types are LoadingState, EmptyState and ErrorState in fs-kit.
ConfirmData
Section titled “ConfirmData”| Field | Type | Notes |
|---|---|---|
title | string | |
subtitle (optional) | string | |
icon (optional) | IconName | |
summary | string | One sentence: what happens when the user confirms. |
changes (optional) | ConfirmChange[] | Before and after rows. A row without to shows as removed, one without from as new. |
impact (optional) | string | One line on how far the change reaches, e.g. “Affects 42 contacts”. |
impactIcon (optional) | IconName | |
tone (optional) | "default" | "destructive" | ”destructive”: alert note, error-colored confirm button with a trash icon, optional type-to-confirm. |
warning (optional) | string | Destructive: the alert note. Default “This can’t be undone.” |
confirmWord (optional) | string | Destructive: the user types this word before the confirm button unlocks. |
confirmLabel (optional) | string | Name the action, e.g. “Delete 3 automations”, not “OK”. |
busyLabel (optional) | string | |
cancelLabel (optional) | string | |
removedLabel (optional) | string | Tag on a removed row. Default “Removed”. |
done (optional) | ConfirmDone | What the card shows after the change went through. |
cancelledText (optional) | string |
ConfirmChange
Section titled “ConfirmChange”| Field | Type | Notes |
|---|---|---|
field | string | What changes, e.g. “Seats”. For an added or removed item: the item’s name. |
from (optional) | string | number | The value now. Omit it for something new. |
to (optional) | string | number | The value after. Omit it for something removed. |
format (optional) | NumberFormat | How a number shows. |
ConfirmDone
Section titled “ConfirmDone”| Field | Type | Notes |
|---|---|---|
title (optional) | string | |
text (optional) | string | |
link (optional) | { label: string; href: string } |
ConfirmActions
Section titled “ConfirmActions”| Field | Type | Notes |
|---|---|---|
confirm() (optional) | () => Promise<{ url?: string } | void> | Makes the change. Throw to show the error and keep the card open. Return { url } to link the done state. |
Install
Section titled “Install”Copy the template and the shared kit into your code: agent/ui/ in an agent repo, or anywhere in your app. The template imports only ./fs-kit.js. Then wire it up from the hosted action or the in-page handler.
- Hosted action: TypeScript, JavaScript
- In-page handler: TypeScript, JavaScript
- confirm: TypeScript, JavaScript
- fs-kit: TypeScript, JavaScript
The hosted action needs an agent repo with one folder per action (agent/actions/<action_key>/index.ts). If your repo keeps its actions in agent/actions/index.ts, use the in-page handler: it runs the same template in your app.
All templates in machine-readable form: /ui-catalog/catalog.json.