Telegram Bot API
🌐 Tiếng Việt

sendMessageDraft

Danh mục: Tin nhắn · Bot API 10.3 · Tài liệu chính thức

Gửi bản nháp tin nhắn - bản xem trước tạm thời (Bot API 9.5+).

Giá trị trả về: Nếu thành công, trả về True.

Tham số

Tham sốKiểuBắt buộcMô tả
chat_idIntegerCóID chat riêng
message_thread_idIntegerTùy chọnID chủ đề (cho diễn đàn)
draft_idIntegerCóID bản nháp duy nhất (khác 0)
textStringTùy chọnNội dung bản nháp (0-4096, rỗng = "Thinking...")
parse_modeStringTùy chọnHTML, Markdown, MarkdownV2
entitiesArray of MessageEntityTùy chọnMảng JSON MessageEntity
can_stopBooleanTùy chọnHiển thị nút dừng các bản nháp tiếp theo (Bot API 10.3)
keep_on_stopBooleanTùy chọnGiữ bản nháp trong chat khi nhấn nút dừng (Bot API 10.3)

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessageDraft" \
  -H "Content-Type: application/json" \
  -d '{"chat_id":123456789,"draft_id":1}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/sendMessageDraft",
    json={
        "chat_id": 123456789,
        "draft_id": 1
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendMessageDraft`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "draft_id": 1
  }),
});
console.log(await res.json());

Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên