Chat cards
Chart
One chart in a chat card: a trend with its previous period dashed behind it, bars grouped or stacked, or a donut breakdown. A headline carries the latest number and its change; hover or tap reads any point.
When to use it
Section titled “When to use it”Use it when: The answer is a shape, not one number: a trend over time (line), amounts per period or channel (bars, grouped or stacked), or how a whole splits up (donut). One to three series, plus a previous period to compare against.
Use something else when: A few headline numbers without their history (KPI tiles). Exact values to look up or sort (table). More than three series, or a full report with findings (report canvas).
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 chart shows. The agent goes on; it already has every number from execute. |
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 no data for the period. 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.
ChartData
Section titled “ChartData”| Field | Type | Notes |
|---|---|---|
type | "line" | "bar" | "donut" | line: a trend over time. bar: amounts per period or category. donut: parts of one whole. |
title | string | |
subtitle (optional) | string | |
icon (optional) | IconName | Default: chart, bars or pie, by type. |
labels | string[] | The x-axis labels, oldest first. On a donut, the slice names. |
series | ChartSeries[] | 1 to 3 series plus one compare series; more are cut. A donut draws its first series, up to 5 slices (the rest become Other). |
stacked (optional) | boolean | Bars only: stack the series instead of grouping them. Values should be 0 or more. |
format (optional) | NumberFormat | How the axis, the tooltip and the headline format values. |
headline (optional) | ChartHeadline | The number above the chart, with its change. |
footnote (optional) | string | Short note on the left of the footer, e.g. “Excludes refunds”. |
link (optional) | { label: string; href: string } | A footer link to the full report in your app. |
ChartSeries
Section titled “ChartSeries”| Field | Type | Notes |
|---|---|---|
name | string | The legend and tooltip name, e.g. “2026” or “Organic”. |
values | number[] | One value per label, in the same order. |
compare (optional) | boolean | A comparison series (last year, last period, a target): muted and dashed, never stacked. At most one. |
ChartHeadline
Section titled “ChartHeadline”| Field | Type | Notes |
|---|---|---|
value (optional) | number | string | The big number. Default: the last period’s value (summed when stacked), or a donut’s total. |
label (optional) | string | What the number is, e.g. “Revenue in November”. Default: the last label, or “Total” on a donut. |
delta (optional) | number | Change in percent. Default: the last period against the compare series, or the period before. |
good (optional) | boolean | false when up is bad (costs, churn). Default: up is good. |
vs (optional) | string | What the change is against, e.g. “vs Nov 2025”. |
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
- chart: 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.