MCPcopy Index your code
hub / github.com/simstudioai/sim / postSlackMessage

Function postSlackMessage

apps/sim/app/api/tools/slack/utils.ts:11–33  ·  view source on GitHub ↗

* Sends a message to a Slack channel using chat.postMessage

(
  accessToken: string,
  channel: string,
  text: string,
  threadTs?: string | null,
  blocks?: unknown[] | null
)

Source from the content-addressed store, hash-verified

9 * Sends a message to a Slack channel using chat.postMessage
10 */
11async function postSlackMessage(
12 accessToken: string,
13 channel: string,
14 text: string,
15 threadTs?: string | null,
16 blocks?: unknown[] | null
17): Promise<{ ok: boolean; ts?: string; channel?: string; message?: any; error?: string }> {
18 const response = await fetch('https://slack.com/api/chat.postMessage', {
19 method: 'POST',
20 headers: {
21 'Content-Type': 'application/json',
22 Authorization: `Bearer ${accessToken}`,
23 },
24 body: JSON.stringify({
25 channel,
26 text,
27 ...(threadTs && { thread_ts: threadTs }),
28 ...(blocks && blocks.length > 0 && { blocks }),
29 }),
30 })
31
32 return response.json()
33}
34
35/**
36 * Creates a default message object when the API doesn't return one

Callers 1

sendSlackMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected