Telegram streaming drafts disappear unless you send the final message

sendMessageDraft is a temporary preview in a private chat. Persist the answer with sendMessage and handle cancellation, late model deltas, and uncertain delivery separately.

Telegram streaming drafts disappear unless you send the final message

Telegram's sendMessageDraft lets a user watch an answer being generated, but the draft is a temporary 30-second preview. Once generation finishes, the bot must call sendMessage to persist the complete answer in the chat. Visible text is not yet a delivered message.

This article checks the current sendMessageDraft contract on November 28, 2026. The latest changelog entry is Bot API 10.5, November 22; that does not mean every draft feature was introduced in 10.5. The examples were run locally without a live bot or model connection.

Which chats support message drafts?

sendMessageDraft currently targets private chats, not groups or channels. Its chat_id is the integer identifier of the private chat, with an optional message_thread_id for the relevant thread.

For a concrete integration example, AstrBot’s Chinese Telegram guide separates private-chat sendMessageDraft from a group path using send_message followed by edit_message_text. This is the guide’s documented routing choice, not an AstrBot test or a comparison of rate limits or performance.

Use the same nonzero draft_id throughout one generation. Telegram animates changes to that draft; changing the identifier replaces it without that animation. Associate each generation with its bot, chat, thread, and draft rather than treating one global counter as every active conversation. See routing a reply to its original topic for the thread boundary.

Draft text may be empty to display “Thinking…”, and allows up to 4096 characters after entity parsing. A final sendMessage requires at least one character. Empty previews therefore cannot be forwarded blindly as final messages. A long answer needs an explicit message splitting strategy, not a preview that repeatedly overwrites and loses earlier paragraphs.

Should every model delta trigger a Telegram request?

No. Accumulate model text and send occasional snapshots at a cadence managed by your application.

Model deltas, draft updates, and final sends are separate events. Parse the model's stream event boundaries, maintain the answer buffer, and use the complete current preview as the draft text. A new delta is not itself the full replacement text. Unchanged snapshots need no additional request.

Model deltas become a snapshot buffer, with separate exits for preview updates and final delivery

The Telegram FAQ gives ordinary-message rate guidance; it is not a fixed rate guarantee for drafts. Coalesce previews and bound the outgoing queue. When the API returns retry_after, wait that number of seconds and recheck whether the generation is still active before sending. Replace stale queued previews with the newest snapshot instead of replaying them all.

Does “keep on stop” save the partial answer?

No. keep_on_stop: true still leaves a temporary draft, which disappears after a short time or when the bot sends a message.

Setting can_stop: true displays a stop button. Pressing it produces a stopped_message_generation update. The event object contains chat, an optional message_thread_id, and draft_id. Match those fields to the active generation, mark it stopped, stop scheduling previews, and cancel the upstream request when possible.

A stop update matches a chat, thread, and draft; late text is excluded from previews and final sends

Text already in transit may arrive after cancellation. Stopping must therefore change application state, not merely call an abort function while the delta consumer continues unchanged. Saving a partial answer is a separate product decision. If you do save one, send a new message and label it incomplete. The example below chooses not to save stopped drafts automatically.

A stop cannot undo a final send already accepted by Telegram. If stopping races with final delivery, preserve the actual ordering and outcome rather than promising that no message can appear after the button is pressed.

How can you test late deltas without a bot?

Use a state handler that distinguishes a ready answer from a request actually being dispatched.

Here, event is an application-defined format, not a Telegram Update. In a real integration, map verified platform events to the full generation key; model events must carry the same identity. This example covers short plain text only. It does not implement splitting, formatting, rate control, or persistence.

import assert from 'node:assert/strict';

function step(state, event) {
  if (event.key !== state.key) return null;
  if (state.phase === 'sending') {
    if (event.kind === 'sent') {
      state.phase = 'delivered';
      state.messageId = event.messageId;
    } else if (event.kind === 'send_unknown') {
      state.phase = 'unknown';
    }
    return null;
  }
  if (state.phase === 'ready_to_send') {
    if (event.kind === 'stop') state.phase = 'stopped';
    if (event.kind === 'start_send') {
      state.phase = 'sending';
      return { method: 'sendMessage', text: state.text };
    }
    return null;
  }
  if (state.phase !== 'generating') return null;
  if (event.kind === 'delta') state.text += event.text;
  if (event.kind === 'stop' || event.kind === 'failed') {
    state.phase = event.kind === 'stop' ? 'stopped' : 'failed';
  }
  if (event.kind === 'preview') {
    return { method: 'sendMessageDraft', text: state.text };
  }
  if (event.kind === 'finish') {
    state.phase = state.text.length ? 'ready_to_send' : 'empty';
  }
  return null;
}

const state = { key: 'demo:7:0:81', phase: 'generating', text: '' };
step(state, { key: state.key, kind: 'delta', text: 'First sentence.' });
step(state, { key: state.key, kind: 'stop' });
step(state, { key: state.key, kind: 'delta', text: 'Late text' });
assert.equal(step(state, { key: state.key, kind: 'finish' }), null);
assert.equal(state.phase, 'stopped');
assert.equal(state.text, 'First sentence.');

const queued = { key: 'demo:7:0:82', phase: 'generating', text: 'Ready' };
step(queued, { key: queued.key, kind: 'finish' });
assert.equal(queued.phase, 'ready_to_send');
step(queued, { key: queued.key, kind: 'stop' });
assert.equal(step(queued, { key: queued.key, kind: 'start_send' }), null);

Save the code as .mjs and run it with Node.js; a normal exit means the assertions passed. finish only marks the answer ready_to_send, so a stop during queueing still cancels it. After waiting in the queue, the sender calls start_send synchronously just before dispatch. Send only if an action is returned; do not put that action into another delayed queue. Likewise, call preview again when a preview is ready to leave the queue instead of dispatching a stale action unconditionally.

Emitted objects contain only the method and text. The network layer still supplies chat_id, a nonzero draft_id for drafts, and any applicable thread field. This in-memory example is not a restart-safe or multiworker delivery implementation.

What should final acceptance checks distinguish?

Treat delivery, user cancellation, generation failure, and uncertain sending as different outcomes.

A finished answer waits for dispatch; only a message receipt confirms delivery, while stopped and unknown remain separate

Local checks covered late deltas after stopping, stopping while a finished answer is still queued, normal dispatch, repeated finish events, empty output, a mismatched generation, model failure, acknowledged delivery, and an unknown send result. A test bot still needs to verify platform behavior: a preview disappears without a final send; a successful sendMessage produces a saved message identifier; stopping affects only its matching draft.

If the final request times out, retain the answer and mark delivery unknown. Regenerating it or immediately sending the full text again does not resolve that uncertainty; use the Telegram event and sending recovery boundaries. Nbility's streaming model endpoint supplies model content, while your bot separately manages draft visibility and final Telegram delivery.

Related posts

View all posts
Send Telegram bot replies back to the right topic

Send Telegram bot replies back to the right topic

Keep chat_id and message_thread_id together when replying to Telegram topics. Use reply_parameters separately, and pause delivery when the original destination becomes unavailable.

TelegramBots

Run your Agent workflow through Nbility

Get an API key and connect OpenAI-compatible models and developer tools from one place.

Get an API key