Setup
1. Create a Bot
Open Telegram and message @BotFather:- Send
/newbot - Choose a name and username
- Copy the bot token (e.g.,
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)
2. Set the Token
3. Run Your Bot
TelegramInterface Parameters
Authentication
Receiver Mode
How the bot receives messages.
"polling" for development, "webhook" for production.Webhook Settings
Access Control
Formatting
Timeouts
Polling Mode (Development)
Polling is the simplest mode. The bot periodically asks Telegram for new messages. No public URL or HTTPS certificate is needed.Webhook Mode (Production)
Webhooks are more efficient for production. Telegram pushes updates to your server as they arrive — no polling delay.- A publicly accessible HTTPS URL
- Port 443, 80, 88, or 8443
- Valid SSL certificate (use Let’s Encrypt or a reverse proxy)
Media Support
The interface automatically handles Telegram media types:
Media is passed to the agent in the
images, audio, and files parameters, so tools and the model can access them.
Voice Notes
Telegram voice messages are sent as.oga files (OGG Opus). Most LLMs don’t understand raw audio — you need to transcribe voice to text first. Add audio_transcriber=True to your agent:
- Telegram delivers it as an
Audioobject withmime_type="audio/ogg" - The agent’s transcriber converts the audio to text via the Whisper API
- The transcript is injected into the message content
- The model processes the text normally
Sending Media
The agent can return media in its response. Images are sent as photos, and files are sent as documents:Access Control
Restrict who can use the bot:Agent with Tools
Give your Telegram bot capabilities:Complete Production Example
Error Handling
The Telegram interface maps API errors to specific exception types:
When an error occurs during message processing, the configured
error_message is sent to the user, and all on_error hooks are invoked.