sendWidget
HTML widget içeren bir mesaj gönderir (Bot API 10.4).
Dönüş değeri: Başarılı olduğunda Message döndürür.
Parametreler
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
chat_id | Integer or String | Evet | Sohbet ID'si veya @username |
message_thread_id | Integer | İsteğe bağlı | Forum konusu ID'si |
html | String | Evet | Widget'ın HTML kodu: 1-32768 bayt, zlib sıkıştırmasından sonra en fazla 4096 bayt |
width | Integer | İsteğe bağlı | Mantıksal piksel cinsinden widget genişliği (mesajın tam genişliği için boş bırakın) |
height | Integer | İsteğe bağlı | Mantıksal piksel cinsinden widget yüksekliği, 50-600 (içeriğe sığdırmak için boş bırakın) |
public_data | String | İsteğe bağlı | Widget'ın genel durumu (public_data), 0-1024 bayt — widget'ın gösterildiği her yerde görünür |
chat_data | String | İsteğe bağlı | Widget'ın bu sohbetteki durumu (chat_data), 0-1024 bayt |
caption | String | İsteğe bağlı | Altyazı (0-1024) |
parse_mode | String | İsteğe bağlı | HTML, Markdown, MarkdownV2 |
caption_entities | Array of MessageEntity | İsteğe bağlı | Altyazı için JSON MessageEntity dizisi |
show_caption_above_media | Boolean | İsteğe bağlı | Altyazıyı widget'ın üstünde göster |
allow_queries | Boolean | İsteğe bağlı | Widget'ın bota sorgu göndermesine izin ver (widget_query) |
is_shared | Boolean | İsteğe bağlı | Paylaşılan widget oluştur — sendSharedWidget ile yeniden gönderilebilir |
disable_notification | Boolean | İsteğe bağlı | Sessiz gönder |
protect_content | Boolean | İsteğe bağlı | İçeriği koru |
allow_paid_broadcast | Boolean | İsteğe bağlı | Ücretli yayına izin ver |
message_effect_id | String | İsteğe bağlı | Mesaj efekti ID'si |
reply_parameters | ReplyParameters | İsteğe bağlı | JSON ReplyParameters nesnesi |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | İsteğe bağlı | JSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
Örnek istek
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendWidget" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendWidget",
json={
"chat_id": 123456789,
"html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendWidget`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
}),
});
console.log(await res.json());
Adım adım rehber: Telegram widget: bot mesajının içinde çalışan etkileşimli HTML
İlgili metotlar
sendSharedWidgetBot tarafından oluşturulan paylaşılan widget'ı yeniden gönderir (Bot API 10.4).answerWidgetQueryWidget'tan gelen sorguyu yanıtlar (Bot API 10.4).editMessageWidgetDataMesajdaki widget'ın verilerini düzenler (Bot API 10.4).editSharedWidgetDataPaylaşılan widget'ın genel verilerini düzenler (Bot API 10.4).