> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Telegram Workflow

> Draft + Edit two-step workflow on Telegram

## Code

```python workflow.py theme={null}
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.workflow.step import Step
from agno.workflow.steps import Steps
from agno.workflow.workflow import Workflow

agent_db = SqliteDb(
    session_table="telegram_workflow_sessions", db_file="tmp/telegram_workflow.db"
)

drafter = Agent(
    name="Drafter",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions="Draft a response to the user's message. Be helpful and informative.",
)

editor = Agent(
    name="Editor",
    model=OpenAIChat(id="gpt-4o-mini"),
    instructions=[
        "Review and polish the draft for clarity and conciseness.",
        "Keep it short and suitable for a Telegram message.",
    ],
)

draft_step = Step(
    name="draft",
    agent=drafter,
    description="Draft an initial response",
)

edit_step = Step(
    name="edit",
    agent=editor,
    description="Edit and polish the draft",
)

telegram_workflow = Workflow(
    name="Telegram Draft-Edit Workflow",
    description="A two-step workflow that drafts and then edits responses for Telegram",
    steps=[
        Steps(
            name="draft_and_edit",
            description="Draft then edit a response",
            steps=[draft_step, edit_step],
        )
    ],
    db=agent_db,
)

agent_os = AgentOS(
    workflows=[telegram_workflow],
    interfaces=[
        Telegram(
            workflow=telegram_workflow,
            reply_to_mentions_only=True,
        )
    ],
)
app = agent_os.get_app()

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

## Usage

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Set Environment Variables">
    ```bash theme={null}
    export TELEGRAM_TOKEN=your-bot-token-from-botfather
    export OPENAI_API_KEY=your-openai-api-key
    export APP_ENV=development
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[telegram]"
    ```
  </Step>

  <Step title="Run Example">
    ```bash theme={null}
    python workflow.py
    ```
  </Step>
</Steps>

## Key Features

* **Two-Step Pipeline**: Drafter writes an initial response, Editor polishes it
* **Workflow on Telegram**: The `Workflow` (not individual agents) is passed to the Telegram interface
* **Sequential Steps**: `Steps` chains `Step` objects in order
* **Persistent Sessions**: SQLite database for conversation history across restarts
