MCPcopy Create free account
hub / github.com/CopilotKit/OpenTag / postAsUser

Function postAsUser

e2e/slack-api.ts:41–57  ·  view source on GitHub ↗
(
  channel: string,
  text: string,
  opts: { threadTs?: string } = {},
)

Source from the content-addressed store, hash-verified

39}
40
41export async function postAsUser(
42 channel: string,
43 text: string,
44 opts: { threadTs?: string } = {},
45) {
46 if (!USER_TOKEN) {
47 throw new Error(
48 "SLACK_USER_TOKEN missing — add an xoxp token with chat:write to .env; see e2e/README.md",
49 );
50 }
51 // `link_names: 1` makes Slack resolve `@username` (and `@here`/`@channel`)
52 // in the post body into real mention tokens — without this, the bot's
53 // `app_mention` event doesn't fire for plain-text "@CopilotKit AG-UI Bot".
54 const params: Record<string, unknown> = { channel, text, link_names: 1 };
55 if (opts.threadTs) params.thread_ts = opts.threadTs;
56 return slack("chat.postMessage", params, USER_TOKEN);
57}
58
59export async function channelHistory(channel: string, limit = 10) {
60 const r = await slack("conversations.history", { channel, limit });

Callers 2

runCaseFunction · 0.85
runScenarioFunction · 0.85

Calls 1

slackFunction · 0.85

Tested by

no test coverage detected