Telegram Bot API
🌐 Español

sendVoice

Categoría: Multimedia · Bot API 10.3 · Documentación oficial

Envía un mensaje de voz.

Devuelve: Si la llamada tiene éxito, devuelve Message.

Parámetros

ParámetroTipoObligatorioDescripción
business_connection_idStringOpcionalID de la conexión empresarial
chat_idInteger or StringSíID del chat o @username
message_thread_idIntegerOpcionalID del tema del foro
direct_messages_topic_idIntegerOpcionalID del tema de mensajes directos (Bot API 10.0)
ephemeral_message_parametersEphemeralMessageParametersOpcionalObjeto JSON EphemeralMessageParameters — mensaje efímero visible para un solo usuario (Bot API 10.3)
voiceInputFile or StringSíURL o file_id del mensaje de voz
captionStringOpcionalLeyenda (0-1024)
parse_modeStringOpcionalHTML, Markdown o MarkdownV2
caption_entitiesArray of MessageEntityOpcionalArray JSON de MessageEntity
durationIntegerOpcionalDuración en segundos
disable_notificationBooleanOpcionalEnviar sin sonido
protect_contentBooleanOpcionalProteger el contenido
allow_paid_broadcastBooleanOpcionalPermitir difusión de pago
message_effect_idStringOpcionalID del efecto del mensaje
suggested_post_parametersSuggestedPostParametersOpcionalObjeto JSON SuggestedPostParameters
reply_parametersReplyParametersOpcionalObjeto JSON ReplyParameters
reply_markupInlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReplyOpcionalObjeto JSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply

Las descripciones de los parámetros son resúmenes breves; consulta la documentación oficial para ver el texto completo.

Ejemplo de solicitud

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendVoice" \
  -H "Content-Type: application/json" \
  -d '{"chat_id":123456789,"voice":"https://example.com/voice.ogg"}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/sendVoice",
    json={
        "chat_id": 123456789,
        "voice": "https://example.com/voice.ogg"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendVoice`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "voice": "https://example.com/voice.ogg"
  }),
});
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