slack-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Slack Automation via Rube MCP

通过Rube MCP实现Slack自动化

Automate Slack workspace operations including messaging, search, channel management, and reaction workflows through Composio's Slack toolkit.
借助Composio的Slack工具包,自动化Slack工作区操作,包括消息发送、搜索、频道管理和消息反应工作流。
工具包文档composio.dev/toolkits/slack

Prerequisites

前提条件

  • Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
  • Active Slack connection via
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    slack
  • Always call
    RUBE_SEARCH_TOOLS
    first to get current tool schemas
  • 已连接Rube MCP(需可使用RUBE_SEARCH_TOOLS)
  • 通过
    RUBE_MANAGE_CONNECTIONS
    使用
    slack
    工具包建立有效的Slack连接
  • 请始终先调用
    RUBE_SEARCH_TOOLS
    以获取当前工具的架构

Setup

设置步骤

Get Rube MCP: Add
https://rube.app/mcp
as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
  1. Verify Rube MCP is available by confirming
    RUBE_SEARCH_TOOLS
    responds
  2. Call
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    slack
  3. If connection is not ACTIVE, follow the returned auth link to complete Slack OAuth
  4. Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加
https://rube.app/mcp
作为MCP服务器。无需API密钥——只需添加该端点即可使用。
  1. 确认
    RUBE_SEARCH_TOOLS
    可正常响应,以此验证Rube MCP是否可用
  2. 调用
    RUBE_MANAGE_CONNECTIONS
    并指定工具包为
    slack
  3. 如果连接状态未显示为ACTIVE,请按照返回的授权链接完成Slack OAuth认证
  4. 在运行任何工作流之前,确认连接状态显示为ACTIVE

Core Workflows

核心工作流

1. Send Messages to Channels

1. 向频道发送消息

When to use: User wants to post a message to a Slack channel or DM
Tool sequence:
  1. SLACK_FIND_CHANNELS
    - Resolve channel name to channel ID [Prerequisite]
  2. SLACK_LIST_ALL_CHANNELS
    - Fallback if FIND_CHANNELS returns empty/ambiguous results [Fallback]
  3. SLACK_FIND_USERS
    - Resolve user for DMs or @mentions [Optional]
  4. SLACK_OPEN_DM
    - Open/reuse a DM channel if messaging a user directly [Optional]
  5. SLACK_SEND_MESSAGE
    - Post the message with resolved channel ID [Required]
  6. SLACK_UPDATES_A_SLACK_MESSAGE
    - Edit the posted message if corrections needed [Optional]
Key parameters:
  • channel
    : Channel ID or name (without '#' prefix)
  • markdown_text
    : Preferred field for formatted messages (supports headers, bold, italic, code blocks)
  • text
    : Raw text fallback (deprecated in favor of markdown_text)
  • thread_ts
    : Timestamp of parent message to reply in a thread
  • blocks
    : Block Kit layout blocks (deprecated, use markdown_text)
Pitfalls:
  • SLACK_FIND_CHANNELS
    requires
    query
    param; missing it errors with "Invalid request data provided"
  • SLACK_SEND_MESSAGE
    requires valid channel plus one of markdown_text/text/blocks/attachments
  • Invalid block payloads return error=invalid_blocks (max 50 blocks)
  • Replies become top-level posts if
    thread_ts
    is omitted
  • Persist
    response.data.channel
    and
    response.data.message.ts
    from SEND_MESSAGE for edit/thread operations
适用场景:用户需要向Slack频道或私信发送消息
工具执行顺序:
  1. SLACK_FIND_CHANNELS
    - 将频道名称解析为频道ID [前置步骤]
  2. SLACK_LIST_ALL_CHANNELS
    - 当FIND_CHANNELS返回空结果或模糊结果时作为备选方案 [备选]
  3. SLACK_FIND_USERS
    - 解析用户ID以用于私信或@提及 [可选]
  4. SLACK_OPEN_DM
    - 如果直接向用户发送消息,打开或复用私信频道 [可选]
  5. SLACK_SEND_MESSAGE
    - 使用解析后的频道ID发送消息 [必填]
  6. SLACK_UPDATES_A_SLACK_MESSAGE
    - 如果需要修正内容,编辑已发送的消息 [可选]
关键参数:
  • channel
    : 频道ID或名称(无需添加#前缀)
  • markdown_text
    : 格式化消息的首选字段(支持标题、粗体、斜体、代码块)
  • text
    : 纯文本备选字段(已弃用,建议使用markdown_text)
  • thread_ts
    : 父消息的时间戳,用于在线程中回复
  • blocks
    : Block Kit布局块(已弃用,建议使用markdown_text)
注意事项:
  • SLACK_FIND_CHANNELS
    需要传入
    query
    参数;若缺失会返回错误"Invalid request data provided"
  • SLACK_SEND_MESSAGE
    需要有效的频道ID,且必须传入markdown_text/text/blocks/attachments中的至少一个
  • 无效的block负载会返回error=invalid_blocks错误(最多支持50个blocks)
  • 如果省略
    thread_ts
    ,回复会成为顶级消息
  • 请保存
    SLACK_SEND_MESSAGE
    返回结果中的
    response.data.channel
    response.data.message.ts
    ,用于后续的编辑或线程操作

2. Search Messages and Conversations

2. 搜索消息和对话

When to use: User wants to find specific messages across the workspace
Tool sequence:
  1. SLACK_FIND_CHANNELS
    - Resolve channel for scoped search with
    in:#channel
    [Optional]
  2. SLACK_FIND_USERS
    - Resolve user for author filter with
    from:@user
    [Optional]
  3. SLACK_SEARCH_MESSAGES
    - Run keyword search across accessible conversations [Required]
  4. SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    - Expand threads for relevant hits [Required]
Key parameters:
  • query
    : Search string supporting modifiers (
    in:#channel
    ,
    from:@user
    ,
    before:YYYY-MM-DD
    ,
    after:YYYY-MM-DD
    ,
    has:link
    ,
    has:file
    )
  • count
    : Results per page (max 100), or total with auto_paginate=true
  • sort
    : 'score' (relevance) or 'timestamp' (chronological)
  • sort_dir
    : 'asc' or 'desc'
Pitfalls:
  • Validation fails if
    query
    is missing/empty
  • ok=true
    can still mean no hits (
    response.data.messages.total=0
    )
  • Matches are under
    response.data.messages.matches
    (sometimes also
    response.data_preview.messages.matches
    )
  • match.text
    may be empty/truncated; key info can appear in
    matches[].attachments[]
  • Thread expansion via FETCH_MESSAGE_THREAD can truncate when
    response.data.has_more=true
    ; paginate via
    response_metadata.next_cursor
适用场景:用户需要在工作区中查找特定消息
工具执行顺序:
  1. SLACK_FIND_CHANNELS
    - 解析频道ID,用于限定搜索范围(使用
    in:#channel
    修饰符)[可选]
  2. SLACK_FIND_USERS
    - 解析用户ID,用于按作者过滤(使用
    from:@user
    修饰符)[可选]
  3. SLACK_SEARCH_MESSAGES
    - 在可访问的对话中执行关键词搜索 [必填]
  4. SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    - 展开相关结果的线程对话 [必填]
关键参数:
  • query
    : 搜索字符串,支持修饰符(
    in:#channel
    from:@user
    before:YYYY-MM-DD
    after:YYYY-MM-DD
    has:link
    has:file
  • count
    : 每页结果数量(最多100条),或设置auto_paginate=true获取全部结果
  • sort
    : 排序方式,可选'score'(按相关性)或'timestamp'(按时间顺序)
  • sort_dir
    : 排序方向,可选'asc'(升序)或'desc'(降序)
注意事项:
  • 如果
    query
    缺失或为空,验证会失败
  • 即使返回
    ok=true
    ,也可能没有匹配结果(
    response.data.messages.total=0
  • 匹配结果位于
    response.data.messages.matches
    中(有时也会出现在
    response.data_preview.messages.matches
  • match.text
    可能为空或被截断;关键信息可能出现在
    matches[].attachments[]
  • response.data.has_more=true
    时,通过
    SLACK_FETCH_MESSAGE_THREAD
    展开线程会被截断;需使用
    response_metadata.next_cursor
    进行分页

3. Manage Channels and Users

3. 管理频道和用户

When to use: User wants to list channels, users, or workspace info
Tool sequence:
  1. SLACK_FETCH_TEAM_INFO
    - Validate connectivity and get workspace identity [Required]
  2. SLACK_LIST_ALL_CHANNELS
    - Enumerate public channels [Required]
  3. SLACK_LIST_CONVERSATIONS
    - Include private channels and DMs [Optional]
  4. SLACK_LIST_ALL_USERS
    - List workspace members [Required]
  5. SLACK_RETRIEVE_CONVERSATION_INFORMATION
    - Get detailed channel metadata [Optional]
  6. SLACK_LIST_USER_GROUPS_FOR_TEAM_WITH_OPTIONS
    - List user groups [Optional]
Key parameters:
  • cursor
    : Pagination cursor from
    response_metadata.next_cursor
  • limit
    : Results per page (default varies; set explicitly for large workspaces)
  • types
    : Channel types filter ('public_channel', 'private_channel', 'im', 'mpim')
Pitfalls:
  • Workspace metadata is nested under
    response.data.team
    , not top-level
  • SLACK_LIST_ALL_CHANNELS
    returns public channels only; use
    SLACK_LIST_CONVERSATIONS
    for private/IM coverage
  • SLACK_LIST_ALL_USERS
    can hit HTTP 429 rate limits; honor Retry-After header
  • Always paginate via
    response_metadata.next_cursor
    until empty; de-duplicate by
    id
适用场景:用户需要列出频道、用户或工作区信息
工具执行顺序:
  1. SLACK_FETCH_TEAM_INFO
    - 验证连接状态并获取工作区标识 [必填]
  2. SLACK_LIST_ALL_CHANNELS
    - 枚举公开频道 [必填]
  3. SLACK_LIST_CONVERSATIONS
    - 包含私有频道和私信 [可选]
  4. SLACK_LIST_ALL_USERS
    - 列出工作区成员 [必填]
  5. SLACK_RETRIEVE_CONVERSATION_INFORMATION
    - 获取频道的详细元数据 [可选]
  6. SLACK_LIST_USER_GROUPS_FOR_TEAM_WITH_OPTIONS
    - 用户组列表 [可选]
关键参数:
  • cursor
    : 来自
    response_metadata.next_cursor
    的分页游标
  • limit
    : 每页结果数量(默认值不固定;针对大型工作区请显式设置)
  • types
    : 频道类型过滤器('public_channel'、'private_channel'、'im'、'mpim')
注意事项:
  • 工作区元数据嵌套在
    response.data.team
    下,而非顶层
  • SLACK_LIST_ALL_CHANNELS
    仅返回公开频道;如需获取私有频道/私信,请使用
    SLACK_LIST_CONVERSATIONS
  • SLACK_LIST_ALL_USERS
    可能触发HTTP 429限流;请遵循Retry-After响应头
  • 请始终通过
    response_metadata.next_cursor
    进行分页,直到游标为空;通过
    id
    对跨页结果去重

4. React to and Thread Messages

4. 消息反应与线程对话管理

When to use: User wants to add reactions or manage threaded conversations
Tool sequence:
  1. SLACK_SEARCH_MESSAGES
    or
    SLACK_FETCH_CONVERSATION_HISTORY
    - Find the target message [Prerequisite]
  2. SLACK_ADD_REACTION_TO_AN_ITEM
    - Add an emoji reaction [Required]
  3. SLACK_FETCH_ITEM_REACTIONS
    - List reactions on a message [Optional]
  4. SLACK_REMOVE_REACTION_FROM_ITEM
    - Remove a reaction [Optional]
  5. SLACK_SEND_MESSAGE
    - Reply in thread using
    thread_ts
    [Optional]
  6. SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    - Read full thread [Optional]
Key parameters:
  • channel
    : Channel ID where the message lives
  • timestamp
    /
    ts
    : Message timestamp (unique identifier like '1234567890.123456')
  • name
    : Emoji name without colons (e.g., 'thumbsup', 'wave::skin-tone-3')
  • thread_ts
    : Parent message timestamp for threaded replies
Pitfalls:
  • Reactions require exact channel ID + message timestamp pair
  • Emoji names use Slack's naming convention without colons
  • SLACK_FETCH_CONVERSATION_HISTORY
    only returns main channel timeline, NOT threaded replies
  • Use
    SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    with parent's
    thread_ts
    to get thread replies
适用场景:用户需要添加消息反应或管理线程对话
工具执行顺序:
  1. SLACK_SEARCH_MESSAGES
    SLACK_FETCH_CONVERSATION_HISTORY
    - 找到目标消息 [前置步骤]
  2. SLACK_ADD_REACTION_TO_AN_ITEM
    - 添加表情反应 [必填]
  3. SLACK_FETCH_ITEM_REACTIONS
    - 列出消息上的所有反应 [可选]
  4. SLACK_REMOVE_REACTION_FROM_ITEM
    - 移除反应 [可选]
  5. SLACK_SEND_MESSAGE
    - 使用
    thread_ts
    在线程中回复 [可选]
  6. SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    - 查看完整线程对话 [可选]
关键参数:
  • channel
    : 目标消息所在的频道ID
  • timestamp
    /
    ts
    : 消息的时间戳(唯一标识符,格式如'1234567890.123456')
  • name
    : 表情名称(无需添加冒号,例如'thumbsup'、'wave::skin-tone-3')
  • thread_ts
    : 父消息的时间戳,用于线程回复
注意事项:
  • 添加反应需要准确的频道ID和消息时间戳组合
  • 表情名称需使用Slack的命名规范,无需添加冒号
  • SLACK_FETCH_CONVERSATION_HISTORY
    仅返回频道主时间线的消息,不包含线程回复
  • 需使用
    SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    并传入父消息的
    thread_ts
    来获取线程回复

5. Schedule Messages

5. 消息调度

When to use: User wants to schedule a message for future delivery
Tool sequence:
  1. SLACK_FIND_CHANNELS
    - Resolve channel ID [Prerequisite]
  2. SLACK_SCHEDULE_MESSAGE
    - Schedule the message with
    post_at
    timestamp [Required]
Key parameters:
  • channel
    : Resolved channel ID
  • post_at
    : Unix timestamp for delivery (up to 120 days in advance)
  • text
    /
    blocks
    : Message content
Pitfalls:
  • Scheduling is limited to 120 days in advance
  • post_at
    must be a Unix timestamp, not ISO 8601
适用场景:用户需要调度消息在未来发送
工具执行顺序:
  1. SLACK_FIND_CHANNELS
    - 解析频道ID [前置步骤]
  2. SLACK_SCHEDULE_MESSAGE
    - 使用
    post_at
    时间戳调度消息 [必填]
关键参数:
  • channel
    : 解析后的频道ID
  • post_at
    : 消息发送的Unix时间戳(最多提前120天)
  • text
    /
    blocks
    : 消息内容
注意事项:
  • 消息调度最多支持提前120天
  • post_at
    必须为Unix时间戳,而非ISO 8601格式

Common Patterns

通用模式

ID Resolution

ID解析

Always resolve display names to IDs before operations:
  • Channel name -> Channel ID:
    SLACK_FIND_CHANNELS
    with
    query
    param
  • User name -> User ID:
    SLACK_FIND_USERS
    with
    search_query
    or
    email
  • DM channel:
    SLACK_OPEN_DM
    with resolved user IDs
在执行操作前,请始终将显示名称解析为ID:
  • 频道名称 -> 频道ID:调用
    SLACK_FIND_CHANNELS
    并传入
    query
    参数
  • 用户名称 -> 用户ID:调用
    SLACK_FIND_USERS
    并传入
    search_query
    email
  • 私信频道:调用
    SLACK_OPEN_DM
    并传入解析后的用户ID

Pagination

分页

Most list endpoints use cursor-based pagination:
  • Follow
    response_metadata.next_cursor
    until empty
  • Set explicit
    limit
    values (e.g., 100-200) for reliable paging
  • De-duplicate results by
    id
    across pages
大多数列表接口使用基于游标的分页:
  • 跟随
    response_metadata.next_cursor
    进行分页,直到游标为空
  • 显式设置
    limit
    值(例如100-200)以确保分页可靠
  • 通过
    id
    对跨页结果去重

Message Formatting

消息格式化

  • Prefer
    markdown_text
    over
    text
    or
    blocks
    for formatted messages
  • Use
    <@USER_ID>
    format to mention users (not @username)
  • Use
    \n
    for line breaks in markdown_text
  • 优先使用
    markdown_text
    而非
    text
    blocks
    来格式化消息
  • 使用
    <@USER_ID>
    格式提及用户(而非@用户名)
  • markdown_text
    中使用
    \n
    进行换行

Known Pitfalls

已知注意事项

  • Channel resolution:
    SLACK_FIND_CHANNELS
    can return empty results if channel is private and bot hasn't been invited
  • Rate limits:
    SLACK_LIST_ALL_USERS
    and other list endpoints can hit HTTP 429; honor Retry-After header
  • Nested responses: Results may be nested under
    response.data.results[0].response.data
    in wrapped executions
  • Thread vs channel:
    SLACK_FETCH_CONVERSATION_HISTORY
    returns main timeline only; use
    SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    for thread replies
  • Message editing: Requires both
    channel
    and original message
    ts
    ; persist these from SEND_MESSAGE response
  • Search delays: Recently posted messages may not appear in search results immediately
  • Scope limitations: Missing OAuth scopes can cause 403 errors; check with
    SLACK_GET_APP_PERMISSION_SCOPES
  • 频道解析:如果频道是私有频道且机器人未被邀请,
    SLACK_FIND_CHANNELS
    可能返回空结果
  • 限流
    SLACK_LIST_ALL_USERS
    和其他列表接口可能触发HTTP 429限流;请遵循Retry-After响应头
  • 嵌套响应:在包装执行中,结果可能嵌套在
    response.data.results[0].response.data
  • 线程与频道区别
    SLACK_FETCH_CONVERSATION_HISTORY
    仅返回主时间线消息;需使用
    SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
    获取线程回复
  • 消息编辑:需要同时传入
    channel
    和原消息的
    ts
    ;请从
    SLACK_SEND_MESSAGE
    的返回结果中保存这两个值
  • 搜索延迟:最近发送的消息可能不会立即出现在搜索结果中
  • 权限范围限制:缺失OAuth权限范围会导致403错误;可通过
    SLACK_GET_APP_PERMISSION_SCOPES
    检查权限

Quick Reference

快速参考

TaskTool SlugKey Params
Find channels
SLACK_FIND_CHANNELS
query
List all channels
SLACK_LIST_ALL_CHANNELS
limit
,
cursor
,
types
Send message
SLACK_SEND_MESSAGE
channel
,
markdown_text
Edit message
SLACK_UPDATES_A_SLACK_MESSAGE
channel
,
ts
,
markdown_text
Search messages
SLACK_SEARCH_MESSAGES
query
,
count
,
sort
Get thread
SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
channel
,
ts
Add reaction
SLACK_ADD_REACTION_TO_AN_ITEM
channel
,
name
,
timestamp
Find users
SLACK_FIND_USERS
search_query
or
email
List users
SLACK_LIST_ALL_USERS
limit
,
cursor
Open DM
SLACK_OPEN_DM
user IDs
Schedule message
SLACK_SCHEDULE_MESSAGE
channel
,
post_at
,
text
Get channel info
SLACK_RETRIEVE_CONVERSATION_INFORMATION
channel ID
Channel history
SLACK_FETCH_CONVERSATION_HISTORY
channel
,
oldest
,
latest
Workspace info
SLACK_FETCH_TEAM_INFO
(none)

Powered by Composio
任务工具标识关键参数
查找频道
SLACK_FIND_CHANNELS
query
列出所有频道
SLACK_LIST_ALL_CHANNELS
limit
,
cursor
,
types
发送消息
SLACK_SEND_MESSAGE
channel
,
markdown_text
编辑消息
SLACK_UPDATES_A_SLACK_MESSAGE
channel
,
ts
,
markdown_text
搜索消息
SLACK_SEARCH_MESSAGES
query
,
count
,
sort
获取线程对话
SLACK_FETCH_MESSAGE_THREAD_FROM_A_CONVERSATION
channel
,
ts
添加反应
SLACK_ADD_REACTION_TO_AN_ITEM
channel
,
name
,
timestamp
查找用户
SLACK_FIND_USERS
search_query
email
列出所有用户
SLACK_LIST_ALL_USERS
limit
,
cursor
打开私信
SLACK_OPEN_DM
用户ID
调度消息
SLACK_SCHEDULE_MESSAGE
channel
,
post_at
,
text
获取频道信息
SLACK_RETRIEVE_CONVERSATION_INFORMATION
频道ID
频道历史记录
SLACK_FETCH_CONVERSATION_HISTORY
channel
,
oldest
,
latest
工作区信息
SLACK_FETCH_TEAM_INFO

Composio提供支持