Skip to content

feat: Slack adapter — bring agent-broker to Slack workspaces #93

@chaodu-agent

Description

@chaodu-agent

Summary

Add a Slack adapter to agent-broker, allowing teams to interact with ACP-compatible agents (Kiro CLI, Claude Code, Codex, Gemini) directly from Slack channels and threads.

Motivation

Proposed Architecture

┌──────────────┐  Slack Events API  ┌──────────────┐  ACP stdio    ┌──────────────┐
│   Slack      │◄──────────────────►│ agent-broker │──────────────►│  coding CLI  │
│   User       │                    │  (Rust)      │◄── JSON-RPC ──│  (acp mode)  │
└──────────────┘                    └──────────────┘               └──────────────┘

Adapter Abstraction

To support multiple platforms cleanly, agent-broker should introduce a ChatAdapter trait:

#[async_trait]
trait ChatAdapter {
    async fn start(&self, pool: Arc<SessionPool>) -> Result<()>;
    async fn send_message(&self, channel: &str, content: &str) -> Result<()>;
    async fn edit_message(&self, channel: &str, msg_id: &str, content: &str) -> Result<()>;
    async fn create_thread(&self, channel: &str, title: &str) -> Result<String>;
    async fn add_reaction(&self, channel: &str, msg_id: &str, emoji: &str) -> Result<()>;
}

Discord, Telegram (#86), and Slack would each implement this trait. The session pool and ACP layer remain unchanged.

Slack-Specific Design

Feature Slack Implementation
Trigger @mention in allowed channels
Threading Slack native threads (reply_broadcast optional)
Streaming Edit message in thread every ~1.5s (same as Discord)
Reactions Slack emoji reactions for status (👀→🤔→🔥→✅)
Auth Slack Bot Token + App-Level Token (Socket Mode)
Channel allowlist Slack channel IDs in allowed_channels

Config Example

[slack]
bot_token = "${SLACK_BOT_TOKEN}"
app_token = "${SLACK_APP_TOKEN}"       # for Socket Mode
allowed_channels = ["C1234567890"]

[agent]
command = "kiro-cli"
args = ["acp", "--trust-all-tools"]
working_dir = "/home/agent"

Connection Mode Options

  1. Socket Mode (recommended) — no public URL needed, works behind firewalls, similar to Discord Gateway WebSocket
  2. Events API + HTTP — requires a public endpoint, more complex but supports higher scale

Socket Mode is the natural fit since it mirrors how the Discord adapter works (persistent WebSocket connection).

Implementation Steps

  1. Abstract ChatAdapter trait from current Discord implementation
  2. Refactor Discord handler to implement the trait
  3. Implement Slack adapter using slack-morphism or similar Rust Slack SDK
  4. Add config section for Slack ([slack] block)
  5. Select adapter at startup based on which config section is present
  6. Add Dockerfile variant and Helm values for Slack deployment

Slack Bot Permissions (Scopes)

  • app_mentions:read — detect @mentions
  • chat:write — send messages
  • channels:history — read channel messages
  • reactions:write — add emoji reactions
  • channels:read — list channels for validation

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurep2Medium — planned work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions