IBM Cloud Docs
Adding conditions to an action

Adding conditions to an action

IBM Cloud

An action condition is a Boolean test, based on some runtime value; the action runs only if the test evaluates as true. This test can be applied to any variable. By defining action conditions, you can do things such as control user access to actions or create date-specific actions.

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

A basic action 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, an action condition might read:

If User category? is employee

In this example, User category can be a list of employees at your organization. This condition evaluates as true if the user is an active employee. If false, you can control access so that former employees can't use the action.

Conditions can be grouped to construct complex tests.

To add an action condition:

  1. In an action, click Customer starts with.

  2. Click Conditions.

    Conditions
    Conditions

  3. Choose the variable for the condition. You can select:

    • An action variable with the customer response from a previous step in the action
    • A session variable that contains a value that is 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 that defines some other value. For more information about expressions, see Writing expressions.

  4. Select the operator that represents the test that 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.

  5. Select the value that you want to evaluate the condition against. The values available depend upon the type of value that you are testing. For example, a variable that contains an options response can be tested against any of the defined options, and a date value can be tested against any date.

    Conditions
    Conditions

  6. To add more than one condition to an action, click Add condition.

  7. To add another group of conditions, click New condition group.

    You can use groups to build complex action conditions. Each group is evaluated true or false as a whole, and then these results are evaluated together. For example, you might build an action that runs 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 that 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