Repository navigation
Closed
Labels
complexity-mediumComplexity: medium (board points 5-8)priority-p1Critical pathtype-featureNew functionality
Description
Summary
Extract a ChannelAdapter interface from the existing Slack integration (src/backend/routers/slack.py) to create a pluggable channel architecture. All external messaging channels (Slack now, Telegram/WhatsApp/Discord later) should implement this common interface.
Context
Trinity already has a working Slack adapter (~590 lines) with OAuth, DM routing, email verification, and session persistence. However, it's a monolithic router with channel-specific logic mixed into business logic. Before adding more channels, we need a clean abstraction layer.
Requirements
Channel Adapter Interface
- Define
ChannelAdapterbase class with standard lifecycle methods:authenticate(request)— Verify incoming webhook/event signaturesparse_message(raw_event) → NormalizedMessage— Extract sender, text, thread, attachmentssend_response(channel_id, message) → None— Deliver formatted responseresolve_user(channel_user) → TrinityIdentity— Map channel user to Trinity user/emailget_session(channel_id, thread_id) → Session— Map channel thread to chat session
- Define
NormalizedMessageschema: sender, text, channel, thread_id, timestamp, attachments, metadata
Message Router
- Central router that receives from any adapter, resolves the target agent, injects context, dispatches to the agent, and routes the response back through the adapter
- Decouple agent execution from channel-specific code
- Channel config per agent in manifest/database: which channel, which thread/channel ID, enabled/disabled
Session Mapping
- Unified session model across channels (extend existing
public_chat_sessionsor createchannel_sessions) - One agent ↔ one persistent thread per client per channel
- Session state: active, paused, closed
What Exists Today
src/backend/routers/slack.py— Reference implementation to decomposesrc/backend/db/public_chat.py— Session persistence patternsrc/backend/routers/chat.py— Core chat execution pipeline
Acceptance Criteria
-
ChannelAdapterbase class defined with documented interface -
SlackAdapterimplements the interface (refactored from currentslack.py) - Central message router dispatches to agents independent of channel
-
NormalizedMessageschema covers Slack's current needs without Slack-specific fields - Per-agent channel configuration (which channels enabled, channel-specific settings)
- Existing Slack functionality preserved — no regressions
- Adding a new channel requires only implementing
ChannelAdapter+ config
Non-Goals
- No new channel implementations in this issue (Telegram, WhatsApp, etc.)
- No UI for channel management (API-only for now)
Metadata
Metadata
Assignees
Labels
complexity-mediumComplexity: medium (board points 5-8)priority-p1Critical pathtype-featureNew functionality
Activity
feat: Channel adapter abstraction with multi-agent Slack support (#63)
fix: Encrypt Slack bot tokens at rest + doc updates (SLACK-002)
feat: Channel adapter abstraction with multi-agent Slack support (#63)
fix: Encrypt Slack bot tokens at rest + doc updates (SLACK-002)
feat: Channel adapter abstraction with multi-agent Slack support (Abi…
fix(slack): use the agent's avatar as the per-message bot icon (#292)
feat(slack): channel identity, proactive messaging, and per-agent bot…