Bots
API reference for the CopilotKit bot stack — @copilotkit/bot, @copilotkit/bot-ui, and @copilotkit/bot-slack.
The bot stack turns any AG-UI agent into a chat-platform bot. Three packages, three jobs:
| Package | Role |
|---|---|
@copilotkit/bot | The platform-agnostic engine: createBot, handler registration, the agent run/tool/interrupt loop, and action binding. Re-exports the @copilotkit/bot-ui vocabulary. |
@copilotkit/bot-ui | A pure JSX runtime + cross-platform component vocabulary for rich messages — no React. |
@copilotkit/bot-slack | The Slack adapter: Socket Mode ingress, JSX → Block Kit via slack(), chat.update streaming. |
pnpm add @copilotkit/bot @copilotkit/bot-ui @copilotkit/bot-slackNew to the stack? Start with the Slack quickstart — zero to a working bot, then come back here for the API surface.
Setup
The packages ship as ES modules only ("type": "module" required). To author messages as JSX, point the TypeScript JSX factory at @copilotkit/bot-ui and write .tsx files:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@copilotkit/bot-ui"
}
}The package ships its own JSX namespace via @copilotkit/bot-ui/jsx-runtime, so JSX is statically type-checked: unknown attributes, wrong prop values, and bad children are compile-time errors.
Start here
createBot()
Create the bot: adapters, agent, tools, context, commands, and the handler surface.
Thread
The per-conversation handle: post, stream, runAgent, awaitChoice, and capability-gated platform methods.
Components
The JSX vocabulary for rich messages: Message, Header, Section, Button, Select, Table, and friends.
slack()
The Slack adapter: options, Block Kit budgets, streaming, and mrkdwn translation.
How the pieces fit
A turn flows through three stages. The adapter normalizes a platform event into a turn and hands it to your handler, which calls thread.runAgent(). The engine drives the run loop — streaming text into the thread, executing tools when the agent calls them, capturing interrupts. Anything you post is JSX lowered to the BotNode intermediate representation (plain serializable data), which the adapter translates to the platform's native format — with interactive handlers bound through the ActionStore.
Related
- Slack quickstart — create the Slack app, install, and run your first bot
- On-call triage example — a full bot over Linear + Notion MCP with HITL and slash commands