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.
Jump to the Full VoxEngine scenario.
Prerequisites
- Store your OpenAI API key in Voximplant
ApplicationStorageunderOPENAI_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 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:
Connect call audio
After the callee answers, the example bridges audio both ways:
Barge-in
Notes
See the VoxEngine API Reference for more details.