Skip to main content
TelegramTools enable an Agent to send messages and media to Telegram chats using the Telegram Bot API. 9 tool methods cover text, photos, documents, video, audio, animations, stickers, editing, and deleting messages.

Prerequisites

uv pip install -U "agno[telegram]"
export TELEGRAM_TOKEN=***

Example

The following agent will send a message to a Telegram chat.
cookbook/14_tools/telegram_tools.py
from agno.agent import Agent
from agno.tools.telegram import TelegramTools

# How to get the token and chat_id:
# 1. Create a new bot with BotFather on Telegram. https://core.telegram.org/bots/features#creating-a-new-bot
# 2. Get the token from BotFather.
# 3. Send a message to the bot.
# 4. Get the chat_id by going to the URL:
#    https://api.telegram.org/bot/<your-bot-token>/getUpdates

telegram_token = "<enter-your-bot-token>"
chat_id = "<enter-your-chat-id>"

agent = Agent(
    name="telegram",
    tools=[TelegramTools(token=telegram_token, chat_id=chat_id)],
)

agent.print_response("Send message to telegram chat a paragraph about the moon")

Toolkit Params

ParameterTypeDefaultDescription
chat_idOptional[str]NoneDefault chat ID. Falls back to TELEGRAM_CHAT_ID env var.
tokenOptional[str]NoneBot token. Falls back to TELEGRAM_TOKEN env var.
enable_send_messageboolTrueEnable send_message tool.
enable_send_photoboolFalseEnable send_photo tool.
enable_send_documentboolFalseEnable send_document tool.
enable_send_videoboolFalseEnable send_video tool.
enable_send_audioboolFalseEnable send_audio tool.
enable_send_animationboolFalseEnable send_animation tool (GIFs).
enable_send_stickerboolFalseEnable send_sticker tool.
enable_edit_messageboolFalseEnable edit_message tool.
enable_delete_messageboolFalseEnable delete_message tool.
allboolFalseEnable all tools. Overrides individual flags.

Toolkit Functions

FunctionDescription
send_messageSend a text message to a chat.
send_photoSend a photo (bytes) with optional caption.
send_documentSend a document (bytes) with filename and optional caption.
send_videoSend a video (bytes) with optional caption.
send_audioSend an audio file (bytes) with optional caption and title.
send_animationSend an animation/GIF (bytes) with optional caption.
send_stickerSend a sticker (bytes).
edit_messageEdit a previously sent message by message_id.
delete_messageDelete a message by message_id.
All methods return a JSON string with {"status": "success", "message_id": ...} on success or {"status": "error", "message": ...} on failure.

Developer Resources