agent-slack

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Agent Slack

Agent Slack

A TypeScript CLI tool that enables AI agents and humans to interact with Slack workspaces through a simple command interface. Features seamless token extraction from the Slack desktop app and multi-workspace support.
这是一款TypeScript CLI工具,允许AI Agent和人类通过简单的命令行界面与Slack工作区进行交互。支持从Slack桌面应用无缝提取令牌,同时具备多工作区管理功能。

Quick Start

快速开始

bash
undefined
bash
undefined

Extract credentials from Slack desktop app (zero-config)

Extract credentials from Slack desktop app (zero-config)

agent-slack auth extract
agent-slack auth extract

Get workspace snapshot

Get workspace snapshot

agent-slack snapshot
agent-slack snapshot

Send a message

Send a message

agent-slack message send general "Hello from AI agent!"
agent-slack message send general "Hello from AI agent!"

List channels

List channels

agent-slack channel list
undefined
agent-slack channel list
undefined

Authentication

身份验证

Seamless Token Extraction

无缝令牌提取

agent-slack automatically extracts your Slack credentials from the desktop app:
bash
undefined
agent-slack 可自动从桌面应用中提取你的Slack凭据:
bash
undefined

Just run this - no manual token copying needed

Just run this - no manual token copying needed

agent-slack auth extract
agent-slack auth extract

Use --debug for troubleshooting

Use --debug for troubleshooting

agent-slack auth extract --debug

This command:
- Auto-detects your platform (macOS/Linux/Windows)
- Supports both direct download and App Store versions of Slack on macOS
- Extracts xoxc token and xoxd cookie (with v10 decryption for sandboxed apps)
- Validates tokens against Slack API before saving
- Discovers ALL logged-in workspaces
- Stores credentials securely in `~/.config/agent-messenger/`
agent-slack auth extract --debug

该命令:
- 自动检测你的操作系统(macOS/Linux/Windows)
- 支持macOS平台下直接下载版和App Store版的Slack应用
- 提取xoxc令牌和xoxd Cookie(针对沙箱应用支持v10解密)
- 在保存前验证令牌是否符合Slack API要求
- 发现所有已登录的工作区
- 将凭据安全存储在`~/.config/agent-messenger/`目录下

Multi-Workspace Support

多工作区支持

bash
undefined
bash
undefined

List all authenticated workspaces

List all authenticated workspaces

agent-slack workspace list
agent-slack workspace list

Switch to a different workspace

Switch to a different workspace

agent-slack workspace switch <workspace-id>
agent-slack workspace switch <workspace-id>

Show current workspace

Show current workspace

agent-slack workspace current
agent-slack workspace current

Check auth status

Check auth status

agent-slack auth status
undefined
agent-slack auth status
undefined

Commands

命令列表

Message Commands

消息相关命令

bash
undefined
bash
undefined

Send a message

Send a message

agent-slack message send <channel> <text> agent-slack message send general "Hello world"
agent-slack message send <channel> <text> agent-slack message send general "Hello world"

Send a threaded reply

Send a threaded reply

agent-slack message send general "Reply" --thread <ts>
agent-slack message send general "Reply" --thread <ts>

List messages

List messages

agent-slack message list <channel> agent-slack message list general --limit 50
agent-slack message list <channel> agent-slack message list general --limit 50

Search messages across workspace

Search messages across workspace

agent-slack message search <query> agent-slack message search "project update" agent-slack message search "from:@user deadline" --limit 50 agent-slack message search "in:#general meeting" --sort timestamp
agent-slack message search <query> agent-slack message search "project update" agent-slack message search "from:@user deadline" --limit 50 agent-slack message search "in:#general meeting" --sort timestamp

Get a single message by timestamp

Get a single message by timestamp

agent-slack message get <channel> <ts> agent-slack message get general 1234567890.123456
agent-slack message get <channel> <ts> agent-slack message get general 1234567890.123456

Get thread replies (includes parent message)

Get thread replies (includes parent message)

agent-slack message replies <channel> <thread_ts> agent-slack message replies general 1234567890.123456 agent-slack message replies general 1234567890.123456 --limit 50 agent-slack message replies general 1234567890.123456 --oldest 1234567890.000000 agent-slack message replies general 1234567890.123456 --cursor <next_cursor>
agent-slack message replies <channel> <thread_ts> agent-slack message replies general 1234567890.123456 agent-slack message replies general 1234567890.123456 --limit 50 agent-slack message replies general 1234567890.123456 --oldest 1234567890.000000 agent-slack message replies general 1234567890.123456 --cursor <next_cursor>

Update a message

Update a message

agent-slack message update <channel> <ts> <new-text>
agent-slack message update <channel> <ts> <new-text>

Delete a message

Delete a message

agent-slack message delete <channel> <ts> --force
undefined
agent-slack message delete <channel> <ts> --force
undefined

Channel Commands

频道相关命令

bash
undefined
bash
undefined

List channels (excludes archived by default)

List channels (excludes archived by default)

agent-slack channel list agent-slack channel list --type public agent-slack channel list --type private agent-slack channel list --include-archived
agent-slack channel list agent-slack channel list --type public agent-slack channel list --type private agent-slack channel list --include-archived

Get channel info

Get channel info

agent-slack channel info <channel> agent-slack channel info general
agent-slack channel info <channel> agent-slack channel info general

Get channel history (alias for message list)

Get channel history (alias for message list)

agent-slack channel history <channel> --limit 100
undefined
agent-slack channel history <channel> --limit 100
undefined

User Commands

用户相关命令

bash
undefined
bash
undefined

List users

List users

agent-slack user list agent-slack user list --include-bots
agent-slack user list agent-slack user list --include-bots

Get user info

Get user info

agent-slack user info <user>
agent-slack user info <user>

Get current user

Get current user

agent-slack user me
undefined
agent-slack user me
undefined

Reaction Commands

表情反应相关命令

bash
undefined
bash
undefined

Add reaction

Add reaction

agent-slack reaction add <channel> <ts> <emoji> agent-slack reaction add general 1234567890.123456 thumbsup
agent-slack reaction add <channel> <ts> <emoji> agent-slack reaction add general 1234567890.123456 thumbsup

Remove reaction

Remove reaction

agent-slack reaction remove <channel> <ts> <emoji>
agent-slack reaction remove <channel> <ts> <emoji>

List reactions on a message

List reactions on a message

agent-slack reaction list <channel> <ts>
undefined
agent-slack reaction list <channel> <ts>
undefined

File Commands

文件相关命令

bash
undefined
bash
undefined

Upload file

Upload file

agent-slack file upload <channel> <path> agent-slack file upload general ./report.pdf
agent-slack file upload <channel> <path> agent-slack file upload general ./report.pdf

List files

List files

agent-slack file list agent-slack file list --channel general
agent-slack file list agent-slack file list --channel general

Get file info

Get file info

agent-slack file info <file-id>
undefined
agent-slack file info <file-id>
undefined

Unread Commands

未读消息相关命令

bash
undefined
bash
undefined

List unread channels

List unread channels

agent-slack unread list agent-slack unread list --pretty
agent-slack unread list agent-slack unread list --pretty

Get unread counts summary

Get unread counts summary

agent-slack unread count
agent-slack unread count

Mark channel as read

Mark channel as read

agent-slack mark read <channel> agent-slack mark read general
undefined
agent-slack mark read <channel> agent-slack mark read general
undefined

Activity Commands

活动相关命令

bash
undefined
bash
undefined

List activity feed (mentions, reactions, replies)

List activity feed (mentions, reactions, replies)

agent-slack activity list agent-slack activity list --limit 50
undefined
agent-slack activity list agent-slack activity list --limit 50
undefined

Saved Items Commands

已保存项目相关命令

bash
undefined
bash
undefined

List saved items

List saved items

agent-slack saved list
agent-slack saved list

Add item to saved

Add item to saved

agent-slack saved add <channel> <ts> agent-slack saved add general 1234567890.123456
agent-slack saved add <channel> <ts> agent-slack saved add general 1234567890.123456

Remove item from saved

Remove item from saved

agent-slack saved remove <channel> <ts>
undefined
agent-slack saved remove <channel> <ts>
undefined

Drafts Commands

草稿相关命令

bash
undefined
bash
undefined

List all drafts

List all drafts

agent-slack drafts list agent-slack drafts list --pretty
undefined
agent-slack drafts list agent-slack drafts list --pretty
undefined

Channel Sections Commands

频道分组相关命令

bash
undefined
bash
undefined

List channel sections (sidebar organization)

List channel sections (sidebar organization)

agent-slack section list agent-slack section list --pretty
undefined
agent-slack section list agent-slack section list --pretty
undefined

Snapshot Command

快照命令

Get comprehensive workspace state for AI agents:
bash
undefined
为AI Agent获取完整的工作区状态:
bash
undefined

Full snapshot

Full snapshot

agent-slack snapshot
agent-slack snapshot

Filtered snapshots

Filtered snapshots

agent-slack snapshot --channels-only agent-slack snapshot --users-only
agent-slack snapshot --channels-only agent-slack snapshot --users-only

Limit messages per channel

Limit messages per channel

agent-slack snapshot --limit 10

Returns JSON with:
- Workspace metadata
- Channels (id, name, topic, purpose)
- Recent messages (ts, text, user, channel)
- Users (id, name, profile)
agent-slack snapshot --limit 10

返回的JSON包含:
- 工作区元数据
- 频道信息(ID、名称、主题、用途)
- 近期消息(时间戳、内容、发送者、频道)
- 用户信息(ID、名称、个人资料)

Output Format

输出格式

JSON (Default)

JSON(默认)

All commands output JSON by default for AI consumption:
json
{
  "ts": "1234567890.123456",
  "text": "Hello world",
  "channel": "C123456"
}
所有命令默认输出JSON格式,方便AI处理:
json
{
  "ts": "1234567890.123456",
  "text": "Hello world",
  "channel": "C123456"
}

Pretty (Human-Readable)

格式化输出(人类可读)

Use
--pretty
flag for formatted output:
bash
agent-slack channel list --pretty
使用
--pretty
参数获取格式化后的输出:
bash
agent-slack channel list --pretty

Common Patterns

常见使用场景

See
references/common-patterns.md
for typical AI agent workflows.
查看
references/common-patterns.md
获取典型AI Agent工作流示例。

Templates

模板

See
templates/
directory for runnable examples:
  • post-message.sh
    - Send messages with error handling
  • monitor-channel.sh
    - Monitor channel for new messages
  • workspace-summary.sh
    - Generate workspace summary
查看
templates/
目录获取可运行的示例:
  • post-message.sh
    - 包含错误处理的消息发送脚本
  • monitor-channel.sh
    - 频道新消息监控脚本
  • workspace-summary.sh
    - 工作区摘要生成脚本

Error Handling

错误处理

All commands return consistent error format:
json
{
  "error": "No workspace authenticated. Run: agent-slack auth extract"
}
Common errors:
  • NO_WORKSPACE
    : No authenticated workspace
  • SLACK_API_ERROR
    : Slack API returned an error
  • RATE_LIMIT
    : Hit Slack rate limit (auto-retries with backoff)
所有命令返回统一的错误格式:
json
{
  "error": "No workspace authenticated. Run: agent-slack auth extract"
}
常见错误类型:
  • NO_WORKSPACE
    : 未认证任何工作区
  • SLACK_API_ERROR
    : Slack API返回错误
  • RATE_LIMIT
    : 触发Slack速率限制(会自动重试并带有退避机制)

Configuration

配置说明

Credentials stored in:
~/.config/agent-messenger/slack-credentials.json
Format:
json
{
  "current_workspace": "T123456",
  "workspaces": {
    "T123456": {
      "workspace_id": "T123456",
      "workspace_name": "My Workspace",
      "token": "xoxc-...",
      "cookie": "xoxd-..."
    }
  }
}
Security: File permissions set to 0600 (owner read/write only)
凭据存储路径:
~/.config/agent-messenger/slack-credentials.json
格式:
json
{
  "current_workspace": "T123456",
  "workspaces": {
    "T123456": {
      "workspace_id": "T123456",
      "workspace_name": "My Workspace",
      "token": "xoxc-...",
      "cookie": "xoxd-..."
    }
  }
}
安全性:文件权限设置为0600(仅所有者可读可写)

Limitations

局限性

  • No real-time events / Socket Mode
  • No channel management (create/archive)
  • No workspace admin operations
  • No scheduled messages
  • No user presence features
  • Plain text messages only (no blocks/formatting in v1)
  • 不支持实时事件/Socket模式
  • 不支持频道管理(创建/归档)
  • 不支持工作区管理员操作
  • 不支持定时消息
  • 不支持用户在线状态功能
  • 仅支持纯文本消息(v1版本不支持块/格式化内容)

Troubleshooting

故障排除

agent-slack: command not found

agent-slack: command not found

The
agent-messenger
package is not installed. Run it directly using a package runner. Ask the user which one to use:
bash
npx -p agent-messenger agent-slack ...
bunx -p agent-messenger agent-slack ...
pnpm dlx --package agent-messenger agent-slack ...
If you already know the user's preferred package runner, use it directly instead of asking.
未安装
agent-messenger
包。可通过包运行器直接执行。询问用户使用的包运行器:
bash
npx -p agent-messenger agent-slack ...
bunx -p agent-messenger agent-slack ...
pnpm dlx --package agent-messenger agent-slack ...
若已知用户偏好的包运行器,可直接使用对应命令,无需询问。

References

参考文档

  • Authentication Guide
  • Common Patterns
  • Authentication Guide
  • Common Patterns