Skip to content

feat: proactive agent messaging to channel users (Telegram / Slack / web) #321

Closed

Description

@vybe

Problem

Trinity agents can only respond to channel messages. They cannot initiate a conversation — there is no way for a scheduled task, a process step, or an agent-to-agent signal to push a message to a specific user on Telegram / Slack / web.

Concretely:

  • telegram_adapter.send_response() only runs inside the inbound pipeline
  • send_notification MCP tool broadcasts to the Trinity WebSocket, not to external channels
  • The announce skill can post to a preconfigured channel via env var, but it is a CLI side-channel, not an agent runtime capability

This blocks real use cases: reminders, monitoring alerts, scheduled reports, follow-ups after long-running work.

Proposed approach

One new MCP tool — send_message — that resolves a recipient by verified email (the identity key from #311) and dispatches through the correct channel adapter.

send_message(
  recipient_email: str,           # verified email; MUST be in agent_sharing OR owner
  text: str,
  channel: \"auto\" | \"telegram\" | \"slack\" | \"web\" = \"auto\",
  reply_to_thread: bool = False,  # continue last thread if one exists
)

Resolution:

  • telegram → look up telegram_chat_links where verified_email = recipient_email AND binding_id belongs to the calling agent
  • slack → look up existing DM channel in slack_channel_agents / slack_active_threads
  • web → WebSocket push + persisted message on public_chat_sessions (user sees it on next load)
  • auto → prefer the channel the user most recently used

Reuse map

Existing primitive Role
agent_sharing (#311) Authorization — recipient must be in the agent's allow-list
telegram_chat_links.verified_email (#311) Telegram recipient resolution
telegram_adapter._send_message() Outbound transport — already battle-tested
slack_service.send_message() Slack transport — already used for auth prompts
MCP auth context (agent_name, scope='agent') Caller identity — agents can only message their own users

What's actually new

  • MCP tool send_message in src/mcp-server/src/tools/ (new module or extend notifications.ts)
  • Backend endpoint POST /api/agents/{name}/messages — does the authorization + channel dispatch
  • Rate limiting (per agent, per recipient) to prevent spam — reuse the adapter-layer limiter
  • Optional: last_active_channel column on agent_sharing or a lightweight user_channel_activity table for auto routing

Authorization rules

  • Agent can only message users where agent_sharing(agent_name, shared_with_email) exists (or the owner)
  • Agent cannot message arbitrary Telegram IDs or Slack users
  • Admin/system scope bypass — needed for platform notifications
  • Rate limit: e.g. 10 proactive messages per recipient per hour, configurable per agent

Open questions

  • Consent: should users opt-in to receive proactive messages, or is being in agent_sharing enough? Leaning: agent_sharing = implicit consent; add a /stop command per channel to revoke.
  • Process Engine integration: the notification step type should grow a channel parameter so scheduled processes can push via this tool.
  • Delivery receipts: do we need callbacks when the user reads the message, or is fire-and-forget fine for v1? (Fire-and-forget v1.)
  • Cost / abuse: should proactive sends count against the agent's cost budget even though they don't invoke the LLM?

Out of scope

  • Group broadcasts (post to every member of a Slack channel) — v2
  • Scheduled messaging primitives (send at X) — already possible via schedules + this tool
  • WhatsApp / SMS channels

Activity

  1. added
    priority-p2
    type-feature
    status-in-progress
    on Apr 13, 2026
  2. removed
    status-in-progress
    on Apr 17, 2026
  3. added
    complexity-medium
    on Jun 3, 2026
  4. added a commit that references this issue on Jul 26, 2026
  5. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p2type-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions