> ## 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.

# Dynamic Variables in DialNexa Agents

> Use DialNexa dynamic variables to personalize prompts, calls, functions, CSV campaigns, workflows, and test conversations.

Dynamic variables in DialNexa are `{{variable_name}}` placeholders that make one agent behave differently for each caller. Instead of creating separate agents per customer segment, you write one prompt with variables and supply different values at call time. Variables work in prompts, welcome messages, voicemail messages, function parameters, and post-call analysis fields.

> [!TIP]
>
> Dynamic variables are personalization with a seatbelt. Without a fallback default, a variable with no value is replaced with nothing, so the agent says the sentence with a gap: `Hi {{first_name}}, ...` becomes `Hi , ...`.

## Before You Begin

List the values that change per caller, every surface that supplies them, and safe fallback text for missing data. Do not use secrets or values that should never appear in a transcript.

## Syntax

Wrap any variable name in double curly braces:

```
{{variable_name}}
```

Variable names are case-sensitive. `{{first_name}}` and `{{First_Name}}` are treated as different variables. Use lowercase with underscores for consistency.

The builder validates variable syntax in prompt-related fields. Variable names should start with a letter or underscore and can contain letters, numbers, underscores, or dots. Empty variables, unclosed braces, and malformed patterns such as `{{amount} }` are rejected before save or test call.

You can place variables anywhere in a prompt:

```
You are calling {{first_name}} {{last_name}} at {{company_name}}.
Their subscription renews on {{renewal_date}} and the current balance is {{balance_amount}}.
```

The agent builder scans the prompt text, welcome message, and voicemail message for placeholders and lists each detected variable in **Agent Settings > Fallback Settings**, where you can set a default value.

## Where Variables Can Be Used

| Location | Example usage |
| - | - |
| System prompt | `You are calling {{first_name}} about their overdue invoice of {{amount_due}}.` |
| Welcome message | `Hi {{first_name}}, this is Priya from Metro Clinic.` |
| Voicemail message | `Hi {{first_name}}, please call us back about your appointment on {{appointment_date}}.` |
| Function parameters | Pass `{{account_id}}` as a parameter to a CRM lookup API call |
| Post-call analysis field prompts | `Did {{first_name}} confirm the appointment?` |

## Where Variable Values Come From

DialNexa does not fill any `{{...}}` variable on its own. Every value comes from the call's `metadata`, a batch file or workflow lead column, or the version's fallback defaults. To use the caller's number, a call reference or the agent's name in a prompt, pass it as a variable with those values.

The current date, time and timezone are added for you, but as a line appended to the prompt rather than as a variable. Set the agent's timezone so they match where your callers are.

## How to Pass Variable Values

Variable values can come from several sources. When multiple sources supply a value for the same variable, the priority order is: API / batch CSV / workflow > test call modal > default fallback.

> [accordion] API (outbound call request)
>
> When starting an outbound call via the DialNexa API, include a `variables` or `metadata` object in the request body with key-value pairs matching your variable names.
>
> ```json theme={null}
> {
>   "agent_id": "...",
>   "to": "+919876543210",
>   "variables": {
>     "first_name": "Rahul",
>     "renewal_date": "June 15",
>     "balance_amount": "3,200"
>   }
> }
> ```
>
> See the API reference for the exact request schema.

> [accordion] Batch CSV (batch calls)
>
> When creating a batch call campaign, upload a CSV file where each row is one call recipient. Column headers must match the variable names used in the agent.
>
> ```csv theme={null}
> phone_number,first_name,renewal_date,balance_amount
> +919876543210,Rahul,June 15,3200
> +919812345678,Anjali,June 18,1450
> ```
>
> The batch call engine maps each CSV column to the corresponding variable for that call. See [Batch Recipient Files](https://dialnexa.com/docs/batch-calls/recipient-files.md) for file format requirements.

> [accordion] Workflow lead variables
>
> In the workflow builder, leads carry their own variable values. When a workflow triggers a call, the lead's variables are passed to the agent automatically. Variable keys in the lead record must match the variable names in the agent prompt.
>
> See [Workflow Lead Variables](https://dialnexa.com/docs/workflows/lead-variables-and-call-attributes.md) for how to define and map lead variables.

> [accordion] Test call modal
>
> When placing a test call from the agent builder or Agents list, a modal appears before dialing. Enter variable values in the modal fields to test how the agent renders the prompt with specific data.
>
> Test call modal values are not saved as defaults. They apply only to that specific test call.

> [accordion] Fallback defaults (Agent Settings)
>
> Default values for each variable are configured in **Agent Settings > Fallback Settings**. These are used when no other source provides a value for the variable.
>
> Fallback defaults are saved as part of the agent version when published. They are the safety net for any call where the upstream data is incomplete.

## Setting Fallback Defaults

**1. Open Agent Settings**

In the agent builder, click the **Settings** tab, then navigate to **Fallback Settings**.

**2. Find detected variables**

The builder lists every `{{variable_name}}` it found in the prompt, welcome message, and voicemail message.

**3. Enter a default value for each variable**

Enter a fallback value that is safe to use when the real value is unavailable. For names, a generic fallback like "there" works: "Hi there" instead of `Hi {{first_name}}`. For amounts or dates, use a placeholder that prompts the caller to confirm: "your upcoming appointment".

**4. Save and include in publish**

Save the settings. Fallback values are included in the published version snapshot.

> [!WARNING]
>
> Leaving a fallback default empty does not cause an error on its own, but it means the placeholder is replaced with nothing if no value is supplied at call time, leaving a gap in what the agent says. Always set a fallback for every variable in your prompt.

## Testing Variable Rendering

Before publishing, test that variables render correctly:

1. Open the agent builder and click the test call button.
2. In the test call modal, enter values for each variable.
3. Place the test call and listen to the welcome message and first prompt. Confirm the values appear correctly in speech.
4. Check the call transcript in Call History to see how variables were rendered in writing.

## Use Dynamic Values As Speech Recognition Hints

For cascaded agents using Deepgram, Soniox, or Sarvam, **Boost dynamic variables** can add each test-call or batch-row value to the transcriber's recognition hints for that call. This is useful for uncommon names, cities, plan names, and identifiers that change for every recipient.

The setting does not change variable rendering and does not send variable names as hints. It sanitizes the resolved values, appends them after the agent's manually configured Boosted Keywords, and stops when the combined limits are full. Existing agents are opted out by default. Enable it under [Speech Settings](https://dialnexa.com/docs/agent-settings/speech-settings.md#boost-dynamic-variables), then compare the recording and transcript with the same test data before using it in a campaign.

## Variable Mistakes to Avoid

> [accordion] Variable name mismatch between agent and CSV
>
> If the agent uses `{{first_name}}` but the CSV column is `FirstName`, the value will not map. Variable names are case-sensitive and must match exactly. Use lowercase underscore convention in both the agent prompt and the CSV header.

> [accordion] Empty fallback value
>
> A variable with no fallback and no runtime value is replaced with nothing. The agent builder may warn when saving a version with empty fallbacks. Treat this as a required field, not optional.

> [accordion] Sensitive data in variables
>
> Avoid placing passwords, full credit card numbers, government ID numbers, or other highly sensitive information in dynamic variables. Variables appear in call transcripts and logs. Use masked fields or post-call analysis if you need to capture sensitive outcomes.

> [accordion] Variable added after publishing
>
> If you add a new `{{variable}}` to the prompt and publish, batches and calls pinned to an older published version will not have that variable defined. Check pinned batches after publishing a version that introduces new variables.

> [accordion] Assuming workflow variables match agent variables
>
> Workflow lead variable keys and agent variable names must match. A mismatch means the workflow passes a value the agent does not recognize, and the agent falls back to the default. Audit the key names in both places when connecting a workflow to an agent.

> [accordion] Adding agent\_transfer\_destinations to a Single Prompt Agent
>
> `agent_transfer_destinations` and the legacy `transfer_agent_destinations` key are valid only for Conversational Flow Agents with call-transfer nodes. Creating or saving a Single Prompt Agent with either key returns `400 Bad Request`.

## Variables in Functions

You can use dynamic variables as parameter values in agent functions. For example, pass `{{account_id}}` to a customer lookup endpoint:

```json theme={null}
{
  "url": "https://api.example.com/customers/{{account_id}}",
  "method": "GET"
}
```

The variable is resolved at call time before the function is called. If the variable has no value, the fallback default is used. If neither is set, the literal placeholder text is sent to the API, which will likely cause the function to fail.

## Verify Dynamic Variables

Test one call with complete values and one with a missing value. Confirm the welcome message, prompt, functions, transfer path, transcript, and fallback behavior use the expected value.

## Recap

Use stable variable names, supply values from every launch path, add safe defaults, and test missing data. Never place secrets or information that should not appear in transcripts inside dynamic variables.

## Related Reading

> [card] [Batch Recipient Files](https://dialnexa.com/docs/batch-calls/recipient-files.md)
>
> Map CSV columns to agent variables for batch campaigns.

> [card] [Workflow Lead Variables](https://dialnexa.com/docs/workflows/lead-variables-and-call-attributes.md)
>
> Connect workflow lead data to agent prompts.

> [card] [Agent Settings](https://dialnexa.com/docs/agent-settings/overview.md)
>
> Set fallback defaults in Fallback Settings.

> [card] [Prompting Guide](https://dialnexa.com/docs/agents/prompts-and-welcome-messages.md)
>
> Write prompts that use variables effectively.

> [card] [Variables And Fallbacks Video](https://dialnexa.com/docs/tutorials/platform-videos/dynamic-variables-and-fallback-settings.md)
>
> Watch the dynamic variable and fallback configuration walkthrough.


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