Chat cards
Comparison
Two to four plans, quotes or versions side by side. Rows that match collapse to one quiet line, the best value in a row gets a star, and the agent’s pick is highlighted with its reason. Read-only by default; with selectable, each column gets a Choose button and the agent waits for the choice.
When to use it
Section titled “When to use it”Use it when: The user weighs 2–4 concrete options on the same attributes: plans, vendor quotes, versions, offers. The answer is in how they differ, row by row. Read-only by default; set selectable when the next step is choosing one, and the card waits for that choice.
Use something else when: One option (entity card). Five or more, or options that share few attributes (records list or table). A choice where a line per option is enough to decide (picker). Numbers over time (chart).
What the agent receives
Section titled “What the agent receives”| The template calls | The agent gets | When |
|---|---|---|
displayed() | FUNCTION_TOOL_DISPLAYED | Read-only (no selectable): as soon as the card shows. The agent goes on. |
submit({ chosen, label, result }) | FUNCTION_TOOL_SUBMITTED_BY_USER | selectable: the user chose an item, after actions.choose() succeeds. chosen is the item id. |
cancel() | FUNCTION_TOOL_CANCELLED_BY_USER | selectable: the user pressed the way out (default None of these). 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 card loads again in place, for example after Try again. While execute runs, the SDK shows its own loader. |
| Empty | execute found fewer than two items. There’s nothing to set side by side, so the card says so. |
| Error | execute returned the failure as data, so the agent can explain it. Try again loads in place. |
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.
ComparisonData
Section titled “ComparisonData”| Field | Type | Notes |
|---|---|---|
title | string | |
subtitle (optional) | string | |
icon (optional) | IconName | |
items | ComparisonItem[] | 2–4 items, one column each, in this order. More are cut. |
rows | ComparisonRow[] | The attributes, top to bottom. Rows that match across every item draw as one quiet line. |
recommended (optional) | { id: string; reason: string } | The item the agent recommends, and why in one sentence. Its column is highlighted and badged. |
recommendedLabel (optional) | string | Badge on the recommended column. Default “Recommended”. |
onlyDifferences (optional) | boolean | Start with matching rows hidden. The user can switch them back on. |
selectable (optional) | boolean | A Choose button under each item. The card becomes an input and the agent waits for the choice. Default: read-only. |
chooseLabel (optional) | string | Default “Choose”. |
busyLabel (optional) | string | |
cancelLabel (optional) | string | Selectable: the way out. Default “None of these”. |
receiptLabel (optional) | string | Receipt lead-in before the chosen name. Default “You chose”. |
cancelledText (optional) | string | |
footnote (optional) | string | |
link (optional) | { label: string; href: string } |
ComparisonItem
Section titled “ComparisonItem”| Field | Type | Notes |
|---|---|---|
id | string | Key into every row’s values. |
name | string | Column heading: the plan, vendor, version or offer. |
price (optional) | string | Headline figure under the name, e.g. “$29”. |
priceSub (optional) | string | Small line under the price, e.g. “per seat / mo”. |
description (optional) | string | One short line under the price. Keep it to a few words: columns are narrow in chat. |
disabledReason (optional) | string | With selectable: shown instead of its Choose button, e.g. “Not for 18 seats”. |
ComparisonRow
Section titled “ComparisonRow”| Field | Type | Notes |
|---|---|---|
label | string | The attribute, e.g. “Storage”. |
values | Record<string, CompareValue> | One value per item id. A missing id or null shows as not offered. |
kind (optional) | "text" | "number" | "boolean" | "rating" | How values draw. Default: from the value (number, boolean, else text). “rating” draws stars out of max. |
format (optional) | NumberFormat | How a number shows (currency, percent, compact). |
unit (optional) | string | After a number, e.g. “GB” or “days”. |
max (optional) | number | Rating scale. Default 5. |
better (optional) | "higher" | "lower" | Which value wins the row: it gets a star and “best” for screen readers. Omit when neither is better. |
hint (optional) | string | A short hint under the label. |
group (optional) | string | Starts a section above this row, e.g. “Security”. |
ComparisonActions
Section titled “ComparisonActions”| Field | Type | Notes |
|---|---|---|
choose() (optional) | (id: string) => Promise<unknown> | Selectable: acts on the choice (switch the plan, accept the quote). Throw to show the error and keep the card open. |
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
- comparison: 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.