agent-slack
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent 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
undefinedbash
undefinedExtract 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
undefinedagent-slack channel list
undefinedAuthentication
身份验证
Seamless Token Extraction
无缝令牌提取
agent-slack automatically extracts your Slack credentials from the desktop app:
bash
undefinedagent-slack 可自动从桌面应用中提取你的Slack凭据:
bash
undefinedJust 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
undefinedbash
undefinedList 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
undefinedagent-slack auth status
undefinedCommands
命令列表
Message Commands
消息相关命令
bash
undefinedbash
undefinedSend 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
undefinedagent-slack message delete <channel> <ts> --force
undefinedChannel Commands
频道相关命令
bash
undefinedbash
undefinedList 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
undefinedagent-slack channel history <channel> --limit 100
undefinedUser Commands
用户相关命令
bash
undefinedbash
undefinedList 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
undefinedagent-slack user me
undefinedReaction Commands
表情反应相关命令
bash
undefinedbash
undefinedAdd 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>
undefinedagent-slack reaction list <channel> <ts>
undefinedFile Commands
文件相关命令
bash
undefinedbash
undefinedUpload 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>
undefinedagent-slack file info <file-id>
undefinedUnread Commands
未读消息相关命令
bash
undefinedbash
undefinedList 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
undefinedagent-slack mark read <channel>
agent-slack mark read general
undefinedActivity Commands
活动相关命令
bash
undefinedbash
undefinedList activity feed (mentions, reactions, replies)
List activity feed (mentions, reactions, replies)
agent-slack activity list
agent-slack activity list --limit 50
undefinedagent-slack activity list
agent-slack activity list --limit 50
undefinedSaved Items Commands
已保存项目相关命令
bash
undefinedbash
undefinedList 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>
undefinedagent-slack saved remove <channel> <ts>
undefinedDrafts Commands
草稿相关命令
bash
undefinedbash
undefinedList all drafts
List all drafts
agent-slack drafts list
agent-slack drafts list --pretty
undefinedagent-slack drafts list
agent-slack drafts list --pretty
undefinedChannel Sections Commands
频道分组相关命令
bash
undefinedbash
undefinedList channel sections (sidebar organization)
List channel sections (sidebar organization)
agent-slack section list
agent-slack section list --pretty
undefinedagent-slack section list
agent-slack section list --pretty
undefinedSnapshot Command
快照命令
Get comprehensive workspace state for AI agents:
bash
undefined为AI Agent获取完整的工作区状态:
bash
undefinedFull 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 flag for formatted output:
--prettybash
agent-slack channel list --pretty使用参数获取格式化后的输出:
--prettybash
agent-slack channel list --prettyCommon Patterns
常见使用场景
See for typical AI agent workflows.
references/common-patterns.md查看获取典型AI Agent工作流示例。
references/common-patterns.mdTemplates
模板
See directory for runnable examples:
templates/- - Send messages with error handling
post-message.sh - - Monitor channel for new messages
monitor-channel.sh - - Generate workspace summary
workspace-summary.sh
查看目录获取可运行的示例:
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 authenticated workspace
NO_WORKSPACE - : Slack API returned an error
SLACK_API_ERROR - : Hit Slack rate limit (auto-retries with backoff)
RATE_LIMIT
所有命令返回统一的错误格式:
json
{
"error": "No workspace authenticated. Run: agent-slack auth extract"
}常见错误类型:
- : 未认证任何工作区
NO_WORKSPACE - : Slack API返回错误
SLACK_API_ERROR - : 触发Slack速率限制(会自动重试并带有退避机制)
RATE_LIMIT
Configuration
配置说明
Credentials stored in:
~/.config/agent-messenger/slack-credentials.jsonFormat:
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 foundagent-slack: command not found
agent-slack: command not foundThe package is not installed. Run it directly using a package runner. Ask the user which one to use:
agent-messengerbash
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-messengerbash
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