Example: Placing an outbound call
Example: Placing an outbound call
For the complete documentation index, see llms.txt.
Overview
This example starts a VoxEngine session, places an outbound PSTN call, and connects the callee to Gemini Live API when the session is ready.
⬇️ Jump to the Full VoxEngine scenario.
Gemini 3.1 Flash Live Preview
This page reflects the current gemini-3.1-flash-live-preview flow from Google’s Live API docs:
https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-live-preview
Prerequisites
- Create a routing rule with this scenario attached (outgoing calls don’t use patterns) so you can run it from the Control Panel or trigger it via API: https://voximplant.com/docs/getting-started/basic-concepts/routing-rules
- Have a PSTN
destinationnumber you can dial (E.164 format), for example your mobile number. - Configure a valid outbound
callerId(for example, a rented Voximplant number or a verified caller ID): https://voximplant.com/docs/getting-started/basic-concepts/phone-numbers - Pass
destinationandcallerIdas routing rule custom data (this example reads them fromVoxEngine.customData()):{"destination":"+15551234567","callerId":"+15557654321"}. - Store your Gemini API key in Voximplant
ApplicationStorageunderGEMINI_API_KEY.
About outbound Caller ID
VoxEngine.callPSTN(...) requires a valid callback-capable caller ID (for example, a rented Voximplant number or a verified caller ID). See https://voximplant.com/docs/getting-started/basic-concepts/phone-numbers.
Launch the routing rule
For quick testing, you can start this outbound scenario from the Voximplant Control Panel:
- Open your Voximplant application and go to the Routing tab.
- Select the routing rule that has this scenario attached.
- Click Run.
- Provide Custom data (max 200 bytes) with
destinationandcallerId:
For production, start the routing rule via Management API startScenarios (pass rule_id, and pass the same JSON string in script_custom_data): https://voximplant.com/docs/references/httpapi/scenarios#startscenarios
Alternate outbound destinations
This example uses VoxEngine.callPSTN(...) for PSTN dialing. You can also route outbound calls to other destination types in VoxEngine:
- SIP (
VoxEngine.callSIP): dial a SIP URI to reach a PBX, carrier, SIP trunk, or other SIP endpoint. - WhatsApp (
VoxEngine.callWhatsappUser): place a WhatsApp Business-initiated call (requires a WhatsApp Business account and enabled numbers). - Voximplant users (
VoxEngine.callUser): calls another app user inside the same Voximplant application such as web SDK, mobile SDK, or SIP user.
Relevant guides:
Notes
- The example uses the Gemini Developer API (
Gemini.Backend.GEMINI_API), not Vertex AI. - The current sample uses
gemini-3.1-flash-live-preview. - Audio is connected after
Gemini.LiveAPIEvents.SetupCompletefires.
Gemini 2.5 compatibility
If you are adapting an older 2.5 outbound sample, use sendRealtimeInput(...) for the initial prompt on 3.1. The current 3.1 sample also uses thinkingConfig: { thinkingLevel: "minimal" }.
See the VoxEngine API Reference for more details.