Skip to content

[Bug]: Session replies not routing to Telegram when webchat is also active #5531

@raghavan

Description

@raghavan

Summary

When a session receives messages from both Telegram and webchat, the agent's automatic replies fail to deliver to Telegram — they only appear in webchat. Direct sends via the message tool work correctly.

Environment

  • OpenClaw Version: 2026.1.29 (a5b4d22)
  • OS: macOS 26.3 (arm64)
  • Node: v23.11.0
  • Gateway Mode: local (port 18789, loopback)
  • Model: claude-opus-4-5

Channel Configuration

{
  "channels": {
    "telegram": {
      "enabled": true,
      "dmPolicy": "pairing",
      "groupPolicy": "allowlist",
      "streamMode": "partial"
    }
  },
  "plugins": {
    "entries": {
      "telegram": {
        "enabled": true
      }
    }
  }
}

Steps to Reproduce

  1. Have both webchat and Telegram connected to the same session (agent:main:main)
  2. Send a message from Telegram to the bot
  3. Observe: Message is received by the agent ✅
  4. Agent generates a reply
  5. Expected: Reply delivered to Telegram (originating channel)
  6. Actual: Reply only appears in webchat; Telegram receives nothing

Workaround

Using the message tool with explicit targeting works:

message({
  action: "send",
  channel: "telegram", 
  target: "<chat_id>",
  message: "..."
})
// ✅ This delivers successfully

But automatic session replies (normal agent responses) do not route to Telegram.

Diagnostic Evidence

Session shows correct delivery context:

{
  "key": "agent:main:main",
  "channel": "telegram",
  "deliveryContext": {
    "channel": "telegram",
    "to": "telegram:6231215677",
    "accountId": "default"
  },
  "lastChannel": "telegram",
  "lastTo": "telegram:6231215677"
}

Despite deliveryContext and lastChannel correctly showing Telegram, replies don't deliver there.

Gateway status shows Telegram OK:

┌──────────┬─────────┬────────┬─────────────────────────────┐
│ Channel  │ Enabled │ State  │ Detail                      │
├──────────┼─────────┼────────┼─────────────────────────────┤
│ Telegram │ ON      │ OK     │ token config · accounts 1/1 │
└──────────┴─────────┴────────┴─────────────────────────────┘

Related Issues

Root Cause Hypothesis

When a session has activity from multiple channels, the reply routing mechanism may be defaulting to webchat instead of respecting the originating channel from deliveryContext. The message tool bypasses this by explicitly specifying the target channel.

Impact

  • Users messaging via Telegram don't receive responses unless the agent explicitly uses the message tool
  • Creates inconsistent UX where some replies appear on Telegram and others don't
  • Requires agent to "remember" to use explicit sends, which is error-prone

Temporary Workaround

Agent must use message tool for all Telegram replies instead of relying on automatic routing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions