Telegram

TelegramTools enables an Agent to send text, photos, documents, video, audio, animations, and stickers to a Telegram chat via the Bot API.

TelegramTools enable an Agent to send messages and media to Telegram chats using the Telegram Bot API. Thirteen tool methods cover sending media, editing and deleting messages, reactions, pins, chat metadata, and file downloads.

Prerequisites

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

Example

The following agent will send a message to a Telegram chat.

cookbook/91_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

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

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.
output_directoryOptional[str]NoneDirectory for files downloaded by get_file. Setting it also enables saving downloads.
save_downloadsboolFalseSave downloaded files locally. Otherwise, get_file returns base64 content.
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.
enable_react_with_emojiboolFalseEnable react_with_emoji tool.
enable_pin_messageboolFalseEnable pin_message tool.
enable_get_chatboolFalseEnable get_chat tool.
enable_get_fileboolFalseEnable get_file 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.
react_with_emojiAdd an emoji reaction to a message.
pin_messagePin a message with optional notification suppression.
get_chatReturn metadata for the configured chat.
get_fileDownload a Telegram file and return a local path or base64 content.

Each method returns a JSON string with a status field. Success fields vary by operation. Errors include a message field.

Developer Resources