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:

{{MyVariable}}

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:

{{My variable}}

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:

Hello, {{FirstName}}!

This will render as:

Hello, John!

Inline Variable Formatting

Variables can also be formatted directly when referenced. Using JavaScript, you can perform transformations inline. For example:

  • Convert to Uppercase:

    {{={{My variable}}.toUpperCase()=}}
    

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

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:

https://release0.com/my-agent?Email=test@test.com&First%20name=John

Note: Replace spaces in variable names with %20 when using URLs.

Embedding Example

To prefill variables using the embed library:

Agent.initBubble({
  agent: `my-agent`,
  prefilledVariables: {
    Email: 'test@test.com',
    'First name': 'John',
  },
});

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:

  1. Declare it in the Variables Panel or dropdown.
  2. 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:

// ✅ Valid
'Hello', ['item 1', 'item 2']

// ❌ Invalid
2, true, { foo: 'bar' }

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:

const data = { foo: 'bar' };
const serialized = JSON.stringify(data);

Then, parse it back when using the variable:

{{=JSON.parse({{My object variable}})=}}

This ensures clean and meaningful variable usage.


Validation and Testing

Before deploying your Agent:

  1. Ensure all variables are correctly saved and referenced.
  2. Validate inline transformations with JavaScript.
  3. Check the Results Page for proper tracking.