Skip to main content

Code

basic_workflow.py
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.tools.websearch import WebSearchTools
from agno.workflow.step import Step
from agno.workflow.workflow import Workflow

# Define agents for the workflow
researcher_agent = Agent(
    name="Research Agent",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[WebSearchTools()],
    role="Search the web and gather comprehensive research on the given topic",
    instructions=[
        "Search for the most recent and relevant information",
        "Focus on credible sources and key insights",
        "Summarize findings clearly and concisely",
    ],
)

writer_agent = Agent(
    name="Content Writer",
    model=OpenAIChat(id="gpt-4o-mini"),
    role="Create engaging content based on research findings",
    instructions=[
        "Write in a clear, engaging, and professional tone",
        "Structure content with proper headings and bullet points",
        "Include key insights from the research",
        "Keep content informative yet accessible",
    ],
)

# Create workflow steps
research_step = Step(
    name="Research Step",
    agent=researcher_agent,
)

writing_step = Step(
    name="Writing Step",
    agent=writer_agent,
)

# Create the workflow
workflow_db = SqliteDb(
    session_table="workflow_sessions", db_file="tmp/basic_workflow.db"
)

content_workflow = Workflow(
    name="Content Creation Workflow",
    description="Research and create content on any topic via Slack",
    db=workflow_db,
    steps=[research_step, writing_step],
    add_workflow_history_to_steps=True,
    num_history_runs=3,
)

# Create AgentOS with Slack interface for the workflow
agent_os = AgentOS(
    workflows=[content_workflow],
    interfaces=[Slack(workflow=content_workflow)],
)

app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="basic_workflow:app", reload=True)

Usage

1

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate
2

Set Environment Variables

export SLACK_TOKEN=***
export SLACK_SIGNING_SECRET=***
export OPENAI_API_KEY=***
3

Install Dependencies

uv pip install 'agno[slack]'
4

Run Example

python basic_workflow.py

Key Features

  • Two-Step Pipeline: Research Agent gathers information, Content Writer produces a polished summary
  • Workflow on Slack: The Workflow object (not individual agents) is passed to the Slack interface
  • Sequential Steps: Steps execute in order, passing output from research to writing
  • SQLite Sessions: Workflow state persists in SQLite