Skip to content

Telegram native streaming support #458

@elianiva

Description

@elianiva

Problem Statement

The current implementation of message streaming on the Telegram adapter uses a post+edit method, which is okay but it's not the nicest thing in the world compared to true streaming. It makes it feels like it's stuck sometimes when the response is taking a while. See: https://x.com/durov/status/2028455440862830970

Proposed Solution

Telegram bots support proper streaming through sendMessageDraft and available for all bots since 1 March 2026, see: https://core.telegram.org/bots/api#sendmessagedraft.

Supporting this meaning a proper stream support so you'd get a better UI for streaming, a proper loading indicator when waiting for the stream, and better UX overall.

Although, there are some caveats which have been detailed by Grammy here: https://grammy.dev/plugins/stream#streaming-formatted-messages

So maybe this would not be the default behaviour and should be an opt-in option? We use remend to fix the markdown chunks but MarkdownV2 has a slightly different syntax and we risk of breaking the stream if there's an invalid syntax arrive. My use case doesn't need a fancy markdown formatting so stripping all formatting and using the stream works just fine for me.

Alternatives Considered

I don't think there's any other alternative since that's the only API they gave us.

Use Case

Maybe we could reuse StreamingPlan for this? I'm not sure though since this is a bit of an outlier case, there's no other adapter that you can configure to either use native streaming or post+edit strategy as far as I'm aware.
I don't think having this kind of "strategy" option would benefit other adapters either because if there's a native streaming option people would probably prefer that instead of post+edit strategy which feels a bit clunky.

It could probably look something like this:

const planned = new StreamingPlan(stream, {
  groupTasks: "plan",         // Slack: render task cards as a single grouped block
  endWith: [feedbackBlock],   // Slack: Block Kit elements appended after stream stops
  updateIntervalMs: 750,      // Fallback mode: post+edit cadence on non-native adapters
  strategy: "native"          // Either "native" or "post+edit", though there's no other adapter that needs this I don't think
});

Priority

Nice to have

Contribution

  • I am willing to help implement this feature

Additional Context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

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