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

# Basic WhatsApp Agent

> Create a basic AI agent that integrates with the WhatsApp Business API

## Code

```python basic.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.whatsapp import Whatsapp

agent_db = SqliteDb(db_file="tmp/persistent_memory.db")
basic_agent = Agent(
    name="Basic Agent",
    model=OpenAIChat(id="gpt-4o"),
    db=agent_db,
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
    markdown=True,
    instructions=[
        "You are chatting on WhatsApp. Keep responses conversational and natural.",
        "Structure your responses as separate short paragraphs separated by double newlines.",
        "Each paragraph should be a distinct thought or message, like a human would send on WhatsApp.",
        "Keep each paragraph to 1-3 sentences max.",
    ],
)

agent_os = AgentOS(
    agents=[basic_agent],
    interfaces=[Whatsapp(agent=basic_agent)],
)
app = agent_os.get_app()

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

## Usage

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

**1. Set Environment Variables**

```bash theme={null}
export WHATSAPP_ACCESS_TOKEN=your_access_token
export WHATSAPP_PHONE_NUMBER_ID=your_phone_number_id
export WHATSAPP_VERIFY_TOKEN=your_verify_token
export WHATSAPP_APP_SECRET=your_app_secret
export OPENAI_API_KEY=your_openai_api_key
```

See the [WhatsApp setup guide](https://agno-v2.mintlify.site/agent-os/interfaces/whatsapp/setup.md) for how to get these values from the [Meta Developer Dashboard](https://developers.facebook.com/apps/).

**2. Install dependencies**

```bash theme={null}
uv pip install -U "agno[os]" openai
```

**3. Run Example**

```bash theme={null}
python basic.py
```

> [!WARNING]
>
> Set `WHATSAPP_SKIP_SIGNATURE_VALIDATION=true` only for local payload tests that are not reachable from the public internet. Public webhook endpoints should validate signatures with `WHATSAPP_APP_SECRET`.

## Key Features

* **WhatsApp Integration**: Responds to messages via the WhatsApp Business API
* **Conversation History**: Maintains context with last 3 interactions
* **Persistent Memory**: SQLite database for session storage
* **Session Reset**: Users can send `/new` to start a fresh conversation
* **Markdown Support**: Rich text formatting in messages


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.