forwardMessages
Reenvía varios mensajes.
Devuelve: Si la llamada tiene éxito, devuelve Array of MessageId.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
chat_id | Integer or String | Sí | ID del chat de destino |
message_thread_id | Integer | Opcional | ID del tema del foro |
direct_messages_topic_id | Integer | Opcional | ID del tema de mensajes directos (Bot API 10.0) |
from_chat_id | Integer or String | Sí | ID del chat de origen |
message_ids | Array of Integer | Sí | Array JSON de IDs de mensajes [1,2,3] |
disable_notification | Boolean | Opcional | Enviar sin sonido |
protect_content | Boolean | Opcional | Proteger el contenido |
Ejemplo de solicitud
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());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
sendMessageEnvía un mensaje de texto.forwardMessageReenvía un mensaje.copyMessageCopia un mensaje sin el enlace al original.copyMessagesCopia varios mensajes.deleteMessageElimina un mensaje.deleteMessagesElimina varios mensajes.sendChatActionEnvía una acción de chat (typing, etc.).sendMessageDraftEnvía un borrador de mensaje: vista previa temporal (Bot API 9.5+).sendContactEnvía un contacto.sendLocationEnvía una ubicación.sendVenueEnvía un lugar.setMessageReactionEstablece una reacción en un mensaje.