Join us at Google I/O from May 18 to 20 for discussions, learning, and a first look at our latest developer products. Register now.


You can carry out conditional logic in scenes using values from the session.params, user.params, intent.params and scene.slots.params objects. The following sections describe the valid syntax for conditions.

Logical operators

Operator Description
&& Logical AND. Inner expressions are evaluated iteratively, and the evaluation is short-circuited if any expression evaluates to false.
|| Logical OR. Inner expressions are evaluated iteratively, and the evaluation is short-circuited if any expression evaluates to true
! Logical NOT. The evaluation of the inner expression is negated

Numerical and string operators

The following numerical and string operators are supported:

Operator Description
+ Add numbers or string concatenation
- Subtract numbers
* Multiply numbers
/ Divide numbers


The following constant booleans are supported:

Constant Description
true Must be lowercase
false Must be lowercase
!false Evaluates to true. Must be lowercase.

Comparison operators

The following comparison operators are provided:

Operator Description
== Equals
!= Not equals
< Less than
<= Less than equals
> Greater than
>= Greater than equals

Lists and maps

Given a list named session.params.myList:

Syntax Description
x in session.params.myList Returns true if the value x is in session.params.myList
myList[x] Returns the value at index x of myList
size(session.params.myList) Returns the size of a list

Given a map named session.params.myMap:

Syntax Description
session.params.myMap == {"one": 1, "two":2} Returns true if maps are equal
session['params']['myMap']['one'] Returns the value with specified key
size(session.params.myMap) Returns the map size

Usage reference

The following syntax examples assumes you are working with session.params object:

session.params = {
  "flag": true,
  "count": 10,
  "name": "john smith",
  "myList": [1, 2, 3],
  "myMap": {"one": 1, "two":2}

You can carry out the following conditional operations:

// numbers and boolean logic
session.params.count > 0 && session.params.count < 100    // AND
session.params.count == 0 || session.params.count != 5    // OR
!(session.params.count <= 0)         // NOT

// booleans
!false                      // true constant
session.params.flag         // boolean variable
session.params.flag == true // explicitly compare with true constant

// strings == "john smith"  // double quotes supported == 'john smith'  // single quotes supported"john") // substring + "!!!" == "john smith!!!" // string concatenation < "abc"          // compares lexicographically
size( == 10      // length of string

// lists
1 in session.params.myList        // "contains in list" operator
session.params.myList[0] == 1     // "index into list" operator
size(session.params.myList) == 3  // returns number of elements in the list

// maps
session.params.myMap == {"one": 1, "two":2} // compare map with json
session['params']['myMap']['one'] == 1      // index using square brackets
size(session.params.myMap) == 2             // number of entries in the map