Example: Function calling
This example answers an inbound call, connects it to Ultravox, and handles client tool invocations via Ultravox data messages.
⬇️ 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 Ultravox API key in Voximplant
ApplicationStorageunderULTRAVOX_API_KEY. - Configure tools in Ultravox (agent or call config) so tool invocations are emitted during the call.
Tool invocation flow
Ultravox emits a ClientToolInvocation data message when the agent calls a client tool. The event payload includes:
toolNameinvocationIdparameters(tool input)
The example listens for these events and returns a client_tool_result response using voiceAIClient.clientToolResult(...).
Tool response (from the example)
Full VoxEngine scenario
voxeengine-ultravox-function-calling.js