AgentSkillsCN

agent-slack

针对 AI 代理的 Slack 自动化 CLI。适用场景包括: - 读取 Slack 消息或线程(给定 URL 或频道+时间戳) - 将 Slack 附件(代码片段、图片、文件)下载至本地路径 - 搜索 Slack 消息或文件 - 发送回复,或添加/移除表情符号 - 将 Slack 画布以 Markdown 格式获取 - 查找 Slack 用户 触发条件: “Slack 消息”、“Slack 线程”、“Slack URL”、“Slack 链接”、“阅读 Slack”、“在 Slack 上回复”、“搜索 Slack”

SKILL.md
--- frontmatter
name: agent-slack
description: |
  Slack automation CLI for AI agents. Use when:
  - Reading a Slack message or thread (given a URL or channel+ts)
  - Downloading Slack attachments (snippets, images, files) to local paths
  - Searching Slack messages or files
  - Sending a reply or adding/removing a reaction
  - Fetching a Slack canvas as markdown
  - Looking up Slack users
  Triggers: "slack message", "slack thread", "slack URL", "slack link", "read slack", "reply on slack", "search slack"

Slack automation with agent-slack

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

Canonical workflow (given a Slack message 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"

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).

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"

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

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"

Canvas + Users

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