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
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer/String | Yes | Numeric ID (or numeric string) of the target user. Private chats only; groups, channels and the @username form are not supported |
| draft_id | Integer | Yes | Unique identifier (random ID) of the draft, must be non-zero. Clients use it to deduplicate repeated pushes of the same draft |
| text | String | Yes | Draft text content, 1-4096 characters |
| parse_mode | String | No | Text parsing mode, supports MarkdownV2, Markdown and HTML, see Formatting Options |
| entities | MessageEntity[] | No | List 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_idmust 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_markupis not supported.
Response
Returns Boolean true on success.
json
{
"ok": true,
"result": true
}Error Codes
| Code | Description |
|---|---|
| 400 | Bad request parameters, see common error descriptions below |
| 401 | Invalid or expired token |
| 500 | Internal server error |
Common Error Descriptions
| description | Meaning |
|---|---|
| RANDOM_ID_INVALID | draft_id is missing or zero |
| MESSAGE_EMPTY | text is empty |
| MESSAGE_TOO_LONG | text exceeds 4096 characters |
| TEXTDRAFT_PEER_INVALID | chat_id is not a user ID (e.g. a group, channel or string username) |
| USER_IS_BOT | The target is another bot |
| USER_DELETED | The target account is deleted or restricted |
| CHAT_WRITE_FORBIDDEN | The 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"
}'