(
channel: string,
text: string,
opts: { threadTs?: string } = {},
)
| 39 | } |
| 40 | |
| 41 | export 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 | |
| 59 | export async function channelHistory(channel: string, limit = 10) { |
| 60 | const r = await slack("conversations.history", { channel, limit }); |
no test coverage detected