mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
fc3cc1b395
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.
18 lines
902 B
TypeScript
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 }];
|
|
}
|