> For the complete documentation index, see [llms.txt](https://docs.dapta.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dapta.ai/ai-voice-agents/how-to-set-up-your-ai-voice-agent/using-dynamic-variables.md).

# Using dynamic variables

{% embed url="<https://www.tella.tv/video/dynamic-input-variables-ejkk?b=0>" %}

Dynamic variables are placeholders used in AI prompts to personalize interactions by dynamically inserting specific information during a conversation. They are essential for tailoring the AI's responses to the individual needs and context of each customer interaction.

### Structuring the Input Variables Section <a href="#structuring-the-input-variables-section" id="structuring-the-input-variables-section"></a>

#### Purpose <a href="#purpose" id="purpose"></a>

The Input Variables section is crucial for defining the dynamic variables that will be used throughout the AI prompt. This section ensures that each variable is clearly documented, providing clarity on its purpose and usage.

Common use cases:

* Pre-fill variables previous to an outbound call for customization
* Grab user's name from database and greet them by their name
* Confirm user's address in a database
* Confirm an appointment with user in existing database

#### Notation <a href="#notation" id="notation"></a>

* Dynamic variables are enclosed in double curly braces, e.g., **{{variable\_name}}**.
* Each variable should be listed with a brief description of its role in the conversation.
* These variables go directly in your prompt and can be tested during test calls.

#### Declaration Example <a href="#declaration-example" id="declaration-example"></a>

* **{{customer\_name}}**: The name of the customer.
* **{{product\_interest}}**: The product the customer is interested in.
* **{{customer\_email}}**: The email address of the customer.
* **{{customer\_company}}**: The company the customer represents.

<figure><img src="/files/aTIAGQYpnM4xDONZB7eD" alt=""><figcaption></figcaption></figure>

#### Usage Example <a href="#usage-example" id="usage-example"></a>

Comment

* Greeting: "Hello {{customer\_name}}, I see you're interested in our {{product\_interest}}."Comment
* Company Reference: "I understand {{customer\_company}} has been experiencing {{specific\_issue}}."

***

#### Placement <a href="#placement" id="placement"></a>

Dynamic variables should be placed in the `# Input Variables` section of the prompt. It is recommended to position them at the end of this section to ensure clarity and organization.

<figure><img src="/files/t54jyTRSkuDwKN4QKceK" alt=""><figcaption></figcaption></figure>

***

### Reserved variable names <a href="#reserved-variable-names" id="reserved-variable-names"></a>

A few variable names are **reserved**. Dapta fills these in automatically when the call happens, so you don't — and can't — set them yourself. When you use one of them in your prompt, it:

* resolves to the system value during the call, and
* does **not** appear as a fillable field in the Input Variables section. Any value you try to provide for it is ignored.

| Variable                      | Resolves to                                                                                                                 |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `{{call_id}}`                 | The call's unique ID                                                                                                        |
| `{{direction}}`               | `inbound` or `outbound`                                                                                                     |
| `{{user_number}}`             | The other party's number (the caller on inbound calls, the person being called on outbound calls)                           |
| `{{agent_number}}`            | Your agent's number (the number being called on inbound calls, the caller on outbound calls)                                |
| `{{current_time}}`            | The current time in the `America/Los_Angeles` timezone                                                                      |
| `{{current_time_<timezone>}}` | The current time in a specific timezone — for example `{{current_time_America/Bogota}}` or `{{current_time_Europe/Madrid}}` |

{% hint style="info" %}

* Any name that contains `current_time` is reserved, including one with a timezone suffix. The other four names are matched **exactly**.
* Names are **case-sensitive** and must be lowercase exactly as shown above.
* If you use an invalid timezone, the `{{current_time_<timezone>}}` placeholder is left blank.
  {% endhint %}

***

### Which names are accepted as variables <a href="#which-names-are-accepted-as-variables" id="which-names-are-accepted-as-variables"></a>

For a placeholder to be picked up as a fillable variable, its name has to be a plain identifier. A name qualifies only when **all** of these are true:

1. It starts with a letter (`a–z`, `A–Z`) or an underscore (`_`).
2. Every other character is a letter, a digit (`0–9`), or an underscore.
3. No other characters appear anywhere — no dots, hyphens, slashes, spaces, `@`, parentheses, brackets, or quotes.
4. The name is not empty.

A single invalid character anywhere disqualifies the whole name. Placeholders that break these rules are still allowed in your prompt text, but they're treated as template expressions and are **not** listed as fillable variables.

{% hint style="info" %}
These rules only apply to the variables **you** create. The [reserved system variables](#reserved-variable-names) are resolved automatically regardless of these rules — which is why `{{current_time_America/Bogota}}` works even though it contains a slash.
{% endhint %}

✅ **Valid:** `{{contact_name}}`, `{{_foo}}`, `{{order2}}`, `{{x}}`

The following examples are **not** shown as variables:

| Placeholder                      | Why                                             |
| -------------------------------- | ----------------------------------------------- |
| `{{user.email}}`                 | Contains a dot                                  |
| `{{contact_name.split(" ")[0]}}` | Dots, parentheses, quotes, spaces, and brackets |
| `{{contact-name}}`               | Contains a hyphen                               |
| `{{first name}}`                 | Contains a space                                |
| `{{1st_name}}`                   | Starts with a digit                             |
| `{{user@id}}`                    | Contains `@`                                    |
| `{{}}`                           | Empty                                           |

***

### Best Practices <a href="#best-practices" id="best-practices"></a>

* Ensure all dynamic variables are accurately populated before the conversation begins.
* Regularly update the list of dynamic variables to reflect any changes in business needs or customer interactions.
* Test the implementation of dynamic variables to ensure they function as expected in various scenarios.

***

### Conclusion <a href="#conclusion" id="conclusion"></a>

Dynamic variables are a powerful tool for creating personalized and effective AI interactions. By understanding and implementing them correctly, businesses can significantly improve the quality of their customer engagements.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.dapta.ai/ai-voice-agents/how-to-set-up-your-ai-voice-agent/using-dynamic-variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
