> ## Documentation Index
> Fetch the complete documentation index at: https://dialnexa.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# DialNexa Custom Functions

> Configure DialNexa custom functions with API endpoints, authentication, parameters, JSON schemas, timeouts, and response variables.

DialNexa custom functions let an agent call your external API during a conversation. Use a custom function when the agent needs live data or needs to create something in a system that is not already handled by a dashboard integration.

![DialNexa Custom Function modal showing name, description, holding message, API endpoint, API token, timeout, headers, and save controls.](https://mintcdn.com/dialnexa/0efoAN-6So4r-6NC/images/documentation/screenshots/custom-function-modal.png?fit=max\&auto=format\&n=0efoAN-6So4r-6NC\&q=85\&s=c885de7165b638c47a3d76dc5a5570b6)

> [!WARNING]
>
> A custom function turns a conversation into an integration. That is useful, and also a reason to test like you mean it.

## Custom Function Fields

Each field changes how the agent calls the external service.

| Field | Purpose |
| - | - |
| Description | Tells the model when and why to use the function. |
| API Endpoint | The URL of the service the function calls. |
| HTTP Method | The request method used by the function. |
| API Token | Optional bearer-style credential for the target API. |
| Timeout | Maximum wait time in milliseconds. The default reducer value is `120000`. |
| Headers | Additional key-value headers. |
| Query Parameters | Key-value values appended to the URL. |
| Response Variables | Named values the agent can use after the API response. |
| JSON Schema | Defines the format the model should return for function arguments. |

Use [dashboard integrations](https://dialnexa.com/docs/dashboard-integrations/overview.md) when the action is available as a managed provider connection. Use a custom function when you own the API contract, need custom authentication, or need response variables from your own service during the call.

## Dynamic Authorization For Chained API Calls

Custom function authentication can use values returned or supplied during the same tool call flow. This is useful when one function obtains a token and a later function must send that token to another API.

| Pattern | Behavior |
| - | - |
| Static API token | Saved token is sent as `Authorization` when no custom header already sets it. |
| Token argument | Arguments named `access_token`, `auth_token`, `api_token`, or `authorization` can be used for the Authorization header. |
| Template token | API token values such as `Bearer %(access_token)s` are filled from function arguments. |
| Template headers | Custom headers can also use `%(key)s` substitutions from function arguments. |

Bare token values are normalized to `Bearer <token>` when they come from token argument fields. If the argument is named `authorization`, DialNexa sends the value as provided.

## Example JSON Schema Pattern

```json theme={null}
{
  "type": "object",
  "properties": {
    "customer_id": { "type": "string" },
    "requested_slot": { "type": "string" }
  },
  "required": ["customer_id"]
}
```

## Speech Behavior While A Function Runs

Callers should not sit in silence without context.

> [card] [Holding message](https://dialnexa.com/docs/voice-ai/latency-turn-taking-and-interruptions.md)
>
> Short message spoken before calling the tool, useful when the API may take time.

> [card] [Speak during execution](https://dialnexa.com/docs/agent-settings/functions.md)
>
> Allows the agent to keep the caller informed while the tool runs.

> [card] [Speak after execution](https://dialnexa.com/docs/monitoring/call-detail-page.md)
>
> Lets the agent explain the result after the tool returns.

> [card] [Response variables](https://dialnexa.com/docs/agents/dynamic-variables.md)
>
> Expose API result values that the agent can mention or use in the next turn.

For cascaded agents, DialNexa keeps an in-flight custom function running when the caller barges in or when a normal turn cleanup starts. This protects real side effects such as bookings from being cancelled halfway through. The call does not use this protection for a true call-ending teardown, and Speech to Speech agents use a separate realtime path.

If the model selects a function but omits a required schema field, the agent asks for that specific missing value instead of using a generic repeat request. Write human-readable field names and descriptions because callers may hear them reflected in the clarification. After the caller supplies the value, confirm the function runs once and the returned result is spoken before the call ends.

## Custom Function Review Questions

> [accordion] Can the function fail gracefully?
>
> Write prompt instructions for API errors, missing data, and timeouts.

> [accordion] Is the timeout realistic?
>
> A very long timeout may keep a caller waiting. A very short one may fail healthy APIs.

> [accordion] Are secrets in the right place?
>
> Use the API token or connection fields, not dynamic variables in prompts.

> [accordion] Can the model produce valid arguments?
>
> Keep JSON schema simple and test edge cases.

> [accordion] What happens if the caller interrupts while the API is running?
>
> On cascaded agents, the in-flight function continues so its side effect and result are not lost. Test the interruption path and make the external API idempotent because the caller may still ask to retry.

## Related Reading

> [card] [Functions](https://dialnexa.com/docs/agent-settings/functions.md)
>
> See all function types.

> [card] [External Webhooks](https://dialnexa.com/docs/api-access/external-webhooks.md)
>
> Configure event delivery separately.

> [card] [Dashboard Integrations](https://dialnexa.com/docs/dashboard-integrations/overview.md)
>
> Use managed provider actions when they fit the job.

> [card] [Testing Agents](https://dialnexa.com/docs/agents/testing-agents.md)
>
> Test function calls in real calls.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.