support_team.py
"""
Support Team
============
A multi-agent team that routes support questions to the right specialist.
Technical Support handles code and API questions; Documentation Specialist
searches Slack history and the web for existing answers.
Key concepts:
- ``Team`` with a coordinator model routes questions to the best member.
- One member uses ``SlackTools`` to find past answers in Slack threads.
- Both members use ``WebSearchTools`` for external documentation.
Slack scopes: app_mentions:read, assistant:write, chat:write, im:history,
search:read, channels:history
Environment variables:
SLACK_TOKEN Bot token (xoxb-) for standard Slack APIs
SLACK_USER_TOKEN User token (xoxp-) required for search_messages
"""
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.slack import Slack
from agno.team import Team
from agno.tools.slack import SlackTools
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
team_db = SqliteDb(session_table="team_sessions", db_file="tmp/support_team.db")
# Technical Support Agent
tech_support = Agent(
name="Technical Support",
role="Code and technical troubleshooting",
model=OpenAIChat(id="gpt-4o"),
tools=[WebSearchTools()],
instructions=[
"You handle technical questions about code, APIs, and implementation.",
"Provide code examples when helpful.",
"Search for current documentation and best practices.",
],
markdown=True,
)
# Documentation Agent
docs_agent = Agent(
name="Documentation Specialist",
role="Finding and explaining documentation",
model=OpenAIChat(id="gpt-4o"),
tools=[
SlackTools(
enable_search_messages=True,
enable_get_thread=True,
),
WebSearchTools(),
],
instructions=[
"You find relevant documentation and past discussions.",
"Search Slack for previous answers to similar questions.",
"Search the web for official documentation.",
"Explain documentation in simple terms.",
],
markdown=True,
)
# The Team with a coordinator
support_team = Team(
name="Support Team",
model=OpenAIChat(id="gpt-4o"),
members=[tech_support, docs_agent],
description="A support team that routes questions to the right specialist.",
instructions=[
"You coordinate support requests.",
"Route technical/code questions to Technical Support.",
"Route 'how do I' or 'where is' questions to Documentation Specialist.",
"For complex questions, consult both agents.",
],
db=team_db,
add_history_to_context=True,
num_history_runs=3,
markdown=True,
)
agent_os = AgentOS(
teams=[support_team],
interfaces=[
Slack(
team=support_team,
reply_to_mentions_only=True,
)
],
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="support_team:app", reload=True)
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U "agno[os,slack]" ddgs openai
3
Export environment variables
export OPENAI_API_KEY="your_openai_api_key_here"
export SLACK_SIGNING_SECRET="your_slack_signing_secret_here"
export SLACK_TOKEN="your_slack_token_here"
export SLACK_USER_TOKEN="your_slack_user_token_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
$Env:SLACK_SIGNING_SECRET="your_slack_signing_secret_here"
$Env:SLACK_TOKEN="your_slack_token_here"
$Env:SLACK_USER_TOKEN="your_slack_user_token_here"
4
Run the example
Save the code above as
support_team.py, then run:python support_team.py