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
oris 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:
-
Open the step. Click the condition field at the beginning of the step:
-
Select with conditions from the drop-down list. The Conditions section expands.
-
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.
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
oris 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.
-
-
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.
-
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.
Response type | Operators |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|