Documentation Index
Fetch the complete documentation index at: https://agno-v2-feat-executor-hitl-wf.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Code
import os
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.telegram import Telegram
from agno.tools.websearch import WebSearchTools
agent_db = SqliteDb(db_file="tmp/persistent_memory.db")
basic_agent = Agent(
name="Basic Agent",
model=OpenAIChat(id="gpt-5.2"),
db=agent_db,
add_history_to_context=True,
num_history_runs=3,
add_datetime_to_context=True,
markdown=True,
)
web_research_agent = Agent(
name="Web Research Agent",
model=OpenAIChat(id="gpt-5.2"),
db=agent_db,
tools=[WebSearchTools()],
add_history_to_context=True,
num_history_runs=3,
add_datetime_to_context=True,
)
# Telegram only supports one webhook per bot token, so each interface needs its own bot.
# Create two bots via @BotFather and pass each token explicitly.
agent_os = AgentOS(
agents=[basic_agent, web_research_agent],
interfaces=[
Telegram(agent=basic_agent, prefix="/basic", token=os.getenv("TELEGRAM_TOKEN_BASIC")),
Telegram(agent=web_research_agent, prefix="/web-research", token=os.getenv("TELEGRAM_TOKEN_RESEARCH")),
],
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="multiple_instances:app", reload=True)
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
Set Environment Variables
export TELEGRAM_TOKEN_BASIC=bot-token-for-basic-agent
export TELEGRAM_TOKEN_RESEARCH=bot-token-for-research-agent
export OPENAI_API_KEY=your-openai-api-key
export APP_ENV=development
Install dependencies
uv pip install -U "agno[telegram]"
Run Example
python multiple_instances.py
Register Webhooks
Register a webhook for each bot token:curl "https://api.telegram.org/bot${TELEGRAM_TOKEN_BASIC}/setWebhook?url=${NGROK_URL}/basic/webhook"
curl "https://api.telegram.org/bot${TELEGRAM_TOKEN_RESEARCH}/setWebhook?url=${NGROK_URL}/web-research/webhook"
Key Features
- Prefix-Based Routing: Each agent gets its own webhook path (
/basic/webhook, /web-research/webhook)
- Shared Server: Both agents run on a single AgentOS instance
- Separate Bot Tokens: Each interface uses its own BotFather bot (Telegram allows only one webhook per token)
- Shared Database: Both agents share the same SQLite database