This project implements a locally hosted Pipecat instance that routes audio between Twilio and the Gemini Live API using the Gemini 3.1 live audio model.
- Python 3.10+
- Twilio Account: A phone number with voice capabilities and a TwiML App.
- Google AI Studio API Key: Access to the Gemini API.
- Nginx Proxy Manager (NPM): Or a similar reverse proxy to handle SSL and WebSockets.
- Create Stack: In Portainer, create a new Stack using this repository.
- Environment Variables: Add the following variables in the Portainer "Environment variables" section:
GOOGLE_API_KEYTWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENPortainer will automatically write these tostack.envinside the container.
- Deploy: Deploy the stack. The bot will listen on host port
17293.
- Proxy Host: Create a new Proxy Host in Nginx Proxy Manager.
- Details:
- Forward Host/IP: The local IP of your Docker host.
- Forward Port:
17293 - Websockets Support: ENABLED (Required for audio streaming).
- SSL: Enable "Force SSL" and ensure you have a valid certificate (required by Twilio).
- TwiML App: In the Twilio Console, create or update a TwiML App.
- Voice Request URL: Set this to
https://your-public-domain.com/twiml. - Method:
HTTP GET. - Phone Number: Assign your TwiML App to your active Twilio phone number.
- When a call comes in, Twilio sends a GET request to
/twiml. - The server responds with TwiML instructions to connect the call to a WebSocket stream (
/ws). - Pipecat's
FastAPIWebsocketTransporthandles the bidirectional audio stream from Twilio. - The
GeminiLiveLLMServiceinteracts withgemini-3.1-flash-live-previewto provide real-time speech-to-speech AI interaction.