agent-slack

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Slack automation with
agent-slack

基于
agent-slack
的Slack自动化

agent-slack
is a CLI binary installed on
$PATH
. Invoke it directly (e.g.
agent-slack user list
)
agent-slack
是一个安装在
$PATH
中的CLI二进制文件。可以直接调用(例如
agent-slack user list

Quick start (auth)

快速开始(认证)

Authentication is automatic on macOS (Slack Desktop first, then Chrome fallback).
If credentials aren’t available, run one of:
  • Slack Desktop (default):
bash
agent-slack auth import-desktop
agent-slack auth test
  • Chrome fallback:
bash
agent-slack auth import-chrome
agent-slack auth test
  • Or set env vars (browser tokens; avoid pasting these into chat logs):
bash
export SLACK_TOKEN="xoxc-..."
export SLACK_COOKIE_D="xoxd-..."
agent-slack auth test
  • Or set a standard token:
bash
export SLACK_TOKEN="xoxb-..."  # or xoxp-...
agent-slack auth test
Check configured workspaces:
bash
agent-slack auth whoami
在macOS系统上认证是自动完成的(优先使用Slack桌面客户端,其次是Chrome浏览器作为备选)。
如果无法获取凭证,请运行以下命令之一:
  • Slack桌面客户端(默认方式):
bash
agent-slack auth import-desktop
agent-slack auth test
  • Chrome浏览器备选方案:
bash
agent-slack auth import-chrome
agent-slack auth test
  • 或者设置环境变量(浏览器令牌;请勿将这些内容粘贴到聊天记录中):
bash
export SLACK_TOKEN="xoxc-..."
export SLACK_COOKIE_D="xoxd-..."
agent-slack auth test
  • 或者设置标准令牌:
bash
export SLACK_TOKEN="xoxb-..."  # 或xoxp-...
agent-slack auth test
查看已配置的工作区:
bash
agent-slack auth whoami

Canonical workflow (given a Slack message URL)

标准工作流(给定Slack消息URL)

  1. Fetch a single message (plus thread summary, if any):
bash
agent-slack message get "https://workspace.slack.com/archives/C123/p1700000000000000"
  1. If you need the full thread:
bash
agent-slack message list "https://workspace.slack.com/archives/C123/p1700000000000000"
  1. 获取单条消息(如有线程则包含线程摘要):
bash
agent-slack message get "https://workspace.slack.com/archives/C123/p1700000000000000"
  1. 如果需要完整线程内容:
bash
agent-slack message list "https://workspace.slack.com/archives/C123/p1700000000000000"

Attachments (snippets/images/files)

附件(代码片段/图片/文件)

message get/list
and
search
auto-download attachments and include absolute paths in JSON output (typically under
message.files[].path
/
files[].path
).
message get/list
search
命令会自动下载附件,并在JSON输出中包含绝对路径(通常位于
message.files[].path
/
files[].path
下)。

Reply or react (does the right thing)

回复或添加反应(智能适配场景)

bash
agent-slack message send "https://workspace.slack.com/archives/C123/p1700000000000000" "I can take this."
agent-slack message react add "https://workspace.slack.com/archives/C123/p1700000000000000" "eyes"
agent-slack message react remove "https://workspace.slack.com/archives/C123/p1700000000000000" "eyes"
bash
agent-slack message send "https://workspace.slack.com/archives/C123/p1700000000000000" "I can take this."
agent-slack message react add "https://workspace.slack.com/archives/C123/p1700000000000000" "eyes"
agent-slack message react remove "https://workspace.slack.com/archives/C123/p1700000000000000" "eyes"

Search (messages + files)

搜索(消息+文件)

Prefer channel-scoped search for reliability:
bash
agent-slack search all "smoke tests failed" --channel "#alerts" --after 2026-01-01 --before 2026-02-01
agent-slack search messages "stably test" --user "@alice" --channel general
agent-slack search files "testing" --content-type snippet --limit 10
建议使用频道范围的搜索以确保可靠性:
bash
agent-slack search all "smoke tests failed" --channel "#alerts" --after 2026-01-01 --before 2026-02-01
agent-slack search messages "stably test" --user "@alice" --channel general
agent-slack search files "testing" --content-type snippet --limit 10

Multi-workspace guardrail (important)

多工作区防护机制(重要)

If you have multiple workspaces configured and you use a channel name (
#general
/
general
), pass
--workspace
(or set
SLACK_WORKSPACE_URL
) to avoid ambiguity:
bash
agent-slack message get "#general" --workspace "https://myteam.slack.com" --ts "1770165109.628379"
如果您配置了多个工作区,且使用频道名称
#general
/
general
),请传递
--workspace
参数(或设置
SLACK_WORKSPACE_URL
环境变量)以避免歧义:
bash
agent-slack message get "#general" --workspace "https://myteam.slack.com" --ts "1770165109.628379"

Canvas + Users

Canvas与用户管理

bash
agent-slack canvas get "https://workspace.slack.com/docs/T123/F456"
agent-slack user list --workspace "https://workspace.slack.com" --limit 100
agent-slack user get "@alice" --workspace "https://workspace.slack.com"
bash
agent-slack canvas get "https://workspace.slack.com/docs/T123/F456"
agent-slack user list --workspace "https://workspace.slack.com" --limit 100
agent-slack user get "@alice" --workspace "https://workspace.slack.com"

References

参考文档

  • references/commands.md: full command map + all flags
  • references/targets.md: URL vs
    #channel
    targeting rules
  • references/output.md: JSON output shapes + download paths
  • references/commands.md:完整命令映射及所有参数说明
  • references/targets.md:URL与
    #channel
    目标定位规则
  • references/output.md:JSON输出格式及下载路径说明