Best practices

Variables are essential for creating dynamic, personalized, and context-aware experiences. They allow your AI Agent to collect information from users, track conversation state, and pass data into elements like Action and Playbooks. This topic outlines best practices for designing, storing, and reusing variables effectively, along with common pitfalls and examples of good variable usage.

Use clear and specific variable names

Choose names that describe what the variable stores, rather than generic labels. Clear naming helps both the AI Agent and future builders understand the variable’s purpose.

Good examples

  • user_email
  • shipping_address
  • account_tier

Avoid

  • value
  • input1
  • temp
Descriptive variable names improve Autocapture accuracy and makes them easier to maintain.

Use Autocapture variables for conversational data

Autocapture variables perform best when the information is something the user will naturally state during the conversation (such as email, phone number, or order number).

Use Autocapture when:

  • The target value will appear in the transcript
  • The context is natural (e.g., “My order number is 12345”)
  • You want the Agent to prompt only when needed

Avoid Autocapture when:

  • The user might phrase the answer ambiguously
  • The information needs precise formatting
Autocapture works best in English and may not perform consistently in other languages.

Use Global variables for values needed across multiple steps

Global variables persist and can be reused across Actions, Playbooks, Processes, and other elements.

They are ideal for:

  • Persistent user details (e.g., order number)
  • Context used across multiple steps

Avoid storing:

  • Large API responses
  • Data that changes frequently
  • Sensitive details that do not need to persist
Variable reuse depends on identity continuity. To learn how the system determines whether a user is returning, see Conversation identifiers and persistence.

Use Sensitive variables for confidential information

Sensitive variables should be used for personally identifiable or sensitive data.

Sensitive variables:

  • Are redacted in the dashboard
  • Are deleted automatically after 24 hours
  • Should be used for anything you do not want stored long-term

Use metavariables for environment and channel context

Metavariables give your Agent information about the user’s device, browser, channel, and system state.

Common use cases:

  • Personalizing content based on language or timezone
  • Handling browser-specific behavior

Metavariables cannot be created manually. They are populated automatically or passed via setMetaFields() in your embed script.

Minimize the size of stored data

Variables can store up to 100,000 characters, but smaller values are better for performance and maintainability.

Best practices:

  • Store only the specific fields you need
  • Avoid storing large JSON responses
  • Parse and extract needed values before saving
Storing large payloads may cause the variable to exceed the size limit or impact the performance of your AI Agent.

Avoid re-asking for information unnecessarily

Before using a Capture block, check whether the value already exists.

Use Set Variable or Conditional block to:

  • Skip asking for information that has already been collected
  • Reuse verified data
  • Reduce friction and create smoother conversations

Use metadata for logged-in user information

Avoid asking users to repeat information that your system already knows. Use setMetaFields() to pass things like:

  • email address
  • account tier
  • subscription level

This ensures consistency and reduces effort for authenticated users.

Test variable behavior with different user identities

Variable persistence depends on how Ada recognizes users. Test with:

  • Returning Web Chat users
  • New private-mode sessions
  • Different devices and browsers
  • Email threads inside and outside the continuation window
  • Social channel interactions
Identity testing helps ensure variables behave correctly across channels and repeat visits. For more information, see Conversation identifiers and persistence.

Keep your variable set organized

Variable sets can grow over time! Keep them clean by:

  • Reviewing unused variables periodically
  • Maintaining clear descriptions
  • Grouping variables by use case
  • Standardizing naming conventions

Common mistakes

Here are some common errors that can impact performance or user experience.

Variables that store entire API responses or large JSON objects may exceed the character limit or become difficult to work with.

Autocapture may misinterpret ambiguous inputs or fail in non-English languages.

Sensitive details should be stored only in Sensitive variables.

Variable reuse depends on identity, channel rules, and persistence settings. A new user session may clear Global variable values.

Examples

Correct

1{ "order_status": "shipped" }

Avoid

1{
2 "order_id": "12345",
3 "items": [...],
4 "shipping": {...},
5 "customer": {...},
6 "metadata": {...}
7}

Store only the fields you actually intend to use.

Correct

1setMetaFields({ email: user.email, account_id: user.id });

Avoid Asking the user: “What is your email address?” for authenticated sessions.

Correct If user_email exists, no need to capture it in a variable.

Avoid Asking the user for their email every time the process runs.

See also