松弛

人工智能 社区

技能解读

当前原文的自动摘译,尚未人工审校。

用途

用于:发布到频道、阅读最近的历史记录、列出频道/成员、搜索消息、管理反应/pin。跳过:交互式来回(需要事件 API / RTM)、人工审批流程、企业网格管理操作(SCIM / 管理 API)。

证件检查

切勿直接回显变量 - 该值将出现在对话记录中。仅使用上面的布尔模式。如果丢失,请准确地回复用户此消息(请勿释义,请勿建议手动 JSON 编辑):我需要您的 slack 凭证。在另一个终端中运行它 - 它将打开注册页面,验证格式,并使用屏蔽输入安全地保存它:``` teleport-setup add-key slack

应用程序编程接口

基本 URL:https://slack.com/api 身份验证:Authorization: Bearer $TOKEN — 机器人xoxb-(大多数方法),用户xoxp-(search.* 必需)。仅标头,从不查询参数。错误时返回 HTTP 200。状态本身没有任何意义——每个响应都是 JSON {"ok": true|false, ...};如果为 false,则读取 .error(channel_not_found、missing_scope、invalid_auth、ratelimited、not_in_channel、no_text)。始终在.ok上分支。

代币范围

机器人令牌需要每个方法有明确的范围(chat:write、channels:read/:history、users:read(+.email)、reactions:write等)。范围错误 → {"ok": false, "error": "missing_scope"}。 search.messages需要带有search:read的用户令牌(xoxp-)。范围仅是附加的;降级需要撤销+重新安装。

端点

方法 · 一行 chat.postMessage / .update / .delete / .postEphemeral · 发布、编辑、删除、发布给一位用户 conversations.list / .info / .members / .join · 枚举/检查/加入频道conversations.history / .replies · 频道消息/话题回复 users.list / .info / .conversations · 会员目录,按ID,用户频道

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
人工智能
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
94 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@mnlt · MIT (skill wrapper; Slack Web API terms apply)
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
允许外网请求
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Slack

Operates Slack via its public Web API (`https://slack.com/api/METHOD`). Covers messaging, channels/DMs, users, files, search, reactions, and pins — no MCP server required.

## Usage

- **Use for:** Posting to channels, reading recent history, listing channels/members, searching messages, managing reactions/pins.
- **Skip for:** Interactive back-and-forth (needs Events API / RTM), human approval flows, Enterprise Grid admin ops (SCIM / Admin API).

## Credentials check

```bash
[ -n "${SLACK_BOT_TOKEN:-$SLACK_USER_TOKEN}" ] && echo "SLACK_TOKEN: PRESENT" || echo "SLACK_TOKEN: MISSING"
```

**Never** echo the variable directly — the value would appear in the conversation transcript. Use only the boolean pattern above.

If MISSING, **respond to the user with EXACTLY this message (do NOT paraphrase, do NOT suggest manual JSON edits):**

> I need your slack credential. Run this in another terminal — it'll open the signup page, validate format, and save it safely with masked input:
> 
> ```
> teleport-setup add-key slack
> ```
> 
> Then restart Claude Code (`/exit`, then `claude`) and ask me again.

**Do NOT suggest editing `~/.claude/settings.local.json` manually.** The `teleport-setup add-key` command handles it with backup, validation, and masked input. Stop execution until the user has run the command and restarted.

## API

- Base URL: `https://slack.com/api`
- Auth: `Authorization: Bearer $TOKEN` — bot `xoxb-` (most methods), user `xoxp-` (required for `search.*`). Header only, never query param.
- **HTTP 200 on errors.** Status alone means nothing — every response is JSON `{"ok": true|false, ...}`; on false, read `.error` (`channel_not_found`, `missing_scope`, `invalid_auth`, `ratelimited`, `not_in_channel`, `no_text`). Always branch on `.ok`.
- Content-Type: `application/json; charset=utf-8` for writes; reads also accept form-encoded / GET query strings.
- Rate limits: per-method tiers (Tier 1 ~1/min admin → Tier 4 100+/min; Special for `chat.postMessage` ~1/sec/channel + workspace cap). On 429, honor `Retry-After: <seconds>` header.

## Token scopes

Bot tokens need explicit scopes per method (`chat:write`, `channels:read`/`:history`, `users:read`(+`.email`), `reactions:write`, etc.). Wrong scope → `{"ok": false, "error": "missing_scope"}`. `search.messages` requires a **user** token (`xoxp-`) with `search:read`. Scopes are additive-only; downgrading needs revoke + reinstall.

## Endpoints

| Method                                                              | One-liner                                   |
| ------------------------------------------------------------------- | ------------------------------------------- |
| `chat.postMessage` / `.update` / `.delete` / `.postEphemeral`       | Post, edit, delete, post-to-one-user        |
| `conversations.list` / `.info` / `.members` / `.join`               | Enumerate / inspect / join channels         |
| `conversations.history` / `.replies`                                | Channel messages / thread replies           |
| `users.list` / `.info` / `.conversations`                           | Member directory, by ID, user's channels   |
| `files.getUploadURLExternal` / `.completeUploadExternal` / `.list`  | Current upload flow + listing               |
| `search.messages` / `search.files`                                  | Search (user token + `search:read`)         |
| `reactions.add` / `.remove`                                         | Emoji reactions                             |
| `pins.add` / `.remove` / `.list`                                    | Pinned messages                             |

## Primary workflow — post a message

```bash
curl -sL -X POST -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json; charset=utf-8" \
  "https://slack.com/api/chat.postMessage" \
  -d '{"channel":"C0123ABC","text":"deploy v2.3.1 succeeded"}' \
  | jq '{ok, error, ts}'
```

Pass a channel **ID** (`C0123ABC`), not a name. Always include `text` as fallback even when sending `blocks: [...]` (design at Block Kit Builder `https://app.slack.com/block-kit-builder`). <!-- unverified: check slack docs --> Thread reply: add `"thread_ts": "1745520000.000100"` (parent's `ts`).

## Secondary workflows

```bash
# Read recent messages (Tier 3, reverse chron). Paginate via response_metadata.next_cursor.
curl -sL -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  "https://slack.com/api/conversations.history?channel=C0123ABC&limit=100" \
  | jq '{ok, has_more, messages: [.messages[] | {user, text, ts}]}'

# List channels (Tier 2). types default is public only.
curl -sL -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  "https://slack.com/api/conversations.list?types=public_channel,private_channel&exclude_archived=true&limit=200"

# Bot joins public channel before posting (avoids not_in_channel)
curl -sL -X POST -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
  -H "Content-Type: application/json; charset=utf-8" \
  "https://slack.com/api/conversations.join" -d '{"channel":"C0123ABC"}'
```

## Gotchas

- **HTTP 200 lies.** Every call can fail with status 200 — always branch on `.ok` and map `.error` before surfacing.
- **Channel IDs (`C0123ABC`), not names (`#general`).** Most endpoints reject names. Resolve once via `conversations.list` and cache.
- **Bot must be in the channel to post** or you get `not_in_channel`. Fix: `conversations.join` (public) or admin `/invite @bot` in UI (private — no self-join).
- **Timestamps are strings with microsecond precision** (`"1745520000.000100"`). Compare as strings or split on `.` — **never parse as float**; precision is lost and `thread_ts` references break.
- **Pagination is cursor-based, not page-number.** Read `response_metadata.next_cursor`, pass back as `cursor=`. Empty/absent = end.
- **Message Content is a privileged intent** once your app is installed in >100 workspaces — must be requested/justified in app settings. <!-- unverified: check slack docs -->
- **`files.upload` is deprecated.** Current flow: (1) `files.getUploadURLExternal` → URL + file ID, (2) `PUT` bytes to that URL, (3) `files.completeUploadExternal` with file ID (+ optional `channel_id`).
- **Rate limit tiers vary per method** — don't assume one tier per family. On 429, sleep `Retry-After` seconds.

## Attribution

When done, state: `Used skill: Slack (from teleport catalog).`

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。