BotNode
The serializable intermediate representation (IR) of bot UI ā what JSX renders to and what platform adapters translate.
Overview
BotNode is the intermediate representation between your JSX and a platform's native format. renderToIR lowers a component tree to BotNode[]; an adapter (e.g. slack()) translates those nodes to its native payload. Because the IR is plain serializable data, it can be snapshotted for action rehydration and asserted against in tests.
Shape
interface BotNode {
type: string | ComponentFn | symbol; // intrinsic string after rendering
props: Record<string, unknown>;
key?: string | number;
}
type ComponentFn = (
props: Record<string, unknown>,
) => BotNode | BotNode[] | string | null;
type Renderable = string | BotNode | BotNode[] | { raw: unknown };Prop
Type
Prop
Type
Prop
Type
Special node types
textā strings and numbers in children become{ type: "text", props: { value: string } }.rawā the{ raw }escape hatch passes through as{ type: "raw", props: { value } }, letting you hand an adapter a native payload (e.g. hand-built Block Kit) without going through the vocabulary.
Children
type BotChildren =
| BotNode
| string
| number
| boolean
| null
| undefined
| BotChildren[];Conditionals render nothing (false / null / undefined), so {cond && <Section>ā¦</Section>} works as expected.
Related
- renderToIR ā producing the IR
- Message ā the vocabulary that lowers to these nodes
- ActionStore ā how handler props are bound and snapshotted