Back to Copilotkit

createChannel

showcase/shell-docs/src/content/reference/channels/functions/createChannel.mdx

1.64.22.6 KB
Original Source

createChannel(options) creates the provider-neutral Channel registered with CopilotRuntime({ channels }).

Signature

ts
function createChannel<TStateSchema>(
  options: CreateChannelOptions<TStateSchema>,
): Channel<ThreadStateOf<TStateSchema>>;

Import it from the umbrella package:

ts
import { createChannel } from "@copilotkit/channels";

Managed example

ts
const channel = createChannel({
  name: "support-slack",
  provider: "slack",
  agent: makeAgent,
  tools: [getIncident],
  context: [
    {
      description: "Response style",
      value: "Put the next action first.",
    },
  ],
});

channel.onMessage(async ({ thread, message }) => {
  await thread.runAgent({ prompt: message.text });
});

Use provider: "teams" with the exact Code of the corresponding Teams Channel in Intelligence. Slack and Teams are production-ready managed providers.

Options

OptionTypeNotes
namestringRequired for managed delivery. Must match the project-unique Intelligence Code.
provider"slack" | "teams"Managed provider. Defaults to Slack when omitted; set it explicitly.
showToolStatusbooleanManaged Slack hides tool-call progress by default. Set true to show it; tool history remains available in Intelligence either way.
agentAbstractAgent | (threadId) => AbstractAgentPrefer a factory; a singleton is isolated per run via clone().
toolsChannelTool[]Channel-level typed tools.
contextContextEntry[]Stable context added to every agent run.
componentsChannelComponent[]Named JSX components used to reconstruct callbacks.
commandsChannelCommand[]Declared commands routed from provider ingress.
storeStoreConfigState, persistence, turn concurrency (parallel default), transcripts, and dedup.
adaptersPlatformAdapter[]Developer-owned direct transports. Do not mix them with managed activation on one Channel.

The managed runtime validates name as lowercase kebab-case, 3–64 characters, not equal to channels, and unique within the Runtime.

Registration methods

The returned Channel supports:

  • onMessage and onMention
  • onInterrupt
  • onInteraction
  • onCommand
  • onReaction
  • onThreadStarted
  • onModalSubmit and onModalClose for adapters that support modals
  • tool to add a tool before the Channel starts

See Channel for handler signatures and StoreConfig for persistence.