showcase/shell-docs/src/content/reference/bot/functions/createBot.mdx
createBot is the entry point of @copilotkit/bot. It wires one or more platform adapters to an AG-UI agent and returns a Bot — the surface for registering turn handlers, interaction handlers, interrupt handlers, slash commands, and tools, plus start() / stop() lifecycle control.
For a complete walkthrough, see the Slack quickstart.
import { createBot } from "@copilotkit/bot";
function createBot(opts: CreateBotOptions): Bot;
import { createBot } from "@copilotkit/bot";
import { slack, defaultSlackTools, defaultSlackContext } from "@copilotkit/bot-slack";
const bot = createBot({
adapters: [
slack({
botToken: process.env.SLACK_BOT_TOKEN!,
appToken: process.env.SLACK_APP_TOKEN!,
}),
],
agent: (threadId) => makeAgent(threadId),
tools: [...defaultSlackTools, ...appTools],
context: [...defaultSlackContext, ...appContext],
});
bot.onMention(async ({ thread }) => {
await thread.runAgent();
});
await bot.start();
onMention handler is registered, all turns route to the mention handlers; otherwise onMessage handlers fire. Registering identical handlers on both never double-fires.ActionExpiredError internally; createBot swallows it, so the click is acked but ignored and no message is posted.runAgent — omitting agent is fine for bots that only post UI, but thread.runAgent() will throw.