Skip to content

feat(telegram): Edit-based streaming for regular DMs #1876

@leonardsellem

Description

@leonardsellem

Summary

The current Telegram draft streaming (channels.telegram.streamMode) only works in private chats with topics enabled (forum topic mode), which requires message_thread_id in incoming messages. This is a Telegram Bot API constraint.

However, the primary way users interact with Clawdbot via Telegram is regular 1:1 DMs, which don't support topics. This makes the draft streaming feature effectively unusable for the main use case.

Proposal

Implement edit-based streaming as an alternative streaming mode for Telegram:

  1. Send an initial message with partial content (e.g., "▌" or first chunk)
  2. Edit the message repeatedly as more tokens arrive
  3. Final edit removes any cursor indicator

Suggested config

{
  channels: {
    telegram: {
      streamMode: "edit"  // new mode alongside "partial" | "block" | "off"
    }
  }
}

Or a separate setting to decouple from draft streaming:

{
  channels: {
    telegram: {
      editStreaming: {
        enabled: true,
        minChars: 50,      // don't edit until buffer >= N chars
        intervalMs: 500,   // minimum time between edits (rate limit protection)
        showCursor: true   // append ▌ while generating
      }
    }
  }
}

Considerations

  • Rate limits: Telegram Bot API limits editMessageText calls. Need throttling (e.g., max 1 edit per 500ms or adaptive based on 429 responses).
  • UX: Edited messages don't trigger notifications, so this is clean for the user.
  • Fallback: If edit fails (e.g., message too old, rate limited), fall back to sending final message normally.
  • Compatibility: Should work in both DMs and groups.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions