Skip to main content
Variables allow you to pass dynamic data into your workflows at runtime, making workflows reusable across different contexts. Test data is what you use to build the flow in the editor.

Setting test data

In the workflow editor, go to Settings > Test Data. A Test Data tab will appear in the editor, and you’ll be able to type or paste a test data JSON that the agent can use to write scripts in editor mode.

How the agent uses test data and variables

In the editor, you’ll see a data/variables.json file. When using the editor, this file contains the test data you give it in Settings > Test Data. In production, this file contains the variables JSON you pass to it when running a workflow. Let’s say you set the test data to be the following JSON:
data/variables.json
{
  "PO_Number": "4729183",
}
If the agent then needs to fill in a search bar with a PO_Number, it’s likely to write code like this:
scratch_work/fill_search_bar_and_submit.py
import asyncio
import json
from servers.browser_tools import click, type, screenshot

async def main():
    # Load variables
    with open("/home/chrome_user/agent/data/variables.json", "r") as f:
        variables = json.load(f)

    # Click and fill PO number field
    await click(selector="input#searchBar")
    await type(text=variables["PO_Number"])

asyncio.run(main())

Advantages of using a variables file

Since the agent writes python code, it can manipulate variables before using them. A simple example is when a form requires separate first and last name fields, but the data source you’re setting variables from (e.g., your internal database) only returns a full name:
scratch_work/fill_name_fields.py
import asyncio
import json
from servers.browser_tools import click, type

async def main():
    with open("/home/chrome_user/agent/data/variables.json", "r") as f:
        variables = json.load(f)

    full_name = variables.get("full_name")
    first_name = full_name.split(" ")[0]
    last_name = full_name.split(" ")[1]

    await click(selector="input#firstname")
    await type(text=first_name)

    await click(selector="input#lastname")
    await type(text=last_name)

asyncio.run(main())

Productionizing variables

When the productionize agent runs, it will use the test data format to create the Variables schema (found in Settings > Variables). You can further edit the Variables schema manually as needed.

Variables as feature flags

One way you can use variables is to treat them like feature flags. You’ll likely need to be testing web automations on live portals, and often won’t want to do form submissions during test time. Given the following test data:
data/variables.json
{
  "submit": false
}
The agent can conditionally submit based on the flag:
scratch_work/submit.py
import asyncio
import json
from servers.browser_tools import click, screenshot

async def main():
    with open("/home/chrome_user/agent/data/variables.json", "r") as f:
        variables = json.load(f)

    if variables.get("submit"):
        await click(selector="button#submit")
        await screenshot()

asyncio.run(main())