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
oris 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:
-
In an action, click Customer starts with.
-
Click Conditions.
-
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.
-
Select the operator that represents the test that you want to perform on the variable (for example,
is
oris not
). The available operators for a particular value depend upon its data type. For more information, see Operators. -
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.
-
To add more than one condition to an action, click Add condition.
-
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.
Response type | Operators |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|