IBM Cloud Docs
Adding conditions to a step

Adding conditions to a step

An action represents a business process that helps customers answer their questions or solve their problems. Such a process must adapt to different specifics, based on information provided by customers or otherwise available at run time. For example, the steps for withdrawing money from a savings account might be slightly different from the steps for withdrawing for a checking account.

A step condition is a boolean test, based on some runtime value; the step executes only if the test evaluates as true. This test can be applied to any variable, such as an action variable containing the customer response from a previous step. By defining step conditions, you can create multiple pathways through an action based on different possible runtime values.

For more information about variables, see Using variables to manage conversation information.

A basic step condition is expressed in the following form:

If {variable} {operator} {value}

where:

  • {variable} is the name of a variable or an expression.
  • {operator} is the type of test to apply to the variable value (for example, is or is not).
  • {value} is the value to compare to the variable.

For example, a step condition might read:

If Withdraw from which account? is Checking

This condition evaluates as true if the customer's response to the previous Withdraw from which account? step is Checking.

Conditions can be grouped together to construct complex tests.

To add a step condition:

  1. Open the step. Click the condition field at the beginning of the step:

    Step editor with condition field highlighted
    Condition field

  2. Select with conditions from the drop-down list. The Conditions section expands.

  3. By default, a single condition group, containing a single condition, is automatically created based on the action variable stored by the most recent customer response.

    Editing a condition to select Checking as the value to check for
    Edit condition

    You can click any part of the expression to edit it:

    • Select the variable you want to test. You can select any of the following:

      • An action variable storing the customer response from a previous step in the action
      • A session variable containing a value stored by any action
      • A built-in variable set by the assistant or by an integration

      You can also define a complex condition by writing an expression defining some other value. For more information about expressions, see Writing expressions.

    • Select the operator representing the test you want to perform on the variable (for example, is or is not). The available operators for a particular value depend upon its data type. (For more information, see Operators.)

    • Select the value you want to evaluate the test against. Again, the values available depend upon the type of value you are testing. For example, a variable containing an options response can be tested against any of the defined options, and a date value can be tested against any date.

  4. To add more than one condition to a step, after adding a condition, click New condition group.

    One use case where using more than one condition is helpful is if you need to capture a value range. For example, maybe a requirement of opening a checking account is that the customer deposit at least $100 into the account at creation time. You might ask the customer if they want to transfer funds to the account, and if so, how much? To continue with the transfer, the transfer amount must be $100 or more, but cannot exceed $1000. You can add a step with the following conditions:

    • How much to transfer? > 99
    • How much to transfer? < 1001

    Specify whether all or any of the conditions must be met for the step to be included in the conversational flow.

  5. To add another group of conditions, click Add new group.

    You can use groups to build complex step conditions. Each group is evaluated true or false as a whole, and then these results are evaluated together. For example, you might build a step that executes only if all conditions in group 1 are true or any condition in group 2 is true. (Groups function like parentheses in the boolean conditions of many programming languages.)

    After you add a group, you can define one or more conditions in the new group. Between groups, choose and or or to indicate whether the conditions in both conditional groups or only one of them must be met for the step to be included in the conversational flow.

Operators

An operator specifies the kind of test you are performing on a value in a condition. The specific operators available in a condition depend on the customer response type of the value, as shown in the following table.

Operators
Response type Operators
  • Options
  • is
  • is not
  • is any of
  • is none of
  • Regex
  • is
  • is not
  • Number
  • Currency
  • Percent
  • is defined
  • is not defined
  • is equal to (==)
  • is not equal to (≠)
  • is less than (<)
  • is less than or equal to (<=)
  • is greater than (>)
  • is greater than or equal to (>=)
  • Date
  • is defined
  • is not defined
  • is on (also allows specific day of the week)
  • is not on
  • is before
  • is after
  • is on or before
  • is on or after
  • Time
  • is defined
  • is not defined
  • is at
  • is not at
  • is before
  • is after
  • is at or before
  • is at or after
  • Free text
  • is
  • is not
  • contains
  • does not contain
  • matches
  • does not match