Conditions reference

This reference describes the syntax for using conditions in routes. The parameter references described below ($a, $b, $c) are short to aid description. The actual parameter references you can use in conditions are found in the parameters guide.

Comparison operators

Comparison operators have a left hand side (LHS) and a right hand side (RHS). The following comparison operators are supported:

  • HAS (:)
  • EQUALS (=)
  • NOT_EQUALS (!=)
  • LESS_THAN (<)
  • LESS_THAN_EQUALS (<=)
  • GREATER_THAN (>)
  • GREATER_THAN_EQUALS (>=)

Rules for comparison operators

  • The LHS must be a parameter reference.
    $a = 5
    
  • The RHS is type casted to the same type as the LHS before comparing.
  • HAS for anything other than strings is treated as EQUALS.

Support for strings

  • HAS performs a substring search. If $a is set to "hello world", the following is true:
    $a : "hello"
    
  • When using strings on the RHS, double quotes are needed if the string contains space. If $a is set to "hello world", the following is true:
    $a = "hello world"
    
  • LESS* and GREATER* compare lexicographically. If $a is set to "abc", the following is true:
    $a > "aaa"
    

Boolean operators

Conjunction (AND)

For the AND operator, expressions are evaluated iteratively, and the evaluation is short-circuited if any expression evaluates to false. Example:

$a > 0 AND $a < 100

Disjunction (OR)

For the OR operator, expressions are evaluated iteratively, and the evaluation is short-circuited if any expression evaluates to true. Example:

$a = 0 OR $a > 5

Negation (NOT)

For the NOT operator, the expression is negated. Example:

NOT $a <= 0

Rules for boolean operators

  • The boolean operators must be uppercase.
  • The boolean operators must not be part of a quoted string.

Boolean constants

The following boolean constants are defined:

true
false

Functions

The following built-in functions can be used in condition expressions.

Rand

You can use the rand function to generate a random floating point number in the range [0,1). For example, there is a 10% probability that the following condition will be true:

$sys.func.rand() < 0.1

Compound expressions

You can use boolean operators and comparison operators to form compound expressions. Parentheses may be used to make the logic clearer or change the precedence. For example:

(NOT ($a > 1 AND $b < 100)) OR $c = 50

If you are not using parenthesis, you cannot use both OR and AND operators in a compound expression:

$a=1 AND $b=2 AND $c=3  // VALID
$a=1 OR $b=2 OR $c=3    // VALID
$a=1 OR $b=2 AND $c=3   // INVALID
($a=1 OR $b=2) AND $c=3 // VALID

Example conditions

To check whether the current page's form is filled, use the following condition:

$page.params.status = "FINAL"

To check whether a particular form parameter was filled for the end-user's previous conversational turn, use the following condition:

$page.params.parameter-id.status = "UPDATED"

To force a route to be called upon evaluation, use the following condition:

true

To check that a numerical session parameter is between the values 1 and 10, use the following condition:

$session.params.parameter-id >= 1 AND $session.params.parameter-id <= 10

To check that the second value of a list session parameter is equal to "hello", use the following condition:

$session.params.parameter-id[1] = "hello"