showcase/shell-docs/src/content/reference/bot/functions/defineBotCommand.mdx
defineBotCommand defines a slash command with full type inference: ctx.options is inferred from the options schema. Commands are registered via createBot({ commands }) or bot.onCommand, and routed to the matching handler when the platform delivers an invocation.
import { defineBotCommand } from "@copilotkit/bot";
function defineBotCommand<Schema extends ObjectSchema>(
command: BotCommand<Schema>,
): BotCommand<Schema>;
import { defineBotCommand } from "@copilotkit/bot";
import { z } from "zod";
const triage = defineBotCommand({
name: "triage",
description: "Summarize and file the current thread.",
options: z.object({ priority: z.enum(["low", "high"]).optional() }),
async handler({ thread, text }) {
await thread.runAgent({ prompt: `Triage: ${text}` });
},
});
A slash command's text is never posted to the channel, so it isn't in the history the adapter reconstructs — pass it to the agent explicitly with runAgent({ prompt }).
slash_commands section, or "Slash Commands" in the app settings); an undeclared command is silently dropped, even over Socket Mode. See the Slack quickstart.start(), declared commands are forwarded to adapters that implement registerCommands (e.g. a Discord-style application-command API); adapters without it, including Slack, are skipped.commands option / onCommand)runAgent({ prompt })