For the complete documentation index, see llms.txt. This page is also available as Markdown.

Using dynamic variables

Define dynamic variables to personalize voice agent prompts, see which names Dapta reserves, and store custom action responses as variables mid-call.

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.

What are dynamic variables used for?

Dynamic variables are placeholders, written as {{variable_name}}, that Dapta swaps for real values during a call. Use them to pre-fill details before an outbound call, greet a caller by name pulled from your database, confirm a stored address, or confirm an existing appointment, so every conversation is personalized instead of generic.

Structuring the Input Variables Section

Purpose

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

  • 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

  • {{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.

Usage Example

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

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.


Reserved variable names

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}}

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


Which names are accepted as variables

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.

These rules only apply to the variables you create. The reserved system variables are resolved automatically regardless of these rules — which is why {{current_time_America/Bogota}} works even though it contains a slash.

✅ 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


Variables from action responses

Besides pre-filling variables before a call, your agent can create new dynamic variables during the call from the response of a Custom Action.

When configuring a Custom Action (Settings → Agent Actions → Add → Custom Action), use the Store fields as variables section:

  • "Field in the response": the field to read from the action's response, e.g. response.tracking.

  • "Variable name": the name of the variable that will store the value, e.g. tracking_number.

Once the action runs during a call, the value becomes available as a regular dynamic variable — for example {{tracking_number}} — and can be used later in the same call, such as in a transfer message.

Add one row per field you want to store. Rows with an empty field or variable name are ignored.


Best Practices

  • 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

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.

Last updated