Skip to content

sendMessageDraft

Push a draft text into the message input box of a user's private chat with the bot. This is a SafeW extension method that does not exist in the Telegram Bot API.

Unlike sendMessage, this method does not create a real message: the draft is delivered as a real-time update, and the client pre-fills the text into the input box of the user's private chat with the bot, leaving it to the user to decide whether to send it. The draft is not persisted and no message_id is produced.

Request

POST /:token/sendMessageDraft

Parameters

ParameterTypeRequiredDescription
chat_idInteger/StringYesNumeric ID (or numeric string) of the target user. Private chats only; groups, channels and the @username form are not supported
draft_idIntegerYesUnique identifier (random ID) of the draft, must be non-zero. Clients use it to deduplicate repeated pushes of the same draft
textStringYesDraft text content, 1-4096 characters
parse_modeStringNoText parsing mode, supports MarkdownV2, Markdown and HTML, see Formatting Options
entitiesMessageEntity[]NoList of special entities in the draft text, can be used instead of parse_mode. If both are provided, parse_mode takes precedence

Restrictions

  • Private chats only: chat_id must be a user ID — not a bot, group or channel.
  • The target user must have an existing dialog with the bot and must have messaged the bot before.
  • Drafts cannot be pushed to deleted or restricted accounts.
  • The draft is a transient update: it produces no message record and reply_markup is not supported.

Response

Returns Boolean true on success.

json
{
  "ok": true,
  "result": true
}

Error Codes

CodeDescription
400Bad request parameters, see common error descriptions below
401Invalid or expired token
500Internal server error

Common Error Descriptions

descriptionMeaning
RANDOM_ID_INVALIDdraft_id is missing or zero
MESSAGE_EMPTYtext is empty
MESSAGE_TOO_LONGtext exceeds 4096 characters
TEXTDRAFT_PEER_INVALIDchat_id is not a user ID (e.g. a group, channel or string username)
USER_IS_BOTThe target is another bot
USER_DELETEDThe target account is deleted or restricted
CHAT_WRITE_FORBIDDENThe target user has never messaged the bot, so no draft can be pushed

Examples

cURL

bash
curl -X POST "https://api.safew.bot/<token>/sendMessageDraft" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "draft_id": 1720000000123,
    "text": "Check my orders for today"
  }'

Draft with Formatting

bash
curl -X POST "https://api.safew.bot/<token>/sendMessageDraft" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "draft_id": 1720000000124,
    "text": "Check order <b>NO.2024001</b>",
    "parse_mode": "HTML"
  }'