Prerequisites
Example
The following agent will send a message to a Telegram chat.cookbook/tools/tavily_tools.py
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
You are viewing v1 docs. For the latest documentation, visit docs.agno.com
pip install -U agno httpx
export TELEGRAM_TOKEN=***
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")
| Parameter | Type | Default | Description |
|---|---|---|---|
token | Optional[str] | None | Telegram Bot API token. If not provided, will check TELEGRAM_TOKEN environment variable. |
chat_id | Union[str, int] | - | The ID of the chat to send messages to. |
| Function | Description |
|---|---|
send_message | Sends a message to the specified Telegram chat. Takes a message string as input and returns the API response as text. If an error occurs, returns an error message. |
Was this page helpful?