Build

Agent messaging

Agent messaging lets an agent answer messages without starting a loop run. Use it when the work is conversational: support triage, team chat, field questions, coaching, or any task where the next user message matters.

It works for internal business operations and product backends. A team can talk to an agent from Slack or Telegram. Your SaaS app can call the same session runtime through the API for a customer-facing assistant.

Agent messaging and loops are coequal ways to use agents:

SurfaceUse it forDurable record
Agent messagingOpen-ended conversations from Slack, Telegram, or your API.Agent session
LoopsVersioned processes with triggers, steps, waits, and bounds.Run

Use messaging when a person should be able to keep talking. Use a loop when the agent should follow a repeatable process.

Entry points

Mobius supports three messaging entry points:

Entry pointHow it startsUse when
SlackA connected Slack workspace routes direct messages, mentions, or selected channel messages to an agent.The agent should work where the team already talks.
TelegramA connected Telegram bot routes bot messages or group conversations to an agent.The agent should answer from a Telegram bot.
APIYour backend calls POST /v1/projects/{project}/agents/invoke.You are embedding an agent in your own product or service.

Slack and Telegram use messaging bindings on the agent. The API can call the same session and turn runtime directly.

What happens

  1. A message arrives from Slack, Telegram, or your API.
  2. Mobius resolves the target agent.
  3. Mobius resolves or creates a session for that conversation.
  4. The agent runs one turn and writes to the session transcript.
  5. Slack or Telegram replies in the original conversation, or your API streams the turn back to your client.

The session transcript is the source of truth. A provider delivery can fail, but the session still records what the agent produced.

Messaging bindings

A messaging binding connects one agent to one provider integration. Bindings decide which conversations can activate the agent:

  • direct messages,
  • mentions,
  • all messages in selected conversations,
  • sender allowlists,
  • conversation allowlists,
  • per-binding model route,
  • per-binding compaction policy.

Keep bindings narrow at first. Start with direct messages or mentions in one channel, then widen once the agent is useful.

Save a binding from the CLI. Put the binding in slack-binding.json:

{
  "provider": "slack",
  "integration_id": "int_slack_7x3m9q2v5p8n4r6t",
  "enabled": true,
  "dms": true,
  "mentions": true,
  "all_messages": false,
  "channels": ["C0123456789"],
  "dm_policy": "open",
  "reply_mode": "auto"
}

Then apply it to the agent:

mobius agents save-messaging-binding agt_support \
  --project platform \
  --file slack-binding.json

Use the same command with provider: "telegram" for Telegram bindings.

API messaging

For your own app, call the compound invoke endpoint. The CLI exposes it as mobius sessions invoke-agent; SDKs and raw HTTP clients use POST /v1/projects/{project}/agents/invoke.

Save the request as support-message.json:

{
  "agent_ref": {
    "id": "agt_support"
  },
  "session": {
    "mode": "continue_or_create",
    "session_key": "app:acct_123:user_456:support",
    "title": "Support chat",
    "metadata": {
      "account_id": "acct_123",
      "user_id": "user_456"
    }
  },
  "input": {
    "content": [
      {
        "type": "text",
        "text": "Can you summarize my open tickets?"
      }
    ],
    "idempotency_key": "msg_01J8..."
  }
}

Invoke the agent:

mobius sessions invoke-agent \
  --project platform \
  --file support-message.json

By default the response is accepted with an after_sequence cursor. Open the session stream with that cursor to follow the turn:

mobius sessions stream ses_01... \
  --project platform \
  --after-sequence N

Raw HTTP clients can request text/event-stream from the invoke endpoint when they need the turn streamed inline.

When your API is relaying a Slack or Telegram webhook, include channel_context with the provider, channel, and thread IDs. Mobius stores that routing context on the turn so support views can trace the transcript back to the provider conversation.

When to use a loop instead

Use a loop when the work needs a declared process: a schedule, an event trigger, ordered steps, approval gates, retries, budgets, or cleanup. Messaging can still start follow-up work. New session messages emit session.message.created source events, so a conversation can trigger a loop when it needs a more structured path.

  • Agent sessions explains transcripts, turns, streaming, and compaction.
  • Agents define instructions, tools, roles, and default model behavior.
  • Slack connects workspace messages to agents.
  • Telegram connects bot messages to agents.
  • API Introduction covers authentication and API conventions.