slack-notifications

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Mode: Cognitive/Prompt-Driven — No standalone utility script; use via agent context.
模式:认知/提示驱动 — 无独立实用脚本,需通过Agent上下文使用。

Slack Notifications Skill

Slack Notifications Skill

Overview

概述

This skill provides Slack API operations with progressive disclosure for optimal context usage.
Context Savings: ~90% reduction
  • MCP Mode: ~15,000 tokens always loaded (30+ tools)
  • Skill Mode: ~500 tokens metadata + on-demand loading
本Skill提供Slack API操作能力,采用渐进式披露实现最优上下文使用。
上下文节省:降低约90%
  • MCP模式:始终加载约15,000 tokens(30+工具)
  • Skill模式:约500 tokens元数据 + 按需加载

Requirements

要求

  • SLACK_BOT_TOKEN environment variable (required)
  • SLACK_SIGNING_SECRET environment variable (optional, for event verification)
  • SLACK_APP_TOKEN environment variable (optional, for Socket Mode)
  • SLACK_BOT_TOKEN 环境变量(必填)
  • SLACK_SIGNING_SECRET 环境变量(选填,用于事件验证)
  • SLACK_APP_TOKEN 环境变量(选填,用于Socket模式)

Setting up Slack Bot Token

配置Slack Bot Token

  1. Create a Slack App at https://api.slack.com/apps
  2. Navigate to "OAuth & Permissions"
  3. Add required bot token scopes:
    • chat:write
      - Send messages
    • channels:read
      - List channels
    • channels:history
      - Read channel history
    • users:read
      - List users
    • files:write
      - Upload files
    • reactions:write
      - Add reactions
  4. Install app to workspace
  5. Copy "Bot User OAuth Token" to
    SLACK_BOT_TOKEN
    environment variable
  1. https://api.slack.com/apps 创建Slack应用
  2. 导航到「OAuth & Permissions」页面
  3. 添加所需的Bot令牌权限范围:
    • chat:write
      - 发送消息
    • channels:read
      - 列出频道
    • channels:history
      - 读取频道历史
    • users:read
      - 列出用户
    • files:write
      - 上传文件
    • reactions:write
      - 添加反应
  4. 将应用安装到工作区
  5. 复制「Bot User OAuth Token」到
    SLACK_BOT_TOKEN
    环境变量

Tools

工具

The skill provides 14 tools across 5 categories:
CategoryToolsConfirmation Required
Messagingpost-message, post-thread, update-message, delete-messageYes (all)
Channelslist-channels, get-channel, channel-historyNo
Userslist-users, get-user, user-presenceNo
Filesupload-file, list-filesYes (upload only)
Reactionsadd-reaction, get-reactionsNo
本Skill提供5个分类下的14个工具:
分类工具列表是否需要确认
消息发送post-message, post-thread, update-message, delete-message全部需要
频道管理list-channels, get-channel, channel-history不需要
用户管理list-users, get-user, user-presence不需要
文件管理upload-file, list-files仅上传需要
表情反应add-reaction, get-reactions不需要

Quick Reference

快速参考

bash
undefined
bash
undefined

Post message to channel

发送消息到频道

curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{"channel": "C1234567890", "text": "Hello from Claude!"}'
curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{"channel": "C1234567890", "text": "Hello from Claude!"}'

List channels

列出频道

curl -X GET "https://slack.com/api/conversations.list"
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
curl -X GET "https://slack.com/api/conversations.list"
-H "Authorization: Bearer $SLACK_BOT_TOKEN"

Upload file

上传文件

curl -X POST https://slack.com/api/files.upload
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-F "channels=C1234567890"
-F "file=@report.pdf"
-F "title=Weekly Report"
undefined
curl -X POST https://slack.com/api/files.upload
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-F "channels=C1234567890"
-F "file=@report.pdf"
-F "title=Weekly Report"
undefined

Tool Details

工具详情

Messaging Tools (Confirmation Required)

消息工具(需确认)

post-message

post-message

Send a message to a Slack channel.
Parameters:
  • channel
    (required): Channel ID or name (e.g., "C1234567890" or "#general")
  • text
    (required): Message text (supports Slack markdown)
  • thread_ts
    (optional): Parent message timestamp for threading
  • blocks
    (optional): Rich message blocks (JSON array)
Example:
bash
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "text": "Deployment successful!",
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*Deployment Status*\n:white_check_mark: Production deployed successfully"
        }
      }
    ]
  }'
发送消息到Slack频道。
参数
  • channel
    (必填):频道ID或名称(例如:"C1234567890" 或 "#general")
  • text
    (必填):消息内容(支持Slack markdown)
  • thread_ts
    (选填):消息所属父线程的时间戳,用于回复线程
  • blocks
    (选填):富消息块(JSON数组)
示例
bash
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "text": "Deployment successful!",
    "blocks": [
      {
        "type": "section",
        "text": {
          "type": "mrkdwn",
          "text": "*Deployment Status*\n:white_check_mark: Production deployed successfully"
        }
      }
    ]
  }'

post-thread

post-thread

Reply to a message in a thread.
Parameters:
  • channel
    (required): Channel ID
  • thread_ts
    (required): Parent message timestamp
  • text
    (required): Reply text
Example:
bash
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "thread_ts": "1234567890.123456",
    "text": "Thread reply here"
  }'
回复线程中的消息。
参数
  • channel
    (必填):频道ID
  • thread_ts
    (必填):父消息时间戳
  • text
    (必填):回复内容
示例
bash
curl -X POST https://slack.com/api/chat.postMessage \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "thread_ts": "1234567890.123456",
    "text": "Thread reply here"
  }'

update-message

update-message

Update an existing message.
Parameters:
  • channel
    (required): Channel ID
  • ts
    (required): Message timestamp
  • text
    (required): New message text
Example:
bash
curl -X POST https://slack.com/api/chat.update \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "ts": "1234567890.123456",
    "text": "Updated message"
  }'
更新已发送的消息。
参数
  • channel
    (必填):频道ID
  • ts
    (必填):消息时间戳
  • text
    (必填):新的消息内容
示例
bash
curl -X POST https://slack.com/api/chat.update \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "ts": "1234567890.123456",
    "text": "Updated message"
  }'

delete-message

delete-message

Delete a message.
Parameters:
  • channel
    (required): Channel ID
  • ts
    (required): Message timestamp
Example:
bash
curl -X POST https://slack.com/api/chat.delete \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "ts": "1234567890.123456"
  }'
删除消息。
参数
  • channel
    (必填):频道ID
  • ts
    (必填):消息时间戳
示例
bash
curl -X POST https://slack.com/api/chat.delete \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "ts": "1234567890.123456"
  }'

Channel Tools

频道工具

list-channels

list-channels

List all channels in workspace.
Parameters:
  • types
    (optional): Comma-separated channel types (default: "public_channel")
    • Options: "public_channel", "private_channel", "mpim", "im"
  • limit
    (optional): Max channels to return (default: 100)
Example:
bash
curl -X GET "https://slack.com/api/conversations.list?types=public_channel,private_channel" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
列出工作区所有频道。
参数
  • types
    (选填):逗号分隔的频道类型(默认:"public_channel")
    • 可选值:"public_channel", "private_channel", "mpim", "im"
  • limit
    (选填):返回的最大频道数量(默认:100)
示例
bash
curl -X GET "https://slack.com/api/conversations.list?types=public_channel,private_channel" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

get-channel

get-channel

Get channel information.
Parameters:
  • channel
    (required): Channel ID
Example:
bash
curl -X GET "https://slack.com/api/conversations.info?channel=C1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
获取频道信息。
参数
  • channel
    (必填):频道ID
示例
bash
curl -X GET "https://slack.com/api/conversations.info?channel=C1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

channel-history

channel-history

Get channel message history.
Parameters:
  • channel
    (required): Channel ID
  • limit
    (optional): Max messages to return (default: 100)
  • oldest
    (optional): Start of time range (Unix timestamp)
  • latest
    (optional): End of time range (Unix timestamp)
Example:
bash
curl -X GET "https://slack.com/api/conversations.history?channel=C1234567890&limit=50" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
Security Note: Channel history may contain sensitive information. Use with caution.
获取频道消息历史。
参数
  • channel
    (必填):频道ID
  • limit
    (选填):返回的最大消息数量(默认:100)
  • oldest
    (选填):时间范围起始值(Unix时间戳)
  • latest
    (选填):时间范围结束值(Unix时间戳)
示例
bash
curl -X GET "https://slack.com/api/conversations.history?channel=C1234567890&limit=50" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
安全提示:频道历史可能包含敏感信息,请谨慎使用。

User Tools

用户工具

list-users

list-users

List all users in workspace.
Parameters:
  • limit
    (optional): Max users to return (default: 100)
Example:
bash
curl -X GET "https://slack.com/api/users.list" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
列出工作区所有用户。
参数
  • limit
    (选填):返回的最大用户数量(默认:100)
示例
bash
curl -X GET "https://slack.com/api/users.list" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

get-user

get-user

Get user profile information.
Parameters:
  • user
    (required): User ID
Example:
bash
curl -X GET "https://slack.com/api/users.info?user=U1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
获取用户资料信息。
参数
  • user
    (必填):用户ID
示例
bash
curl -X GET "https://slack.com/api/users.info?user=U1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

user-presence

user-presence

Get user online status.
Parameters:
  • user
    (required): User ID
Example:
bash
curl -X GET "https://slack.com/api/users.getPresence?user=U1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
获取用户在线状态。
参数
  • user
    (必填):用户ID
示例
bash
curl -X GET "https://slack.com/api/users.getPresence?user=U1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

File Tools

文件工具

upload-file (Confirmation Required)

upload-file(需确认)

Upload a file to Slack channel.
Parameters:
  • channels
    (required): Comma-separated channel IDs
  • file
    (required): File path to upload
  • title
    (optional): File title
  • initial_comment
    (optional): Message text
Example:
bash
curl -X POST https://slack.com/api/files.upload \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -F "channels=C1234567890" \
  -F "file=@C:\reports\weekly.pdf" \
  -F "title=Weekly Report" \
  -F "initial_comment=Here is this week's report"
上传文件到Slack频道。
参数
  • channels
    (必填):逗号分隔的频道ID
  • file
    (必填):待上传文件路径
  • title
    (选填):文件标题
  • initial_comment
    (选填):附带的消息内容
示例
bash
curl -X POST https://slack.com/api/files.upload \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -F "channels=C1234567890" \
  -F "file=@C:\reports\weekly.pdf" \
  -F "title=Weekly Report" \
  -F "initial_comment=Here is this week's report"

list-files

list-files

List files in channel.
Parameters:
  • channel
    (optional): Channel ID to filter by
  • user
    (optional): User ID to filter by
  • count
    (optional): Max files to return (default: 100)
Example:
bash
curl -X GET "https://slack.com/api/files.list?channel=C1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
列出频道中的文件。
参数
  • channel
    (选填):用于过滤的频道ID
  • user
    (选填):用于过滤的用户ID
  • count
    (选填):返回的最大文件数量(默认:100)
示例
bash
curl -X GET "https://slack.com/api/files.list?channel=C1234567890" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

Reaction Tools

表情反应工具

add-reaction

add-reaction

Add emoji reaction to a message.
Parameters:
  • channel
    (required): Channel ID
  • timestamp
    (required): Message timestamp
  • name
    (required): Emoji name (without colons, e.g., "thumbsup")
Example:
bash
curl -X POST https://slack.com/api/reactions.add \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "timestamp": "1234567890.123456",
    "name": "thumbsup"
  }'
为消息添加emoji反应。
参数
  • channel
    (必填):频道ID
  • timestamp
    (必填):消息时间戳
  • name
    (必填):emoji名称(不需要加冒号,例如:"thumbsup")
示例
bash
curl -X POST https://slack.com/api/reactions.add \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "C1234567890",
    "timestamp": "1234567890.123456",
    "name": "thumbsup"
  }'

get-reactions

get-reactions

Get reactions on a message.
Parameters:
  • channel
    (required): Channel ID
  • timestamp
    (required): Message timestamp
Example:
bash
curl -X GET "https://slack.com/api/reactions.get?channel=C1234567890&timestamp=1234567890.123456" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"
获取消息上的反应列表。
参数
  • channel
    (必填):频道ID
  • timestamp
    (必填):消息时间戳
示例
bash
curl -X GET "https://slack.com/api/reactions.get?channel=C1234567890&timestamp=1234567890.123456" \
  -H "Authorization: Bearer $SLACK_BOT_TOKEN"

Agent Integration

Agent集成

Primary Agents

主要适用Agent

  • devops: Infrastructure alerts, deployment notifications, monitoring
  • incident-responder: Incident alerts, status updates, escalations
  • devops:基础设施告警、部署通知、监控提醒
  • incident-responder:事件告警、状态更新、升级通知

Secondary Agents

次要适用Agent

  • pm: Sprint notifications, milestone updates, team announcements
  • developer: Build notifications, PR alerts, test results
  • qa: Test failure alerts, quality reports
  • security-architect: Security alerts, vulnerability notifications
  • pm:迭代通知、里程碑更新、团队公告
  • developer:构建通知、PR提醒、测试结果推送
  • qa:测试失败告警、质量报告推送
  • security-architect:安全告警、漏洞通知

Common Use Cases

常见用例

Deployment Notifications

部署通知

bash
undefined
bash
undefined

Notify channel of successful deployment

通知频道部署成功

curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#deployments", "text": ":rocket: Production deployment completed", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Production Deployment\n:white_check_mark: v1.2.3 deployed successfully\nDuration: 5m 23s" } } ] }'
undefined
curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#deployments", "text": ":rocket: Production deployment completed", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Production Deployment\n:white_check_mark: v1.2.3 deployed successfully\nDuration: 5m 23s" } } ] }'
undefined

Incident Alerts

事件告警

bash
undefined
bash
undefined

Alert on-call team of incident

告警值班团队发生事件

curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#incidents", "text": "<!channel> :rotating_light: High severity incident detected", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Incident INC-1234\n:rotating_light: Severity: P1\nService: API Gateway\nStatus: 503 errors increasing" } } ] }'
undefined
curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#incidents", "text": "<!channel> :rotating_light: High severity incident detected", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Incident INC-1234\n:rotating_light: Severity: P1\nService: API Gateway\nStatus: 503 errors increasing" } } ] }'
undefined

Test Results

测试结果

bash
undefined
bash
undefined

Post test results

推送测试结果

curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#qa", "text": "Test suite completed", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Test Results\n:white_check_mark: 245 passed\n:x: 3 failed\n:warning: 2 skipped" } } ] }'
undefined
curl -X POST https://slack.com/api/chat.postMessage
-H "Authorization: Bearer $SLACK_BOT_TOKEN"
-H "Content-Type: application/json"
-d '{ "channel": "#qa", "text": "Test suite completed", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Test Results\n:white_check_mark: 245 passed\n:x: 3 failed\n:warning: 2 skipped" } } ] }'
undefined

Security Considerations

安全注意事项

Token Security

令牌安全

  • NEVER expose bot token in logs or error messages
  • Store token in environment variable, not in code
  • Use least-privilege scopes for bot token
  • Rotate tokens periodically
  • 绝对不要在日志或错误信息中暴露Bot令牌
  • 将令牌存储在环境变量中,不要硬编码在代码里
  • 为Bot令牌配置最小权限范围
  • 定期轮换令牌

Message Security

消息安全

  • All message operations require confirmation
  • Channel history may contain sensitive information (PII, credentials, etc.)
  • Validate channel permissions before posting
  • Use private channels for sensitive communications
  • 所有消息操作都需要确认
  • 频道历史可能包含敏感信息(PII、凭证等)
  • 发送消息前验证频道权限
  • 敏感沟通使用私有频道

Data Privacy

数据隐私

  • Comply with workspace data retention policies
  • Avoid posting PII or credentials in messages
  • Use Slack's data export features for compliance
  • Respect user privacy and online status
  • 遵守工作区数据保留政策
  • 不要在消息中发送PII或凭证信息
  • 使用Slack的数据导出功能满足合规要求
  • 尊重用户隐私和在线状态

Error Handling

错误处理

Common Errors

常见错误

ErrorCauseSolution
not_authed
Missing or invalid tokenCheck
SLACK_BOT_TOKEN
is set correctly
channel_not_found
Invalid channel IDVerify channel ID with
list-channels
missing_scope
Bot lacks required permissionAdd scope in Slack App settings
rate_limited
Too many requestsImplement exponential backoff
message_not_found
Invalid timestampCheck message timestamp is correct
错误码原因解决方案
not_authed
令牌缺失或无效检查
SLACK_BOT_TOKEN
是否配置正确
channel_not_found
无效的频道ID通过
list-channels
工具验证频道ID
missing_scope
Bot缺少所需权限在Slack应用设置中添加对应的权限范围
rate_limited
请求过多实现指数退避重试策略
message_not_found
无效的时间戳检查消息时间戳是否正确

Retry Strategy

重试策略

For rate limiting errors, implement exponential backoff:
  1. Wait 1 second, retry
  2. Wait 2 seconds, retry
  3. Wait 4 seconds, retry
  4. Wait 8 seconds, retry
  5. Give up after 5 attempts
针对速率限制错误,实现指数退避重试:
  1. 等待1秒后重试
  2. 等待2秒后重试
  3. 等待4秒后重试
  4. 等待8秒后重试
  5. 5次尝试失败后终止重试

Rate Limits

速率限制

Slack API rate limits:
  • Tier 1: 1 request per second
  • Tier 2: 20 requests per minute
  • Tier 3: 50 requests per minute
  • Tier 4: 100 requests per minute
Methods by tier:
  • chat.postMessage
    : Tier 3 (50/min)
  • conversations.list
    : Tier 2 (20/min)
  • users.list
    : Tier 2 (20/min)
  • files.upload
    : Tier 4 (100/min)
Slack API速率限制:
  • Tier 1:每秒1次请求
  • Tier 2:每分钟20次请求
  • Tier 3:每分钟50次请求
  • Tier 4:每分钟100次请求
各接口所属层级:
  • chat.postMessage
    :Tier 3(50次/分钟)
  • conversations.list
    :Tier 2(20次/分钟)
  • users.list
    :Tier 2(20次/分钟)
  • files.upload
    :Tier 4(100次/分钟)

Related

相关链接

Memory Protocol (MANDATORY)

内存协议(强制要求)

Before starting: Read
.claude/context/memory/learnings.md
After completing:
  • New pattern ->
    .claude/context/memory/learnings.md
  • Issue found ->
    .claude/context/memory/issues.md
  • Decision made ->
    .claude/context/memory/decisions.md
ASSUME INTERRUPTION: If it's not in memory, it didn't happen.
开始前: 阅读
.claude/context/memory/learnings.md
完成后:
  • 新的模式 -> 写入
    .claude/context/memory/learnings.md
  • 发现的问题 -> 写入
    .claude/context/memory/issues.md
  • 做出的决策 -> 写入
    .claude/context/memory/decisions.md
假设存在中断风险:未记录在内存中的内容等同于未发生。