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

# Phone Support Agent

> Build voice agents that answer phone calls with RAG-powered knowledge retrieval

<Card title="View Phone & RAG Example on GitHub" icon="github" href="https://github.com/GetStream/Vision-Agents/tree/main/examples/03_phone_and_rag_example">
  Check out the complete Phone & RAG example in our GitHub repository
</Card>

Builds on the [Twilio Phone Agent](/examples/twilio-phone-agent) example — complete ngrok and Twilio webhook setup there first. This tutorial adds RAG so your phone agent can answer questions from a knowledge base using [Gemini FileSearch](https://ai.google.dev/gemini-api/docs/file-search), [TurboPuffer](https://turbopuffer.com/), or Qdrant.

<Info>
  Vision Agents uses [Stream Video](https://getstream.io/video/) for real-time WebRTC transport by default. [External WebRTC transports](/integrations/introduction-to-integrations#edge-transport) are supported as well. Most AI providers offer free tiers to get started.
</Info>

## What You Will Build

* Answer inbound phone calls with an AI agent that retrieves knowledge in real time
* Make outbound calls programmatically for tasks like booking reservations
* Swap RAG backends with a single environment variable
* Handle bidirectional audio via Twilio Media Streams over WebSocket

## Prerequisites

Complete the [Twilio Phone Agent](/examples/twilio-phone-agent) setup first (`.env`, ngrok, Twilio webhook). Add these variables depending on your RAG backend:

```bash theme={null}
# Required for all backends
STREAM_API_KEY=
STREAM_API_SECRET=
GOOGLE_API_KEY=
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
NGROK_URL=your-subdomain.ngrok-free.app

# TurboPuffer only
TURBO_PUFFER_KEY=
```

## Add RAG to your phone agent

<Steps>
  <Step title="Choose a RAG backend" icon="database">
    Set `RAG_BACKEND` when running the inbound example:

    | Backend           | `RAG_BACKEND`      | Notes                                                       |
    | ----------------- | ------------------ | ----------------------------------------------------------- |
    | Gemini FileSearch | `gemini` (default) | Simplest setup — automatic chunking and embedding           |
    | TurboPuffer       | `turbopuffer`      | Hybrid vector + keyword search; requires `TURBO_PUFFER_KEY` |
    | Qdrant            | `qdrant`           | Hybrid search with function calling                         |

    See the [RAG guide](/guides/rag) for backend details.
  </Step>

  <Step title="Add knowledge files" icon="folder-open">
    The example ships with sample docs in `examples/03_phone_and_rag_example/knowledge/` covering Stream Chat, Video, and Feeds APIs. Add your own `.md` files to this directory or replace them with product documentation.
  </Step>

  <Step title="Run inbound with RAG" icon="play">
    From the example directory:

    ```bash theme={null}
    cd examples/03_phone_and_rag_example
    RAG_BACKEND=gemini NGROK_URL=your-subdomain.ngrok-free.app \
      uv run inbound_phone_and_rag_example.py
    ```

    Swap `RAG_BACKEND=turbopuffer` or `RAG_BACKEND=qdrant` to try other backends.
  </Step>

  <Step title="Test with a phone call" icon="microphone">
    Call your Twilio number and ask questions the knowledge base can answer, for example:

    * "What APIs does Stream offer for chat?"
    * "Tell me about Stream Video features."
    * "How does Stream Feeds work?"

    The agent retrieves relevant chunks before responding.
  </Step>
</Steps>

## How RAG connects to the phone agent

The inbound script (`inbound_phone_and_rag_example.py`) wires RAG into the agent based on `RAG_BACKEND`:

* **Gemini** — uses `gemini.GeminiFilesearchRAG` with File Search tools on the LLM
* **TurboPuffer / Qdrant** — registers a search function the LLM calls during conversation

Phone plumbing is unchanged from the [Twilio Phone Agent](/examples/twilio-phone-agent): Twilio webhooks start the media stream, `attach_phone_to_call` bridges audio to Stream, and the agent runs inside the Stream call.

For outbound calls with RAG, extend `outbound_phone_example.py` using the same RAG initialization pattern from the inbound script.

## Next Steps

<CardGroup cols={2}>
  <Card title="RAG Guide" icon="book" href="/guides/rag">
    Learn more about RAG backends and knowledge retrieval
  </Card>

  <Card title="Twilio Integration" icon="plug" href="/integrations/telephony/twilio">
    Plugin API reference and components
  </Card>

  <Card title="HTTP Server Guide" icon="server" href="/guides/http-server">
    Deploy your phone bot with the built-in HTTP server
  </Card>

  <Card title="Deploying Overview" icon="rocket" href="/guides/deploying-overview">
    Move from local dev to production
  </Card>
</CardGroup>
