Skip to content

Parameters and constants ​

Pass dynamic values to flows using parameters and inline constants.

Flows can take data from outside to make them dynamic and reusable. Instead of hardcoding values like usernames, passwords, or product IDs, you can use variables that are populated at runtime.

There are two main ways to define these variables:

  • Parameters: Values passed externally (e.g., from an Astra Scout environment).
  • Constants: Values defined internally within the Flow (e.g., using the env key).

Both are accessed using the same ${VARIABLE_NAME} syntax.

Case sensitivity

Variable names are case-sensitive. ${APP_ID} is different from ${App_ID}.

Parameters ​

Parameters are useful for passing sensitive data (like credentials) or environment-specific configurations (like URLs) that you don't want to commit to your repository.

Passing parameters from an environment ​

In Astra Scout, choose Run → Manage Environments… and create an environment. An environment has a name, optional include and exclude tags, and a list of Environment Variables. Select the environment before you run a flow and each variable is available as ${NAME}.

Type safety

Remember that parameters are passed as strings. If you need a number or boolean, you may need to parse it in JavaScript (e.g., parseInt(${COUNT})).

For example, with variables USERNAME and PASSWORD set in the environment, a flow can access them using the ${VARIABLE_NAME} syntax. The following Flow uses the provided username and password to log in.

yaml
appId: com.example.app
---
- launchApp
- tapOn: "Username"
- inputText: ${USERNAME}
- tapOn: "Password"
- inputText: ${PASSWORD}

Accessing process environment variables ​

Astra Scout also reads environment variables prefixed with MAESTRO_ from its own process environment and makes them available in your flows.

WARNING

Only variables that Astra Scout itself was started with are visible. An app opened from the Dock or Finder does not inherit variables you export in a terminal. Start the app from that terminal, or use an environment instead.

For example, if the app was started with MAESTRO_API_KEY=12345 in its environment, an inline evaluation can capture it:

yaml
- evalScript: ${output.apiKey = MAESTRO_API_KEY}

Constants ​

Constants are variables defined directly within your Flow files. They are useful for defining test data, configuration flags, or reusable values that don't need to change between runs.

Defining inline constants ​

You can define constants at the top of your Flow file using the env key.

In this example, DEFAULT_TIMEOUT and IS_DEBUG are set as constants for the entire Flow file.

yaml
appId: com.example.app
env:
    DEFAULT_TIMEOUT: 5000
    IS_DEBUG: true
---
- launchApp

Passing arguments to subflows ​

When using nested Flows, you can pass arguments to reuse the same subflow with different data. Variables defined in env are available only to that specific subflow execution.

In the following example, the login.yaml subflow is executed with the USER_ROLE constant set to admin.

yaml
- runFlow:
    file: subflows/login.yaml
    env:
        USER_ROLE: "admin"

Priority

Constants defined in a subflow (either in the env header or the runFlow command) override parameters with the same name from the parent flow.

Setting default values ​

You can use JavaScript syntax to provide default values for parameters. This is used for preventing crashes if a parameter is not provided.

In this example, ${USERNAME} will use the provided value if it exists, otherwise, it defaults to "guest".

yaml
- inputText: ${USERNAME || "guest"}

This technique is particularly powerful in subflows, allowing them to be run standalone (using defaults) or as part of a larger suite (using passed parameters).

yaml
# subflows/login.yaml
appId: com.example.app
env:
    # Use the passed value, or default to a test account
    USER_ID: ${USER_ID || "test_user_1"}
---
- tapOn: "User ID"
- inputText: ${USER_ID}

Built-in parameters ​

Astra Scout provides these built-in parameters in every flow.

ParameterDescription
MAESTRO_FILENAMEThe current flow's file name without the extension (e.g., login).
MAESTRO_SHARD_IDAlways 1: Astra Scout does not shard a run across devices.
MAESTRO_SHARD_INDEXAlways 0: Astra Scout does not shard a run across devices.

WARNING

Maestro also defines MAESTRO_DEVICE_UDID. Astra Scout does not set it, so avoid relying on it in flows you share.

Next steps ​

To continue learning how to create Flows, check the following pages: