Uploaded March 2026 | Updated September 2026, 1 hour ago
Build a real-time AI voice assistant using Twilio Voice and Google Gemini. In this step-by-step tutorial, youβll connect live phone calls to Gemini using Twilio ConversationRelay, FastAPI, and WebSockets β with incredibly low latency.
π Full Source Code: github.com/rishabkumar7/twilio-cr-gemini-python
In this video, youβll build a production-ready voice AI assistant that can answer real phone calls and maintain conversation context.
When someone calls your Twilio number:
β’ Twilio hits your /twiml endpoint
β’ TwiML opens a WebSocket connection
β’ Twilio streams speech transcripts in real time
β’ Your server sends prompts to Gemini
β’ Gemini generates a response
β’ Twilio converts it back to speech instantly
The result: a fully conversational AI assistant powered by Gemini 3 Flash.
What youβll learn:
β’ How Twilio ConversationRelay enables low-latency AI calls
β’ How to generate and securely manage a Gemini API key
β’ How to configure a Twilio phone number for voice webhooks
β’ How to build a FastAPI WebSocket server
β’ How to maintain per-caller session memory using Call SID
β’ How to prevent memory leaks in high-volume call systems
Timestamps:
00:00 β Introduction & architecture overview
00:35 β End-to-end call flow explained
01:09 β Required tools (Twilio, Gemini, Enro/ngrok)
01:45 β Setting up FastAPI & dependencies
02:17 β Environment variables & system prompt
03:35 β Session management with Call SID
04:12 β TwiML & ConversationRelay breakdown
05:35 β WebSocket event handling
06:12 β Maintaining conversation context
06:56 β Cleanup & session teardown
07:36 β Exposing your server with Enro
08:56 β Configuring your Twilio number
10:11 β Live demo call with Gemini
11:17 β Context awareness & latency discussion
11:53 β Next steps & enhancements
Tech Stack:
Python
FastAPI
WebSockets
Twilio Voice
TwiML
Google Gemini API
ConversationRelay
From here, you can extend this assistant with tool calling, external APIs, CRM integrations, or custom TTS providers like ElevenLabs.
Subscribe to TwilioDevs for more hands-on AI, voice, and real-time communication tutorials.
π» Sign up for a Twilio account here: twil.io/trytwilio-yt
π Subscribe for more Twilio updates: twil.io/sub-twiliodevs
#Twilio #GoogleGemini #VoiceAI #FastAPI #WebSockets
Build a real-time AI voice assistant using Twilio Voice and Google Gemini. In this step-by-step tutorial, youβll connect live phone calls to Gemini using Twilio ConversationRelay, FastAPI, and WebSockets β with incredibly low latency.
π Full Source Code: github.com/rishabkumar7/twilio-cr-gemini-python
In this video, youβll build a production-ready voice AI assistant that can answer real phone calls and maintain conversation context.
When someone calls your Twilio number:
β’ Twilio hits your /twiml endpoint
β’ TwiML opens a WebSocket connection
β’ Twilio streams speech transcripts in real time
β’ Your server sends prompts to Gemini
β’ Gemini generates a response
β’ Twilio converts it back to speech instantly
The result: a fully conversational AI assistant powered by Gemini 3 Flash.
What youβll learn:
β’ How Twilio ConversationRelay enables low-latency AI calls
β’ How to generate and securely manage a Gemini API key
β’ How to configure a Twilio phone number for voice webhooks
β’ How to build a FastAPI WebSocket server
β’ How to maintain per-caller session memory using Call SID
β’ How to prevent memory leaks in high-volume call systems
Timestamps:
00:00 β Introduction & architecture overview
00:35 β End-to-end call flow explained
01:09 β Required tools (Twilio, Gemini, Enro/ngrok)
01:45 β Setting up FastAPI & dependencies
02:17 β Environment variables & system prompt
03:35 β Session management with Call SID
04:12 β TwiML & ConversationRelay breakdown
05:35 β WebSocket event handling
06:12 β Maintaining conversation context
06:56 β Cleanup & session teardown
07:36 β Exposing your server with Enro
08:56 β Configuring your Twilio number
10:11 β Live demo call with Gemini
11:17 β Context awareness & latency discussion
11:53 β Next steps & enhancements
Tech Stack:
Python
FastAPI
WebSockets
Twilio Voice
TwiML
Google Gemini API
ConversationRelay
From here, you can extend this assistant with tool calling, external APIs, CRM integrations, or custom TTS providers like ElevenLabs.
Subscribe to TwilioDevs for more hands-on AI, voice, and real-time communication tutorials.
π» Sign up for a Twilio account here: twil.io/trytwilio-yt
π Subscribe for more Twilio updates: twil.io/sub-twiliodevs
#Twilio #GoogleGemini #VoiceAI #FastAPI #WebSockets










