sendMessageDraft
메시지 초안(임시 미리보기)을 전송합니다 (Bot API 9.5+).
반환값: 성공 시 반환값: True.
매개변수
| 매개변수 | 타입 | 필수 | 설명 |
|---|---|---|---|
chat_id | Integer | 예 | 개인 채팅 ID |
message_thread_id | Integer | 선택 | 토픽 ID (포럼용) |
draft_id | Integer | 예 | 고유 초안 ID (0이 아닌 값) |
text | String | 선택 | 초안 텍스트 (0-4096, 빈 값 = "Thinking...") |
parse_mode | String | 선택 | HTML, Markdown, MarkdownV2 |
entities | Array of MessageEntity | 선택 | MessageEntity JSON 배열 |
can_stop | Boolean | 선택 | 이후 초안을 중단하는 버튼 표시 (Bot API 10.3) |
keep_on_stop | Boolean | 선택 | 중단 버튼을 눌러도 초안을 채팅에 유지 (Bot API 10.3) |
요청 예제
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());
단계별 가이드: 텔레그램 봇 만들기: @BotFather로 생성하고 첫 메시지 보내기
관련 메서드
sendMessage텍스트 메시지를 전송합니다.forwardMessage메시지를 전달합니다.forwardMessages여러 메시지를 전달합니다.copyMessage원본 링크 없이 메시지를 복사합니다.copyMessages여러 메시지를 복사합니다.deleteMessage메시지를 삭제합니다.deleteMessages여러 메시지를 삭제합니다.sendChatAction채팅 액션(typing 등)을 전송합니다.sendContact연락처를 전송합니다.sendLocation위치를 전송합니다.sendVenue장소를 전송합니다.setMessageReaction메시지에 반응을 설정합니다.