Chat cards
Form with approval
The agent drafts a record and the user checks it, edits it and approves it. Nothing is written until they do. Fields the agent filled in are marked until the user edits them.
When to use it
Section titled “When to use it”Use it when: The agent is about to create or change a record and has drafted most values (from the conversation, the page or an API). The user checks, edits and approves; only then is anything written.
Use something else when: A single yes/no (confirm card). Choosing one of a few options (picker or ask_user_question). More than ~8 fields or dependent sections (wizard, or a FORM canvas on desktop).
What the agent receives
Section titled “What the agent receives”| The template calls | The agent gets | When |
|---|---|---|
submit({ approved, values, result }) | FUNCTION_TOOL_SUBMITTED_BY_USER | After actions.save() succeeds. A save that throws keeps the form open. |
cancel() | FUNCTION_TOOL_CANCELLED_BY_USER | The user pressed Cancel. Nothing was saved. |
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 form loads again in place, after Try again. While execute runs, the SDK shows its own loader. |
| Error | execute couldn’t load what the form needs and returned the failure as data. Try again loads the form 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.
FormApprovalData
Section titled “FormApprovalData”| Field | Type | Notes |
|---|---|---|
title | string | |
subtitle (optional) | string | |
icon (optional) | IconName | |
note (optional) | string | The agent’s one-line note above the fields. |
fields | FormField[] | |
submitLabel (optional) | string | |
busyLabel (optional) | string | |
cancelLabel (optional) | string | |
cancelledText (optional) | string | |
receipt (optional) | { title?: string; subtitle?: string; fields?: string[]; link?: { label: string; href: string } } | What the card shows after a successful save. |
FormField
Section titled “FormField”| Field | Type | Notes |
|---|---|---|
id | string | |
label | string | |
type (optional) | "text" | "email" | "number" | "date" | "select" | "textarea" | |
value (optional) | string | number | |
required (optional) | boolean | |
aiFilled (optional) | boolean | The agent filled this in: dashed border and a “Suggested” mark until the user edits it. |
wide (optional) | boolean | Full row in the two-column layout (textareas always are). |
options (optional) | (string | { value: string; label: string })[] | |
placeholder (optional) | string | |
hint (optional) | string | |
prefix (optional) | string | Shown inside the input, e.g. ”$”. |
rows (optional) | number | |
format (optional) | NumberFormat | How a number shows on the receipt. |
FormActions
Section titled “FormActions”| Field | Type | Notes |
|---|---|---|
save() (optional) | (values: FormValues) => Promise<{ url?: string } | void> | Writes the record. Throw to show the error and keep the form open. Return { url } to link the receipt. |
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
- form-approval: 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.