sendMessageDraft

Raw MD
Use this method to stream a partial message to a user while the message is being generated

Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendMessage with the complete message to persist it in the user's chat. Returns True on success.

Parameters

ParameterTypeRequiredDescription
chat_idIntegerYesUnique identifier for the target private chat
message_thread_idIntegerOptionalUnique identifier for the target message thread
draft_idIntegerYesUnique identifier of the message draft; must be non-zero. Changes to drafts with the same identifier are animated. Otherwise, the draft is replaced without animation.
textStringOptionalText of the message to be sent, 0-4096 characters after entities parsing. Pass an empty text to show a "Thinking..." placeholder.
parse_modeStringOptionalMode for parsing entities in the message text. See formatting options for more details.
entitiesArray of MessageEntityOptionalA JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode
can_stopBooleanOptionalPass True to show the user a button to stop further drafts. The bot will receive an Update "stopped_message_generation" if the user presses the button.
keep_on_stopBooleanOptionalPass True to keep the draft in the chat when the button is pressed. The draft will still disappear after a short time or if the bot sends a message. To fully preserve the partial draft, the bot should send it as a new message.

Example

PHP — Call sendMessageDraft on Botlify Cloud
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN     = getenv('BOT_TOKEN');     // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME  = getenv('BOT_USERNAME');  // Bot username without @

$resp = bot('sendMessageDraft', [
    'chat_id' => $chatId,
    'draft_id' => 'value',
]);

if ($resp['ok'] ?? false) {
    $result = $resp['result']; // handle the response
}
Botlify Cloud Runtime
Credentials are auto-injected in .env — always load them with getenv(): BOT_TOKEN, ADMIN_CHAT_ID, BOT_USERNAME. Main database: database.db (SQLite, WAL mode). Runtime errors: error.log. Quick test: send to $ADMIN_CHAT_ID. Full details: Runtime Reference.