Slack Web API Skill
Use this skill to run Slack Web API operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, auth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://slack.com/api. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/slack-openapi-skill/references/slack-web.openapi.json
- - A Slack bot token and, for selected thread/history reads, an optional user token.
Scope
This skill covers a Messaging Core surface:
- - auth validation
- channel lookup and inspection
- conversation history reads
- thread replies reads
- posting messages, including replies via INLINECODE6
- adding reactions
This skill does not cover:
- - Slack OAuth app installation flow
- file upload flows
- INLINECODE7 ,
admin.*, or usergroups.* method families
Subscribe / Socket Mode Status
Slack inbound events can be delivered through Socket Mode. uxc now has a built-in Slack Socket Mode transport, but this skill still treats it as a limited event-ingest path rather than a fully packaged workflow surface.
Current uxc subscribe status:
- - Slack Web API request/response calls are supported by this skill
- a live Socket Mode smoke test succeeded with the built-in transport:
-
uxc subscribe start https://slack.com/api --transport slack-socket-mode --auth slack-app --sink file:...
- the runtime opened a fresh temporary WebSocket URL automatically
- the initial Slack
hello frame was received
- - a real inbound message event was validated end-to-end:
- while the Socket Mode job was running, a live Slack message event was delivered as an
events_api envelope
- the sink recorded the message payload and INLINECODE15
What the current built-in transport already handles:
- - app-level
xapp-... auth via INLINECODE17 - automatic
apps.connections.open before each connect attempt - raw Socket Mode frame capture
- automatic ack for envelopes that carry INLINECODE19
What is still not packaged:
- - event-shape guidance per subscribed Slack event family
- higher-level workflow packaging for common Slack event intake flows
Slack Socket Mode is now a validated IM subscribe provider at the transport/runtime level.
Authentication
Slack Web API uses Authorization: Bearer <token>.
Token types used in practice:
- -
xoxb-...: Bot User OAuth Token. This is the recommended default for this skill. - INLINECODE22 : User OAuth Token. Use this only when you explicitly want user-token semantics.
- INLINECODE23 : App-level token. Use this for Socket Mode subscribe, not for normal Web API methods.
To create an app-level xapp-... token for Socket Mode:
- 1. Open the target Slack app at INLINECODE25
- Go to INLINECODE26
- Find INLINECODE27
- Generate a token with the
connections:write scope - Enable
Socket Mode in the app configuration before relying on subscribe-based event intake
Option 1: Bot Token (Recommended Default)
Use the Slack Bot User OAuth Token (xoxb-...) for the default binding and for most messaging operations:
CODEBLOCK0
Option 2: User Token (Explicit Override For Selected Reads)
Use a separate Slack User OAuth Token (xoxp-...) when the method requires user-token semantics, especially thread/history access outside bot-accessible conversations:
CODEBLOCK1
Do not bind slack-user by default to the same host/path. Invoke it explicitly when needed:
CODEBLOCK2
If you intentionally want writes to appear as the installing user rather than the bot, you can also invoke write methods with --auth slack-user, but treat that as an explicit override rather than the default path.
Core Workflow
- 1. Use the fixed link command by default:
-
command -v slack-openapi-cli
- If missing, create it:
uxc link slack-openapi-cli https://slack.com/api --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/slack-openapi-skill/references/slack-web.openapi.json
- INLINECODE38
- 2. Inspect operation schema first:
-
slack-openapi-cli get:/auth.test -h
-
slack-openapi-cli get:/conversations.history -h
- INLINECODE41
- 3. Prefer read validation before writes:
-
slack-openapi-cli get:/auth.test
-
slack-openapi-cli get:/conversations.list limit=20 types=public_channel,private_channel
- INLINECODE44
- 4. Execute with key/value or positional JSON:
- key/value:
slack-openapi-cli get:/conversations.history channel=C1234567890 limit=20
- positional JSON:
INLINECODE46
Operation Groups
Read / Lookup
- - INLINECODE47
- INLINECODE48
- INLINECODE49
- INLINECODE50
- INLINECODE51
Messaging / Reactions
- - INLINECODE52
- INLINECODE53
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - Bot token is the recommended default for send and basic read flows.
- Bot token means Slack
Bot User OAuth Token (xoxb-...); do not confuse it with xapp-... app-level tokens. - User token means Slack
User OAuth Token (xoxp-...); use --auth slack-user when you intentionally need user identity or user-token-only reads. - INLINECODE66 has token-type restrictions:
- bot token works for IM and MPIM threads the bot can access
- public/private channel thread reads should use
--auth slack-user
- -
get:/conversations.history only returns conversations visible to the supplied token; a bot token is limited to joined conversations. - Slack rate limits for
conversations.history and conversations.replies vary by app distribution. Slack documents a tighter limit for newly created commercially distributed non-Marketplace apps starting on May 29, 2025; do not assume generic Tier 3 behavior. - Treat
post:/chat.postMessage and post:/reactions.add as write/high-risk operations; require explicit user confirmation before execution. - INLINECODE73 is equivalent to
uxc https://slack.com/api --schema-url <slack_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE75
- Curated OpenAPI schema: INLINECODE76
- Slack Web API docs: https://docs.slack.dev/apis/web-api
- INLINECODE77 : https://docs.slack.dev/reference/methods/chat.postMessage
- INLINECODE78 : https://docs.slack.dev/reference/methods/conversations.history
- INLINECODE79 : https://docs.slack.dev/reference/methods/conversations.replies/
Slack Web API 技能
使用此技能通过 uxc + OpenAPI 运行 Slack Web API 操作。
复用 uxc 技能以获取共享执行、认证和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://slack.com/api 的网络。
- 可访问精选的 OpenAPI 架构 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/slack-openapi-skill/references/slack-web.openapi.json
- - 一个 Slack 机器人令牌,以及用于特定线程/历史读取的可选用户令牌。
范围
此技能涵盖消息核心功能:
- - 认证验证
- 频道查找和检查
- 对话历史读取
- 线程回复读取
- 发布消息,包括通过 thread_ts 回复
- 添加反应
此技能不涵盖:
- - Slack OAuth 应用安装流程
- 文件上传流程
- users.、admin. 或 usergroups.* 方法系列
订阅 / Socket 模式状态
Slack 入站事件可通过 Socket 模式传递。uxc 现在内置了 Slack Socket 模式传输,但此技能仍将其视为有限的事件摄取路径,而非完整打包的工作流界面。
当前 uxc subscribe 状态:
- - 此技能支持 Slack Web API 请求/响应调用
- 使用内置传输成功进行了实时 Socket 模式冒烟测试:
- uxc subscribe start https://slack.com/api --transport slack-socket-mode --auth slack-app --sink file:...
- 运行时自动打开了一个新的临时 WebSocket URL
- 收到了初始的 Slack hello 帧
- 在 Socket 模式作业运行时,一个实时 Slack 消息事件作为 events_api 信封被传递
- 接收器记录了消息负载和 ack_sent=true
当前内置传输已处理的内容:
- - 通过 --auth 进行应用级 xapp-... 认证
- 每次连接尝试前自动进行 apps.connections.open
- 原始 Socket 模式帧捕获
- 自动确认携带 envelope_id 的信封
尚未打包的内容:
- - 每个订阅的 Slack 事件系列的事件形状指导
- 常见 Slack 事件摄取流程的高级工作流打包
Slack Socket 模式现已在传输/运行时级别被验证为 IM 订阅提供者。
认证
Slack Web API 使用 Authorization: Bearer 。
实践中使用的令牌类型:
- - xoxb-...:机器人用户 OAuth 令牌。这是此技能推荐的默认令牌。
- xoxp-...:用户 OAuth 令牌。仅在明确需要用户令牌语义时使用。
- xapp-...:应用级令牌。用于 Socket 模式订阅,不用于常规 Web API 方法。
为 Socket 模式创建应用级 xapp-... 令牌:
- 1. 在 https://api.slack.com/apps 打开目标 Slack 应用
- 进入 基本信息
- 找到 应用级令牌
- 生成具有 connections:write 范围的令牌
- 在依赖基于订阅的事件摄取之前,在应用配置中启用 Socket 模式
选项 1:机器人令牌(推荐默认)
使用 Slack 机器人用户 OAuth 令牌(xoxb-...)作为默认绑定和大多数消息操作:
bash
uxc auth credential set slack-bot \
--auth-type bearer \
--secret-env SLACKBOTTOKEN
uxc auth binding add \
--id slack-bot \
--host slack.com \
--path-prefix /api \
--scheme https \
--credential slack-bot \
--priority 100
选项 2:用户令牌(特定读取的显式覆盖)
当方法需要用户令牌语义时,特别是在机器人可访问对话之外的线程/历史访问,使用单独的 Slack 用户 OAuth 令牌(xoxp-...):
bash
uxc auth credential set slack-user \
--auth-type bearer \
--secret-env SLACKUSERTOKEN
不要默认将 slack-user 绑定到相同的主机/路径。在需要时显式调用它:
bash
uxc auth binding match https://slack.com/api
slack-openapi-cli --auth slack-user get:/conversations.replies channel=C1234567890 ts=1717171717.000100
如果你有意让写入操作显示为安装用户而非机器人,你也可以使用 --auth slack-user 调用写入方法,但将其视为显式覆盖而非默认路径。
核心工作流
- 1. 默认使用固定链接命令:
- command -v slack-openapi-cli
- 如果缺失,创建它:
uxc link slack-openapi-cli https://slack.com/api --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/slack-openapi-skill/references/slack-web.openapi.json
- slack-openapi-cli -h
- 2. 首先检查操作架构:
- slack-openapi-cli get:/auth.test -h
- slack-openapi-cli get:/conversations.history -h
- slack-openapi-cli post:/chat.postMessage -h
- 3. 在写入前优先进行读取验证:
- slack-openapi-cli get:/auth.test
- slack-openapi-cli get:/conversations.list limit=20 types=public
channel,privatechannel
- slack-openapi-cli get:/conversations.info channel=C1234567890
- 4. 使用键/值或位置 JSON 执行:
- 键/值:
slack-openapi-cli get:/conversations.history channel=C1234567890 limit=20
- 位置 JSON:
slack-openapi-cli post:/chat.postMessage {channel:C1234567890,text:来自 UXC 的问候}
操作组
读取/查找
- - get:/auth.test
- get:/conversations.list
- get:/conversations.info
- get:/conversations.history
- get:/conversations.replies
消息/反应
- - post:/chat.postMessage
- post:/reactions.add
护栏
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 机器人令牌是发送和基本读取流程的推荐默认令牌。
- 机器人令牌指 Slack 机器人用户 OAuth 令牌(xoxb-...);不要与 xapp-... 应用级令牌混淆。
- 用户令牌指 Slack 用户 OAuth 令牌(xoxp-...);当你需要用户身份或仅用户令牌读取时,使用 --auth slack-user。
- get:/conversations.replies 有令牌类型限制:
- 机器人令牌适用于机器人可访问的 IM 和 MPIM 线程
- 公共/私有频道线程读取应使用 --auth slack-user
- - get:/conversations.history 仅返回提供的令牌可见的对话;机器人令牌仅限于已加入的对话。
- Slack 对 conversations.history 和 conversations.replies 的速率限制因应用分发而异。Slack 文档指出,从 2025 年 5 月 29 日起,新创建的商业分发非市场应用有更严格的限制;不要假设通用的 Tier 3 行为。
- 将 post:/chat.postMessage 和 post:/reactions.add 视为写入/高风险操作;在执行前需要明确的用户确认。
- slack-openapi-cli ... 等同于 uxc https://slack.com/api --schema-url openapischema> ...。
参考
- - 使用模式:references/usage-patterns.md
- 精选 OpenAPI 架构:references/slack-web.openapi.json
- Slack Web API 文档:https://docs.slack.dev/apis/web-api
- chat.postMessage:https://docs.slack.dev/reference/methods/chat.postMessage
- conversations.history:https://docs.slack.dev/reference/methods/conversations.history
- conversations.replies:https://docs.slack.dev/reference/methods/conversations.replies/