MCPcopy Index your code
hub / github.com/CopilotKit/OpenTag / slack

Function slack

e2e/slack-api.ts:18–39  ·  view source on GitHub ↗
(
  method: string,
  params: Record<string, unknown> = {},
  token = BOT_TOKEN,
)

Source from the content-addressed store, hash-verified

16const ENDPOINT = "https://slack.com/api/";
17
18async function slack(
19 method: string,
20 params: Record<string, unknown> = {},
21 token = BOT_TOKEN,
22): Promise<Record<string, unknown> & { ok: boolean }> {
23 // Slack's Web API accepts form-encoded bodies on every method.
24 // JSON body is rejected by read endpoints like conversations.replies.
25 const form = new URLSearchParams();
26 for (const [k, v] of Object.entries(params)) form.set(k, String(v));
27 const res = await fetch(`${ENDPOINT}${method}`, {
28 method: "POST",
29 headers: {
30 Authorization: `Bearer ${token}`,
31 "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
32 },
33 body: form.toString(),
34 });
35 const json = (await res.json()) as Record<string, unknown> & { ok: boolean };
36 if (!json.ok)
37 throw new Error(`slack ${method} failed: ${JSON.stringify(json)}`);
38 return json;
39}
40
41export async function postAsUser(
42 channel: string,

Callers 5

mainFunction · 0.85
mainFunction · 0.85
postAsUserFunction · 0.85
channelHistoryFunction · 0.85
threadRepliesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected