Basic expression examples

This describes some common ways expressions are used in journeys.

Collected data

Expressions can be used to access data collected and stored by a previous journey step. Suppose a new password is collected from the user (e.g., using Get Information From Client) and stored by the journey in an output variable named registrationData in a field named password.

Use this expression to pass the new password in a subsequent journey step: registrationData.password.

Client request data

When starting a journey, the client application can pass additional data to the journey as part of the invocation request. This data can be accessed by the journey using the following expression: @policy.request().params.

For example, suppose the client passes an external authentication token in a parameter named authToken:

Copy
Copied
window.tsPlatform.ido.startJourney(
    '<journeyId>', 
    { 
        additionalParams: {
            authToken: '<someTokenValue>'
        }
    }
)

Use this expression to access the token value: @policy.request().params.authToken.

Current time

You can fetch the current time, for example, to display to the user, set an expiration, or check some validity period.

These expressions provide the time in UNIX epoch milliseconds or ISO 8601 format: @time().now or @time().nowISO

Dynamic text

Expressions can be used to add dynamic text to a string. For example, suppose the journey stores the user's first name in a variable named first_name. The Display Information step is configured with Message that the client is instructed to display to the user. Since the message field is an interpolated string, it can be configured as Hello ${first_name}.

Conditions

Conditions typically require more complex logic that's configured using expressions.

The examples below assume that amount and deviceModel are variables that store the relevant data.

To check... ...Use this expression
Amount is over 100 amount > 100
User is authenticated @policy.isUserAuthenticated()
Device is model X deviceModel == x
Amount is over 100 and device is model X amount > 100 && deviceModel == x

Dynamic objects

When building a JSON object, you can add dynamic data from variables. Here is an example taken from a user onboarding journey

Copy
Copied
{
  "first_name": clientDetails.first_name,
  "last_name": clientDetails.last_name,
  "birthday": clientDetails.birthday,
  "phone": clientDetails.phone,
  "card_type": clientDetails.card_type,
  "card": clientDetails.card,
  "sec_code": clientDetails.sec_code
}