CopilotKitDocs
  • Docs
  • Reference
  • Cookbook
Get Intelligence free
CopilotKitDocs
DocsReferenceCookbook
DocsReferenceCookbook

@copilotkit/bot

ActionStoreBotNodeInteractionContext

@copilotkit/bot-slack

ReferencebotTypes

InteractionContext

The context passed to interaction handlers — the thread, the clicked control's typed value, and the clicking user.


Overview

InteractionContext is what every interaction handler receives — inline onClick / onSelect / onSubmit handlers on components, handlers registered with bot.onInteraction, and handlers wrapped with bind(). It is generic over the clicked control's value type.

Shape

type ClickHandler<TValue = unknown> = (
  ctx: InteractionContext<TValue>,
) => void | Promise<void>;

interface InteractionContext<TValue = unknown> {
  thread: Thread;
  message: IncomingMessage;
  action: { id: string; value?: TValue };
  values: Record<string, unknown>;
  user: PlatformUser;
  platform: string;
}

Properties

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Handler return type

A ClickHandler must return void or Promise<void>. A concise arrow whose body ends in a value-returning call — like thread.post(...), which returns a MessageRef — won't type-check; use a block body:

<Button
  onClick={async ({ thread }) => {
    await thread.post("done");
  }}
>
  Done
</Button>

Related

  • Button — typed value inference
  • bind() — handlers with persisted args
  • Thread — everything you can do with ctx.thread
10d3939