Example: Answering an incoming call
This example answers an inbound Voximplant call and bridges audio to Deepgram Voice Agent 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 Deepgram API key secret value in Voximplant
ApplicationStorageunderDEEPGRAM_API_KEY.
Session setup
The Deepgram Voice Agent session is configured via a settingsOptions object that’s passed directly to Deepgram.createVoiceAgentClient(...).
In the full example, see SETTINGS_OPTIONS.agent:
listen: speech-to-text provider (for exampletype: "deepgram")think: LLM provider + promptspeak: text-to-speech provider
Don’t set audio settings
When using the VoxEngine connector, do not include audio settings in the Deepgram settings object — audio is handled by the connector for optimal telephony quality.
Connect call audio
Once you’ve created the Deepgram.VoiceAgentClient, you need to connect audio both ways between the phone call and the agent.
In the example, this is done with:
This bridges media between a Call and a Deepgram.VoiceAgentClient. You can also do the same thing explicitly, one direction at a time, using sendMediaTo:
Mid-session updates
After the client is created (see voiceAgentClient in the scenario), you can update the agent mid-call without reconnecting using Deepgram.VoiceAgentClient methods.
These methods are documented in the Voximplant reference:
Barge-in
To keep the conversation interruption-friendly, the example listens for Deepgram.VoiceAgentEvents.UserStartedSpeaking and clears the media buffer so any in-progress TTS audio is canceled when the caller starts talking:
Events
In the scenario, a focused handler captures the transcript via Deepgram.VoiceAgentEvents.ConversationText, and a second handler logs a set of lifecycle/debug events:
The client supports both Deepgram Voice Agent events and Deepgram WebSocket media events (see addEventListener / removeEventListener in the VoiceAgentClient reference):
Deepgram.VoiceAgentEvents:Welcome,SettingsApplied,AgentThinking,ConversationText,UserStartedSpeaking,AgentAudioDone,FunctionCallRequest,FunctionCallResponse,PromptUpdated,SpeakUpdated,History,HTTPResponse,ConnectorInformation,Warning,Error,WebSocketError,UnknownDeepgram.Events:WebSocketMediaStarted,WebSocketMediaEnded
Notes
See the VoxEngine API Reference for more details.