> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# onFunctionCall

> Dispatch a SWAIG function call to its registered handler.

[define-tool]: /docs/server-sdks/reference/typescript/agents/swml-service/define-tool

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

Dispatch a SWAIG function call to the handler registered via
[`defineTool()`][define-tool]. Returns `null` when the named function isn't
registered or has no handler. Called automatically by the `POST /swaig`
dispatch path; subclasses (such as `AgentBase`) override it to add session-token
validation and result normalization.

## **Parameters**

Name of the SWAIG function to dispatch.

Parsed arguments for the function.

The full raw SWAIG request payload, including metadata such as `call_id` and
`global_data`.

## **Returns**

[`FunctionResult`][functionresult]` | Record<string, unknown> | string | void | null`
(or a `Promise` of these) -- The handler's result, or `null` when no matching
function is registered.