Skip to content

Commit add2c58

Browse files
authored
feat(slack): support native chart presentations (#102635)
1 parent a1e75e0 commit add2c58

68 files changed

Lines changed: 3246 additions & 154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
f9b18b8c984425898ea364952a3c73bd57fe201558df5dc92664a098195ee31a plugin-sdk-api-baseline.json
2-
278523eb82c0ee6b8a1ef99e34eb379f53564f5d976c9e4ec0b2e7ce637877a2 plugin-sdk-api-baseline.jsonl
1+
0d81b40bb07ac1cbf1d3e1ffb1f219907a4ae0e284a3c5b67343443a8c052235 plugin-sdk-api-baseline.json
2+
289650c203e232779e839b170e6c68616812c59b00f9083ca25776fbd2888fe6 plugin-sdk-api-baseline.jsonl

‎docs/channels/slack.md‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,57 @@ Native argument menus render as one of the following, in priority order:
15091509

15101510
Slash sessions use isolated keys like `agent:<agentId>:slack:slash:<userId>` and still route command executions to the target conversation session using `CommandTargetSessionKey`.
15111511

1512+
## Native charts
1513+
1514+
Slack's public [`data_visualization` Block Kit block](https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block/)
1515+
renders line, bar, area, and pie charts in messages. OpenClaw maps the portable
1516+
`presentation` `chart` block to that native shape; no additional OAuth scope,
1517+
file upload, image renderer, or Slack configuration is required beyond normal
1518+
`chat:write` message access.
1519+
1520+
```json
1521+
{
1522+
"blocks": [
1523+
{
1524+
"type": "chart",
1525+
"chartType": "bar",
1526+
"title": "Quarterly revenue",
1527+
"categories": ["Q1", "Q2"],
1528+
"series": [{ "name": "Revenue", "values": [120, 145] }],
1529+
"xLabel": "Quarter"
1530+
}
1531+
]
1532+
}
1533+
```
1534+
1535+
Slack's limits are enforced before native rendering:
1536+
1537+
- title and optional axis labels: 50 characters
1538+
- pie: 1-12 positive segments
1539+
- line/bar/area: 1-12 uniquely named series and 1-20 shared categories
1540+
- segment, category, and series labels: 20 characters
1541+
- every series must contain one finite value for every category; non-pie values
1542+
may be negative
1543+
1544+
Every native chart also carries a top-level text representation for screen
1545+
readers, notifications, session mirroring, and clients that cannot render the
1546+
block. Standard presentation sends to other OpenClaw channels receive that same
1547+
deterministic chart data as text unless they advertise native chart support. If
1548+
Slack rejects the chart with `invalid_blocks` during a phased rollout, OpenClaw
1549+
retries once with the text representation and no blocks.
1550+
1551+
Slack currently accepts up to two `data_visualization` blocks per message. When
1552+
a presentation contains more than two valid charts, OpenClaw renders the first
1553+
two natively and preserves each additional chart as deterministic visible text
1554+
in the same message.
1555+
1556+
Slack's [developer launch](https://docs.slack.dev/changelog/2026/06/16/block-kit-data-visualization-block/)
1557+
documents the block as an app-facing Block Kit feature and publishes no paid
1558+
plan restriction. The Business+/Enterprise eligibility language applies to
1559+
Slackbot's automatic AI chart generation, which is separate from an app sending
1560+
an already-structured Block Kit chart. Charts are message-only blocks, not App
1561+
Home, modal, or Canvas content.
1562+
15121563
## Interactive replies
15131564

15141565
Slack can render agent-authored interactive reply controls, but this feature is disabled by default.

‎docs/cli/message.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ openclaw message send --channel discord \
9191
- `--media <path-or-url>`: attach image/audio/video/document (local path or
9292
URL).
9393
- `--presentation <json>`: shared payload with `text`, `context`, `divider`,
94-
`buttons`, `select` blocks, rendered per channel capability. See
94+
`chart`, `buttons`, and `select` blocks, rendered per channel capability. See
9595
[Message Presentation](/plugins/message-presentation).
9696
- `--delivery <json>`: generic delivery preferences, for example `{"pin":
9797
true}`. `--pin` is shorthand for pinned delivery when the channel supports
@@ -114,6 +114,14 @@ openclaw message send --channel telegram --target @mychat --message "Choose:" \
114114
--presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Yes","value":"cmd:yes"},{"label":"No","value":"cmd:no"}]}]}'
115115
```
116116

117+
Slack renders supported chart blocks natively; other channels receive the same
118+
data as readable text:
119+
120+
```bash
121+
openclaw message send --channel slack --target channel:C123 \
122+
--presentation '{"blocks":[{"type":"chart","chartType":"bar","title":"Quarterly revenue","categories":["Q1","Q2"],"series":[{"name":"Revenue","values":[120,145]}],"xLabel":"Quarter"}]}'
123+
```
124+
117125
Telegram Mini App buttons use `webApp` (`web_app` still parses for legacy
118126
JSON) and only render in private chats between a user and the bot:
119127

‎docs/docs_map.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ Do not edit it by hand; run `pnpm docs:map:gen`.
861861
- H2: Voice input
862862
- H2: Media, chunking, and delivery
863863
- H2: Commands and slash behavior
864+
- H2: Native charts
864865
- H2: Interactive replies
865866
- H3: Plugin-owned modal submissions
866867
- H2: Native approvals in Slack

‎docs/plugins/architecture-internals.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ fallback rules, provider mapping, and plugin author checklist.
738738

739739
Send-capable plugins declare what they can render through message capabilities:
740740

741-
- `presentation` for semantic presentation blocks (`text`, `context`, `divider`, `buttons`, `select`)
741+
- `presentation` for semantic presentation blocks (`text`, `context`, `divider`, `chart`, `buttons`, `select`)
742742
- `delivery-pin` for pinned-delivery requests
743743

744744
Core decides whether to render the presentation natively or degrade it to text.

‎docs/plugins/message-presentation.md‎

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
summary: "Semantic message cards, buttons, selects, fallback text, and delivery hints for channel plugins"
2+
summary: "Semantic message cards, charts, controls, fallback text, and delivery hints for channel plugins"
33
title: "Message presentation"
44
read_when:
5-
- Adding or modifying message card, button, or select rendering
5+
- Adding or modifying message card, chart, button, or select rendering
66
- Building a channel plugin that supports rich outbound messages
77
- Changing message tool presentation or delivery capabilities
88
- Debugging provider-specific card/block/component rendering regressions
@@ -13,7 +13,7 @@ It lets agents, CLI commands, approval flows, and plugins describe the message
1313
intent once, while each channel plugin renders the best native shape it can.
1414

1515
Use presentation for portable message UI: text sections, small context/footer
16-
text, dividers, buttons, select menus, and card title/tone.
16+
text, dividers, charts, buttons, select menus, and card title/tone.
1717

1818
Do not add new provider-native fields such as Discord `components`, Slack
1919
`blocks`, Telegram `buttons`, Teams `card`, or Feishu `card` to the shared
@@ -44,7 +44,22 @@ type MessagePresentationBlock =
4444
| { type: "context"; text: string }
4545
| { type: "divider" }
4646
| { type: "buttons"; buttons: MessagePresentationButton[] }
47-
| { type: "select"; placeholder?: string; options: MessagePresentationOption[] };
47+
| { type: "select"; placeholder?: string; options: MessagePresentationOption[] }
48+
| {
49+
type: "chart";
50+
chartType: "pie";
51+
title: string;
52+
segments: Array<{ label: string; value: number }>;
53+
}
54+
| {
55+
type: "chart";
56+
chartType: "bar" | "area" | "line";
57+
title: string;
58+
categories: string[];
59+
series: Array<{ name: string; values: number[] }>;
60+
xLabel?: string;
61+
yLabel?: string;
62+
};
4863

4964
type MessagePresentationAction =
5065
| { type: "command"; command: string }
@@ -121,6 +136,17 @@ Select semantics:
121136
select support.
122137
- If a channel does not support selects, fallback text lists the labels.
123138

139+
Chart semantics:
140+
141+
- `pie` requires positive segment values.
142+
- `bar`, `area`, and `line` use one ordered `categories` array. Every series
143+
supplies exactly one finite value per category, in the same order.
144+
- Category labels and series names must be unique. Invalid or incomplete chart
145+
blocks are dropped during normalization rather than silently changing data.
146+
- Native chart rendering is opt-in through `presentationCapabilities.charts`.
147+
Other channels receive the chart title, axes, categories, series, and values
148+
as deterministic text. This is also the accessibility fallback.
149+
124150
## Producer examples
125151

126152
Simple card:
@@ -188,6 +214,27 @@ Select menu:
188214
}
189215
```
190216

217+
Chart:
218+
219+
```json
220+
{
221+
"blocks": [
222+
{
223+
"type": "chart",
224+
"chartType": "line",
225+
"title": "Quarterly revenue",
226+
"categories": ["Q1", "Q2", "Q3"],
227+
"series": [
228+
{ "name": "Product", "values": [120, 145, 138] },
229+
{ "name": "Services", "values": [80, 95, 104] }
230+
],
231+
"xLabel": "Quarter",
232+
"yLabel": "Revenue"
233+
}
234+
]
235+
}
236+
```
237+
191238
CLI send:
192239

193240
```bash
@@ -231,6 +278,7 @@ const adapter: ChannelOutboundAdapter = {
231278
selects: true,
232279
context: true,
233280
divider: true,
281+
charts: false,
234282
limits: {
235283
actions: {
236284
maxActions: 25,
@@ -276,6 +324,7 @@ type ChannelPresentationCapabilities = {
276324
selects?: boolean;
277325
context?: boolean;
278326
divider?: boolean;
327+
charts?: boolean;
279328
limits?: {
280329
actions?: {
281330
maxActions?: number;
@@ -311,19 +360,24 @@ visible fallback.
311360

312361
## Core render flow
313362

314-
When a `ReplyPayload` or message action includes `presentation`, core:
363+
On the canonical outbound path used by CLI and standard message actions, core:
315364

316365
1. Normalizes the presentation payload.
317366
2. Resolves the target channel's outbound adapter.
318367
3. Reads `presentationCapabilities`.
319368
4. Applies generic capability limits such as action count, label length, and
320-
select option count when the adapter advertises them.
369+
select option count when the adapter advertises them. Chart blocks become
370+
deterministic text unless the adapter explicitly advertises `charts: true`.
321371
5. Calls `renderPresentation` when the adapter can render the payload.
322372
6. Falls back to conservative text when the adapter is absent or cannot render.
323373
7. Sends the resulting payload through the normal channel delivery path.
324374
8. Applies delivery metadata such as `delivery.pin` after the first successful
325375
sent message.
326376

377+
Channel-local reply or preview funnels that consume `ReplyPayload` directly
378+
must either enter that canonical path or materialize the same presentation
379+
fallback before projecting the payload down to plain text/media.
380+
327381
Core owns fallback behavior so producers can stay channel-agnostic. Channel
328382
plugins own native rendering and interaction handling.
329383

@@ -339,6 +393,7 @@ Fallback text includes:
339393
- `divider` blocks as a visual separator
340394
- button labels, including URLs for link buttons
341395
- select option labels
396+
- chart title, type, axes, categories, series, and values
342397

343398
### Button value fallback visibility
344399

@@ -365,6 +420,7 @@ Examples:
365420

366421
- Telegram with inline buttons disabled sends text fallback.
367422
- A channel without select support lists select options as text.
423+
- A channel without native chart support lists the chart data as text.
368424
- A URL-only button becomes either a native link button or a fallback URL line.
369425
- Optional pin failures do not fail the delivered message.
370426

@@ -382,7 +438,7 @@ Current bundled renderers:
382438
| Matrix | Text fallback plus structured event field | Buttons/selects advertise as supported, but every block currently renders as `renderMessagePresentationFallbackText` output carried in a `com.openclaw.presentation` event field, not native interactive widgets. |
383439
| Mattermost | Text plus interactive props | Selects and dividers are not supported; those blocks degrade to text. |
384440
| Microsoft Teams | Adaptive Cards | Plain `message` text is included with the card when both are provided. Selects, styles, and disabled state are not supported. |
385-
| Slack | Block Kit | Preserves legacy `channelData.slack.blocks` for existing provider-native payload producers, but new shared sends should use `presentation`. |
441+
| Slack | Block Kit | Renders `chart` as native `data_visualization`; preserves legacy `channelData.slack.blocks`, but new shared sends should use `presentation`. |
386442
| Telegram | Text plus inline keyboards | Buttons/selects require inline button capability for the target surface; otherwise text fallback is used. |
387443
| Plain channels | Text fallback | Channels without a renderer still get readable output. |
388444

@@ -404,6 +460,7 @@ helpers. It supports:
404460
- tone
405461
- context
406462
- divider
463+
- chart
407464
- URL-only buttons
408465
- generic delivery metadata through `ReplyPayload.delivery`
409466

@@ -421,6 +478,7 @@ import {
421478
presentationPageSize,
422479
presentationToInteractiveControlsReply,
423480
presentationToInteractiveReply,
481+
renderMessagePresentationChartFallbackText,
424482
renderMessagePresentationFallbackText,
425483
resolveMessagePresentationActionValue,
426484
resolveMessagePresentationControlValue,
@@ -505,8 +563,8 @@ messages where the provider supports those operations.
505563
- Declare generic capability limits on `presentationCapabilities.limits` when
506564
they are known.
507565
- Preserve final platform limits in the renderer and tests.
508-
- Add fallback tests for unsupported buttons, selects, URL buttons, title/text
509-
duplication, and mixed `message` plus `presentation` sends.
566+
- Add fallback tests for unsupported charts, buttons, selects, URL buttons,
567+
title/text duplication, and mixed `message` plus `presentation` sends.
510568
- Add delivery pin support through `deliveryCapabilities.pin` and
511569
`pinDeliveredMessage` only when the provider can pin the sent message id.
512570
- Do not expose new provider-native card/block/component/button fields through

‎extensions/discord/src/actions/handle-action.test.ts‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,56 @@ describe("handleDiscordMessageAction", () => {
563563
});
564564
});
565565

566+
it("downgrades chart-only presentations to Discord component text", async () => {
567+
const cfg = discordConfig();
568+
569+
await handleDiscordMessageAction({
570+
action: "send",
571+
params: {
572+
to: "channel:123",
573+
presentation: {
574+
blocks: [
575+
{
576+
type: "chart",
577+
chartType: "bar",
578+
title: "Revenue",
579+
categories: ["Q1", "Q2"],
580+
series: [{ name: "USD", values: [12, 18] }],
581+
},
582+
],
583+
},
584+
},
585+
cfg,
586+
});
587+
588+
expectDiscordActionCall({
589+
payload: {
590+
action: "sendMessage",
591+
accountId: undefined,
592+
to: "channel:123",
593+
content: "",
594+
mediaUrl: undefined,
595+
filename: undefined,
596+
replyTo: undefined,
597+
components: {
598+
blocks: [
599+
{
600+
type: "text",
601+
text: "-# Revenue (bar chart)\n- USD: Q1: 12; Q2: 18",
602+
},
603+
],
604+
},
605+
embeds: undefined,
606+
asVoice: false,
607+
silent: false,
608+
__sessionKey: undefined,
609+
__agentId: undefined,
610+
},
611+
cfg,
612+
options: defaultActionOptions(),
613+
});
614+
});
615+
566616
it("does not use another provider's current target for Discord sends", async () => {
567617
await expect(
568618
handleDiscordMessageAction({

‎extensions/discord/src/actions/handle-action.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
99
import { resolveReactionMessageId } from "openclaw/plugin-sdk/channel-actions";
1010
import type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-contract";
1111
import {
12+
adaptMessagePresentationForChannel,
1213
normalizeInteractiveReply,
1314
normalizeMessagePresentation,
1415
} from "openclaw/plugin-sdk/interactive-runtime";
1516
import { normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
1617
import { handleDiscordAction } from "../../action-runtime-api.js";
1718
import { notifyDiscordInboundEventOutboundSuccess } from "../inbound-event-delivery.js";
19+
import { DISCORD_PRESENTATION_CAPABILITIES } from "../outbound-components.js";
1820
import {
1921
buildDiscordInteractiveComponents,
2022
buildDiscordPresentationComponents,
@@ -92,9 +94,17 @@ export async function handleDiscordMessageAction(
9294
if (action === "send") {
9395
const to = readSendTarget();
9496
const asVoice = readBooleanParam(params, "asVoice") === true;
97+
const presentation =
98+
params.components == null ? normalizeMessagePresentation(params.presentation) : undefined;
99+
const adaptedPresentation = presentation
100+
? adaptMessagePresentationForChannel({
101+
presentation,
102+
capabilities: DISCORD_PRESENTATION_CAPABILITIES,
103+
})
104+
: undefined;
95105
const rawComponents =
96106
params.components ??
97-
buildDiscordPresentationComponents(normalizeMessagePresentation(params.presentation)) ??
107+
buildDiscordPresentationComponents(adaptedPresentation) ??
98108
buildDiscordInteractiveComponents(normalizeInteractiveReply(params.interactive));
99109
const hasComponents =
100110
Boolean(rawComponents) &&

0 commit comments

Comments
 (0)