Skip to content

[Feature]: Message catch-up on gateway restart for Telegram and Discord #26783

@ViperBlackSkull

Description

@ViperBlackSkull

Problem

When the OpenClaw gateway restarts (due to crash, config error, maintenance, etc.), any messages sent to Telegram or Discord while the gateway was down are permanently missed. This leads to:

  • Unanswered user messages
  • Lost conversation context
  • Poor user experience when the bot appears to "ignore" messages

Current Behavior

Both Telegram and Discord channels only process messages that arrive after the gateway connects:

  • Telegram: Uses getUpdates polling or webhooks, but doesnt track update_id for catch-up
  • Discord: Uses gateway events, doesnt fetch missed messages on reconnect

Proposed Solution

Implement a message catch-up mechanism that:

  1. Tracks last processed ID per channel/session:

    • Telegram: Store last update_id
    • Discord: Store last message_id per channel
  2. On gateway startup:

    • Query each channel for messages/updates after the last seen ID
    • Queue them for processing with rate limiting
  3. Config options:

{
  "channels": {
    "telegram": {
      "catchup": {
        "enabled": true,
        "maxMessages": 50,
        "maxAgeHours": 24
      }
    },
    "discord": {
      "catchup": {
        "enabled": true,
        "maxMessages": 100,
        "maxAgeHours": 48
      }
    }
  }
}

API Support

Platform API Capability Retention
Telegram getUpdates?offset=N ~24 hours
Discord GET /channels/{id}/messages?after={id} Unlimited (channel dependent)

Benefits

  • Reliability: No missed messages during downtime
  • User Experience: Users get responses even if bot was temporarily offline
  • Professionalism: Bot appears consistently available

Related Issues

Willing to Contribute

Yes, I can help test and provide feedback on implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions