Skip to main content
NavTalk supports function calling to integrate digital humans with external systems, enabling the execution of custom functions and API calls during conversations. This allows the digital human to interact with weather APIs, databases, CRM systems, IoT devices, and other external services.
Provider Support:
  • OpenAIRealtime: Function calling can be defined and configured directly via API parameters (as shown in this guide). You can pass function definitions programmatically.
  • ElevenLabs: Function calling must be configured through the ElevenLabs dashboard. It cannot be defined via API parameters - you need to set up functions in your ElevenLabs account settings before using them.
1

Define Function Tools

Define the functions that can be called by including them in the tools array. In v2, function tools configuration is sent immediately after the WebSocket connection is established (in the onopen event), not after receiving realtime.session.created:
You can define multiple functions in the tools array. Each function should have a unique name, clear description, and well-defined parameters. Function tools configuration is sent immediately after the WebSocket connection is established, not after receiving realtime.session.created. Connection identity is passed through the WebSocket URL (license plus name or avatarId); per-session configuration such as voice, prompt, and tools is sent with realtime.input_config.
2

Listen for Function Call Events

Listen for function call events in your WebSocket message handler. When a function needs to be called, you’ll receive a realtime.response.function_call_arguments.done event:
The realtime.response.function_call_arguments.done event contains the following properties:
string
Name of the function to be called.Example: "function_call_judge"
string | object
Function call parameters. May be a JSON string or already parsed object containing the parameter values.Example: "{\"userInput\": \"What's the weather in Beijing?\"}" or {"userInput": "What's the weather in Beijing?"}
string
Unique identifier for this function call. Required when returning results - use this call_id when sending the function call output back to the AI.Example: "call-123456"
3

Handle Function Calls

Parse the function call arguments and execute your custom logic:
4

Integrate External APIs

Call your external APIs or backend services to handle the business logic:
5

Optionally Return Results to AI

After processing the function call, send the result back only when you want the AI to continue the conversation using the function result. If the function call only needs to trigger external business logic and no follow-up AI response is needed, you can omit this step.
Send realtime.function_call_output only when the AI should use the function result to generate a follow-up reply. Set data.reply to "1" to trigger that reply. If no follow-up AI interaction is needed, handle the function result in your application and skip this message.

Common Use Cases

Function calling allows you to extend the digital human’s capabilities beyond conversation. Integrate with any REST API, database, or backend service to create powerful, context-aware applications.