Variables
Variables act as placeholders for content that can be reused throughout your Agent. Understanding how to utilize variables is essential for creating a truly customized user experience.
Saving an Answer in a Variable
To store user input in a variable, configure your User Input block to save the response. This variable can then be reused elsewhere in your Agent Dialog. For example:
You can also create, use or update variables in most Release0 blocks. For example if you agent requests the user to input his/her email address, you can enter the Email block and in its configuration, you can type Email in the “Save the answer in a variable”. This will create a new variable called Email and save the user’s input in it.
Using Variables
Once declared, you can use variables anywhere in your Agent by referencing them with the following syntax:
Here, “My variable” is the name of the variable.
Example:
If a variable named FirstName
contains “John”, you can display it in a dialog like this:
This will render as:
Inline Variable Formatting
Variables can also be formatted directly when referenced. Using JavaScript, you can perform transformations inline. For example:
-
Convert to Uppercase:
If
My variable
contains “John”, the output will be “JOHN”. -
Accessing List Items:
- First item:
{{={{My variable}}[0]=}}
or{{={{My variable}}.at(0)=}}
- Last item:
{{={{My variable}}.at(-1)=}}
- First item:
Note: Wrapping the syntax with
{{= ... =}}
evaluates the content as JavaScript.
Variables Panel
You can manage variables by accessing the Variables Panel in the editor (top-right corner). In this panel, you can:
- Rename, edit, or delete variables.
- Enable the option to save variables in the results table for tracking.
Viewing Variables in Results
Variables saved to the results will appear in the Results Page under dedicated columns.
Prefilled Variables
You can prefill variables by passing initial values in the URL when launching your Agent. For example:
URL Example
Given these variables:
Email
First name
You can initialize them like this:
Note: Replace spaces in variable names with
%20
when using URLs.
Embedding Example
To prefill variables using the embed library:
Tip: Surround variable names containing spaces with quotes.
Hidden Variables
Variables do not need to be visible to the user. Hidden variables can be used internally for tracking session details such as User ID
or utm_source
.
To make a variable hidden:
- Declare it in the Variables Panel or dropdown.
- Exclude it from visible dialogs.
These values will still appear in the Results Page for analysis.
Valid Value Types
Variables can contain:
- Text (
string
) - List of Texts (
string[]
)
Examples:
Warning: Non-text content (e.g., objects or numbers) will be automatically converted to text.
Handling Complex Data
To save complex data (e.g., objects), use JSON.stringify
:
Then, parse it back when using the variable:
This ensures clean and meaningful variable usage.
Validation and Testing
Before deploying your Agent:
- Ensure all variables are correctly saved and referenced.
- Validate inline transformations with JavaScript.
- Check the Results Page for proper tracking.