View Phone & RAG Example on GitHub
Check out the complete Phone & RAG example in our GitHub repository
Vision Agents uses Stream Video for real-time WebRTC transport by default. External WebRTC transports 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 setup first (.env, ngrok, Twilio webhook). Add these variables depending on your RAG backend:
Add RAG to your phone agent
Choose a RAG backend
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.Run inbound with RAG
From the example directory:Swap
RAG_BACKEND=turbopuffer or RAG_BACKEND=qdrant to try other backends.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?”
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.GeminiFilesearchRAGwith File Search tools on the LLM - TurboPuffer / Qdrant — registers a search function the LLM calls during conversation
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
RAG Guide
Learn more about RAG backends and knowledge retrieval
Twilio Integration
Plugin API reference and components
HTTP Server Guide
Deploy your phone bot with the built-in HTTP server
Deploying Overview
Move from local dev to production