Basic Slack Agent
Minimal Slack bot with SQLite session persistence and @mention replies
Part of the Slack interface examples. Follow the setup guide.
Code
from agno.agent import Agent
from agno.db.sqlite.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.slack import Slack
agent_db = SqliteDb(session_table="agent_sessions", db_file="tmp/persistent_memory.db")
basic_agent = Agent(
name="Basic Agent",
model=OpenAIChat(id="gpt-5.4-mini"),
db=agent_db,
add_history_to_context=True,
num_history_runs=3,
add_datetime_to_context=True,
)
# Setup our AgentOS app
agent_os = AgentOS(
agents=[basic_agent],
interfaces=[
Slack(
agent=basic_agent,
reply_to_mentions_only=True, # The Agent will react only to messages mentioning it
)
],
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="basic:app", reload=True)Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet Environment Variables
export SLACK_TOKEN=***
export SLACK_SIGNING_SECRET=***
export OPENAI_API_KEY=***Install Dependencies
uv pip install -U "agno[os,slack]" openaiRun Example
python basic.pyKey Features
- Mention-Only Replies: Responds only to @mentions in channels
- Session Persistence: SQLite database stores conversation history across restarts
- Conversation History: Last 3 interactions included in context