Files
copilotkit__copilotkit/examples/slack/app/sender-context.ts
Alem Tuzlak fc3cc1b395 feat(examples): drive Slack and Telegram from one app
examples/slack now starts a Slack bot and/or a Telegram bot from one platform-neutral app layer, env-conditional on which credentials are set. Neutralized Slack-specific rendering so the shared components work on both platforms: unicode glyphs instead of mrkdwn shortcodes, no Block Kit raw fallbacks, neutral context/tool wording. Migrated the Telegram e2e smoke harness and BotFather setup docs; removed the separate examples/telegram app.
2026-06-17 19:20:00 +02:00

18 lines
902 B
TypeScript

import type { ContextEntry } from "@copilotkit/bot";
import type { PlatformUser } from "@copilotkit/bot-ui";
/**
* Build the per-turn context naming the requesting user, so the agent
* can act "as" them (filter Linear by their email, @-mention them). The
* platform adapter resolves `{ id, name?, email? }` per turn; if it's absent
* there's nothing to attribute, so we add no entry.
*/
export function senderContext(user: PlatformUser | undefined): ContextEntry[] {
// `createBot` substitutes `{ id: "" }` for an unresolved sender (a truthy
// object), so guard on a usable id — not mere object presence — otherwise we
// emit a "Requesting user (user id )" entry with nothing to attribute.
if (!user?.id) return [];
const label = `${user.name ?? user.id}${user.email ? ` <${user.email}>` : ""} (user id ${user.id})`;
return [{ description: "Requesting user", value: label }];
}