slack
Use this skill when a task requires reading from Slack, posting to Slack, uploading or downloading Slack files, inspecting Slack users/channels/teams, or otherwise interacting with Slack data.
When to use
- The user asks to read, search, summarize, or inspect Slack channels, groups, mentions, messages, users, teams, or files.
- The user asks to send, draft, or post a Slack message.
- The user asks to upload, fetch, or inspect Slack files.
- The user asks to build or debug Slack automation that should use the Slack REST API.
Instructions
Use the Slack REST API directly from Bun.
Check for SLACK_BOT_TOKEN in the environment before making Slack API calls.
- If
SLACK_BOT_TOKEN is missing or empty, stop and tell the user to set up Slack at https://superwall.ai/integrations.
- Do not ask the user to paste the token into chat.
Use Bun's built-in fetch to call Slack Web API endpoints.
- Send the token with
Authorization: Bearer ${process.env.SLACK_BOT_TOKEN}.
- Send JSON requests with
Content-Type: application/json; charset=utf-8 unless the endpoint requires multipart form data.
- Check both the HTTP status and Slack's JSON
ok field.
- Report Slack API errors by method name and
error value.
Prefer small, task-specific Bun scripts for Slack work.
const token = process.env.SLACK_BOT_TOKEN;
if (!token) {
throw new Error(
"SLACK_BOT_TOKEN is not set. Set up Slack at https://superwall.ai/integrations."
);
}
async function slack(method: string, body: Record<string, unknown> = {}) {
const response = await fetch(`https://slack.com/api/${method}`, {
method: "POST",
headers: {
authorization: `Bearer ${token}`,
"content-type": "application/json; charset=utf-8",
},
body: JSON.stringify(body),
});
const data = await response.json();
if (!response.ok || !data.ok) {
throw new Error(`${method} failed: ${data.error ?? response.statusText}`);
}
return data;
}
Use Slack cursor pagination whenever the response includes response_metadata.next_cursor.
- Keep page sizes conservative for reads.
- Stop when
next_cursor is absent or empty.
Treat the following bot scopes as available at minimum:
{
"scopes": {
"bot": [
"app_mentions:read",
"channels:read",
"channels:history",
"chat:write",
"chat:write.public",
"files:write",
"files:read",
"team:read",
"users:read",
"groups:history"
]
}
}
More scopes may be added over time.
- When scope availability matters, check the Slack API for the up-to-date scopes available to the app before deciding an operation is impossible.
- If the API reports a missing scope, state the exact scope Slack requires and the operation that needs it.
Use common Slack Web API methods according to the task:
auth.test to verify the token and identify the workspace/app context.
conversations.list to list public channels and private channels permitted by scopes.
conversations.history to read channel or group history.
chat.postMessage to send messages.
users.list or users.info to inspect users.
team.info to inspect workspace details.
files.uploadV2, files.info, and related file methods for file operations.
Be careful with writes.
- For sending messages or uploading files, confirm the target channel/user and content unless the user has already made both explicit.
- Do not delete, overwrite, or broadly broadcast content unless explicitly requested.
1---2name: slack3description: Work with Slack through the Slack Web API using Bun and the SLACK_BOT_TOKEN environment variable.4---56# slack78Use this skill when a task requires reading from Slack, posting to Slack, uploading or downloading Slack files, inspecting Slack users/channels/teams, or otherwise interacting with Slack data.910## When to use1112- The user asks to read, search, summarize, or inspect Slack channels, groups, mentions, messages, users, teams, or files.13- The user asks to send, draft, or post a Slack message.14- The user asks to upload, fetch, or inspect Slack files.15- The user asks to build or debug Slack automation that should use the Slack REST API.1617## Instructions1819Use the Slack REST API directly from Bun.20211. Check for `SLACK_BOT_TOKEN` in the environment before making Slack API calls.22 - If `SLACK_BOT_TOKEN` is missing or empty, stop and tell the user to set up Slack at https://superwall.ai/integrations.23 - Do not ask the user to paste the token into chat.24252. Use Bun's built-in `fetch` to call Slack Web API endpoints.26 - Send the token with `Authorization: Bearer ${process.env.SLACK_BOT_TOKEN}`.27 - Send JSON requests with `Content-Type: application/json; charset=utf-8` unless the endpoint requires multipart form data.28 - Check both the HTTP status and Slack's JSON `ok` field.29 - Report Slack API errors by method name and `error` value.30313. Prefer small, task-specific Bun scripts for Slack work.3233```ts34const token = process.env.SLACK_BOT_TOKEN;3536if (!token) {37 throw new Error(38 "SLACK_BOT_TOKEN is not set. Set up Slack at https://superwall.ai/integrations."39 );40}4142async function slack(method: string, body: Record<string, unknown> = {}) {43 const response = await fetch(`https://slack.com/api/${method}`, {44 method: "POST",45 headers: {46 authorization: `Bearer ${token}`,47 "content-type": "application/json; charset=utf-8",48 },49 body: JSON.stringify(body),50 });5152 const data = await response.json();5354 if (!response.ok || !data.ok) {55 throw new Error(`${method} failed: ${data.error ?? response.statusText}`);56 }5758 return data;59}60```61624. Use Slack cursor pagination whenever the response includes `response_metadata.next_cursor`.63 - Keep page sizes conservative for reads.64 - Stop when `next_cursor` is absent or empty.65665. Treat the following bot scopes as available at minimum:6768```json69{70 "scopes": {71 "bot": [72 "app_mentions:read",73 "channels:read",74 "channels:history",75 "chat:write",76 "chat:write.public",77 "files:write",78 "files:read",79 "team:read",80 "users:read",81 "groups:history"82 ]83 }84}85```86876. More scopes may be added over time.88 - When scope availability matters, check the Slack API for the up-to-date scopes available to the app before deciding an operation is impossible.89 - If the API reports a missing scope, state the exact scope Slack requires and the operation that needs it.90917. Use common Slack Web API methods according to the task:92 - `auth.test` to verify the token and identify the workspace/app context.93 - `conversations.list` to list public channels and private channels permitted by scopes.94 - `conversations.history` to read channel or group history.95 - `chat.postMessage` to send messages.96 - `users.list` or `users.info` to inspect users.97 - `team.info` to inspect workspace details.98 - `files.uploadV2`, `files.info`, and related file methods for file operations.991008. Be careful with writes.101 - For sending messages or uploading files, confirm the target channel/user and content unless the user has already made both explicit.102 - Do not delete, overwrite, or broadly broadcast content unless explicitly requested.