sendSharedWidget
Vuelve a enviar un widget compartido creado por el bot (Bot API 10.4).
Devuelve: Si la llamada tiene éxito, devuelve Message.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
chat_id | Integer or String | Sí | ID del chat o @username |
message_thread_id | Integer | Opcional | ID del tema del foro |
widget_id | String | Sí | ID del widget compartido (widget.id del mensaje enviado) |
chat_data | String | Opcional | Estado del widget en este chat (chat_data), 0-1024 bytes |
caption | String | Opcional | Leyenda (0-1024) |
parse_mode | String | Opcional | HTML, Markdown o MarkdownV2 |
caption_entities | Array of MessageEntity | Opcional | Array JSON de MessageEntity para la leyenda |
show_caption_above_media | Boolean | Opcional | Mostrar la leyenda encima del widget |
disable_notification | Boolean | Opcional | Enviar sin sonido |
protect_content | Boolean | Opcional | Proteger el contenido |
allow_paid_broadcast | Boolean | Opcional | Permitir difusión de pago |
message_effect_id | String | Opcional | ID del efecto del mensaje |
reply_parameters | ReplyParameters | Opcional | Objeto JSON ReplyParameters |
reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | Opcional | Objeto JSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply |
Ejemplo de solicitud
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendSharedWidget" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"widget_id":"WIDGET_ID"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendSharedWidget",
json={
"chat_id": 123456789,
"widget_id": "WIDGET_ID"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendSharedWidget`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"widget_id": "WIDGET_ID"
}),
});
console.log(await res.json());
Guía paso a paso: Ejemplos de widgets de Telegram: HTML completo y bot en Python
Métodos relacionados
sendWidgetEnvía un mensaje con un widget HTML (Bot API 10.4).answerWidgetQueryResponde a una consulta de un widget (Bot API 10.4).editMessageWidgetDataEdita los datos de un widget en un mensaje (Bot API 10.4).editSharedWidgetDataEdita los datos públicos de un widget compartido (Bot API 10.4).