Chat cards
KPI tiles
Two to six headline numbers, each with its change and a sparkline. The agent answers in a sentence; the card carries the numbers.
When to use it
Section titled “When to use it”Use it when: The user asks how something is doing and the answer is 2–6 headline numbers (totals, rates, counts), each with a change vs a period.
Use something else when: One number only (answer in text). A trend over time is the point (chart card). Many rows of the same metric (records list / table).
What the agent receives
Section titled “What the agent receives”| The template calls | The agent gets | When |
|---|---|---|
displayed() | FUNCTION_TOOL_DISPLAYED | As soon as the card shows. The agent goes on. |
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 nothing to show. The card says so and the agent explains why. |
| 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.
KpiTilesData
Section titled “KpiTilesData”| Field | Type | Notes |
|---|---|---|
title | string | |
subtitle (optional) | string | |
icon (optional) | IconName | |
metrics | KpiMetric[] | 2–6 tiles; more are cut. |
footnote (optional) | string | |
link (optional) | { label: string; href: string } |
KpiMetric
Section titled “KpiMetric”| Field | Type | Notes |
|---|---|---|
label | string | |
value | number | string | |
format (optional) | NumberFormat | |
delta (optional) | { value: number; good?: boolean; vs?: string } | Change in percent. good: false when up is bad (costs, churn); default: up is good. |
trend (optional) | number[] | Recent values, oldest first, for the sparkline. |
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
- kpi-tiles: 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.