sendMessage
Envía un mensaje de texto.
Devuelve: Si la llamada tiene éxito, devuelve Message.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
business_connection_id | String | Opcional | ID de la conexión empresarial |
chat_id | Integer or String | Sí | ID del chat o @username |
message_thread_id | Integer | Opcional | ID del tema del foro |
direct_messages_topic_id | Integer | Opcional | ID del tema de mensajes directos (para canales, Bot API 10.0) |
ephemeral_message_parameters | EphemeralMessageParameters | Opcional | Objeto JSON EphemeralMessageParameters — mensaje efímero visible para un solo usuario (Bot API 10.3) |
text | String | Sí | Texto del mensaje (1-4096 caracteres) |
parse_mode | String | Opcional | HTML, Markdown o MarkdownV2 |
entities | Array of MessageEntity | Opcional | Array JSON de MessageEntity |
link_preview_options | LinkPreviewOptions | Opcional | Objeto JSON LinkPreviewOptions |
disable_notification | Boolean | Opcional | Enviar sin sonido |
protect_content | Boolean | Opcional | Proteger el contenido |
allow_paid_broadcast | Boolean | Opcional | Permitir difusión de pago (0.1 Stars/mensaje) |
message_effect_id | String | Opcional | ID del efecto del mensaje |
suggested_post_parameters | SuggestedPostParameters | Opcional | Objeto JSON SuggestedPostParameters (para canales) |
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/sendMessage" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"text":"Hello from the Bot API!"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendMessage",
json={
"chat_id": 123456789,
"text": "Hello from the Bot API!"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendMessage`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"text": "Hello from the Bot API!"
}),
});
console.log(await res.json());
Guía paso a paso: Cómo enviar mensajes con la API de Telegram: sendMessage paso a paso
Métodos relacionados
forwardMessageReenvía un mensaje.forwardMessagesReenvía varios mensajes.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.