CopilotKitDocs
  • Docs
  • Reference
  • Cookbook
Get Intelligence free
CopilotKitDocs
DocsReferenceCookbook
DocsReferenceCookbook

@copilotkit/bot

@copilotkit/bot-slack

slackrenderBlockKitmarkdownToMrkdwndefaultSlackToolsdefaultSlackContextSanitizingHttpAgent
ReferencebotSlack

renderBlockKit

Translate the bot-ui BotNode IR to Slack Block Kit, degrading within Slack's per-element budgets (SLACK_LIMITS).


Overview

renderBlockKit translates the BotNode IR into Block Kit blocks; renderSlackMessage additionally extracts a top-level <Message accent> into the accent color for an attachment. The adapter calls these for you on every thread.post — reach for them directly when testing components or building custom egress.

Signature

import { renderBlockKit, renderSlackMessage, SLACK_LIMITS } from "@copilotkit/bot-slack";

function renderBlockKit(ir: BotNode[]): KnownBlock[];

function renderSlackMessage(ir: BotNode[]): {
  blocks: KnownBlock[];
  accent?: string;
};

Component mapping

ComponentBlock Kit
Messagethe message's blocks (or an accent attachment)
Headerheader
Section / Markdownsection (mrkdwn)
Fieldssection.fields
Contextcontext
Actionsactions
Buttonbutton (action_id = minted opaque id)
Selectstatic_select
Inputplain_text_input
Imageimage
Dividerdivider
Tablenative table block

Per-element budgets

Slack caps every element. The renderer degrades instead of failing: over-long text is truncated with an overflow marker, and the top-level block list is clamped to 50 with an overflow-signal context block appended when blocks had to be dropped. Sub-collections (fields, actions elements, context elements, select options, table rows/columns) are clamped to their caps without a marker — an 11th field or 26th button is dropped silently. Nothing ever exceeds a platform limit. The limits ship as SLACK_LIMITS:

LimitValueElement
blocksPerMessage50blocks per message
sectionText3000section body chars
headerText150header chars
fieldsPerSection10fields per section
fieldText2000field chars
actionsElements25controls per actions row
contextElements10elements per context block
buttonText75button label chars
actionId255action_id chars
buttonValue2000button value chars
selectOptions100options per select
tableColumns20columns per table
tableRows100rows per table
cellText2000table cell chars

Accent attachments

Block Kit has no native accent color, so a single top-level <Message accent="#27AE60"> is surfaced by renderSlackMessage as accent, and the adapter posts the blocks as an attachment with a colored left bar: attachments: [{ color, blocks }].

Related

  • slack() — the adapter that calls this on every post
  • BotNode — the IR this consumes
  • renderToIR — producing the IR from JSX
570dd39