Example: Placing an outbound call
Example: Placing an outbound call
For the complete documentation index, see llms.txt.
This example starts a VoxEngine session, places an outbound PSTN call, and bridges audio to OpenAI Realtime once the callee answers. Select a model version to keep the session configuration and complete scenario synchronized. gpt-realtime-2.1 is the default for new applications.
Jump to the Full VoxEngine scenarios.
Prerequisites
- Store your OpenAI API key in Voximplant Secrets under
OPENAI_API_KEY. - Ensure outbound calling is enabled for your Voximplant application and that your caller ID is verified.
Outbound call parameters
The example expects destination and caller ID in customData (read via VoxEngine.customData()):
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 with the Management API startScenarios method. Pass rule_id and the same JSON string in script_custom_data.
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:
Session setup
The outbound call setup is shared between versions. Only the Realtime model and session configuration change.
GPT Realtime 2.1
GPT Realtime 1.5
The example configures the OpenAI Realtime session with a short system prompt, enables semantic VAD, and uses low reasoning effort.
Connect call audio
After the callee answers, the example bridges audio both ways:
Barge-in
The scenario clears buffered model audio whenever OpenAI detects caller speech: