Example: Answering an incoming call
This example answers an inbound Voximplant call and bridges audio to ElevenLabs Agents for real-time speech-to-speech conversations.
Jump to the Full VoxEngine scenario.
Prerequisites
- Set up an inbound entrypoint for the caller:
- Phone number: https://voximplant.com/docs/getting-started/basic-concepts/phone-numbers
- WhatsApp: https://voximplant.com/docs/guides/integrations/whatsapp
- SIP user / SIP registration: https://voximplant.com/docs/guides/calls/sip
- Voximplant user: https://voximplant.com/docs/getting-started/basic-concepts/users (see also https://voximplant.com/docs/guides/calls/scenarios#how-to-call-a-voximplant-user)
- Create a routing rule that points the destination (number / WhatsApp / SIP username) to this scenario: https://voximplant.com/docs/getting-started/basic-concepts/routing-rules
- Store your ElevenLabs API key in Voximplant
ApplicationStorageunderELEVENLABS_API_KEY. - Store your ElevenLabs Agent ID in Voximplant
ApplicationStorageunderELEVENLABS_AGENT_ID.
Session setup
ElevenLabs Agents are configured in the ElevenLabs console. In VoxEngine, you only need the API key and agent ID.
In the full example, the client is created with:
Configure prompts and tools in ElevenLabs
Prompts, voices, and tools live in your ElevenLabs Agent configuration. Update them in the ElevenLabs console and reuse the same agent ID in VoxEngine.
Connect call audio
Once you have an ElevenLabs.AgentsClient, bridge audio both ways between the call and the agent:
Barge-in
To keep the conversation interruption-friendly, the example listens for ElevenLabs.AgentsEvents.Interruption and clears the media buffer so any in-progress TTS audio is canceled when the caller starts talking:
Events
The scenario logs transcripts and key lifecycle events. For example:
Notes
See the VoxEngine API Reference for more details.