> ## 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] [View Phone & RAG Example on GitHub](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

Builds on the [Twilio Phone Agent](https://visionagents.ai/examples/twilio-phone-agent.md) 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.

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

## 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](https://visionagents.ai/examples/twilio-phone-agent.md) 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

**1. Choose a RAG backend**

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](https://visionagents.ai/guides/rag.md) for backend details.

**2. Add knowledge files**

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.

**3. Run inbound with RAG**

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.

**4. Test with a phone call**

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.

## 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](https://visionagents.ai/examples/twilio-phone-agent.md): 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

> [card] [RAG Guide](https://visionagents.ai/guides/rag.md)
>
> Learn more about RAG backends and knowledge retrieval

> [card] [Twilio Integration](https://visionagents.ai/integrations/telephony/twilio.md)
>
> Plugin API reference and components

> [card] [HTTP Server Guide](https://visionagents.ai/guides/http-server.md)
>
> Deploy your phone bot with the built-in HTTP server

> [card] [Deploying Overview](https://visionagents.ai/guides/deploying-overview.md)
>
> Move from local dev to production


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