forwardMessages
Chuyển tiếp nhiều tin nhắn.
Giá trị trả về: Nếu thành công, trả về Array of MessageId.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
chat_id | Integer or String | Có | ID chat đích |
message_thread_id | Integer | Tùy chọn | ID chủ đề diễn đàn |
direct_messages_topic_id | Integer | Tùy chọn | ID chủ đề tin nhắn trực tiếp (Bot API 10.0) |
from_chat_id | Integer or String | Có | ID chat nguồn |
message_ids | Array of Integer | Có | Mảng JSON các ID tin nhắn [1,2,3] |
disable_notification | Boolean | Tùy chọn | Gửi không âm thanh |
protect_content | Boolean | Tùy chọn | Bảo vệ nội dung |
Ví dụ request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/forwardMessages" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"from_chat_id":123456789,"message_ids":[42,43]}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/forwardMessages",
json={
"chat_id": 123456789,
"from_chat_id": 123456789,
"message_ids": [
42,
43
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/forwardMessages`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"from_chat_id": 123456789,
"message_ids": [
42,
43
]
}),
});
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
Phương thức liên quan
sendMessageGửi tin nhắn văn bản.forwardMessageChuyển tiếp một tin nhắn.copyMessageSao chép tin nhắn mà không kèm liên kết chuyển tiếp.copyMessagesSao chép nhiều tin nhắn.deleteMessageXóa một tin nhắn.deleteMessagesXóa nhiều tin nhắn.sendChatActionGửi hành động trong chat (đang nhập, v.v.).sendMessageDraftGửi bản nháp tin nhắn - bản xem trước tạm thời (Bot API 9.5+).sendContactGửi thông tin liên hệ.sendLocationGửi vị trí.sendVenueGửi địa điểm.setMessageReactionĐặt cảm xúc cho tin nhắn.