A conditional step means that the defined bot step (with asserters, logichooks) will only be executed if a certain condition is met.
The condition can be defined in a special logichook, which ref must be started with ‘CONDITIONAL_STEP’.
Example: ‘CONDITIONAL_STEP_CAPABILITY_VALUE_BASED’
Conditional logichooks integrated into Botium
Configuration
In the Botium UI this icon represents a conditional logic hook. If we add a conditional logic hook to a bot step, the parameters must be configured to be able to evaluate the conditional logic.
Let’s imagine that we have a chatbot, which can answer the question ‘Are you open?’, based on the current time:
-
8:00-16:30 - The shop is open
-
16:31-7:59 - The shop is closed
Handling multiple conditional groups
Now we would like to validate multiple bot messages. So let’s change the chatbot to have two bot messages with the question ‘Are you open?’:
-
Time Frame: 8:00-16:30:
- Message 1: The shop is open.
- Message 2: What can I do for you?
-
Time Frame: 16:31-7:59:
- Message 1: The shop is closed.
- Message 2: Please come back later.
Each conditional step requires a Condition Group ID. Steps with the same ID are grouped together.
- Group G1: For the time frame 8:00-16:30
- Group G2: For the time frame 16:31-7:59
You can easily identify which steps belong to the same group in the Convo Editor by looking at the icons on the left of each step. One conditional group asserts one bot message.
Developing your own Conditional Logic Hook
If you can't find the conditional logic hook you need, you can create your own using
the information in the Developing Custom Logic Hooks article. You'll need to implement the
onBotPrepare
function like this:
onBotPrepare ({ convo, convoStep, args }) {
const conditionGroupId = args[1]
let params
try {
params = JSON.parse(args[0])
} catch (e) {
throw new Error(`ConditionalCustomLogicHook: No parsable JSON object found in params: ${e}`)
}
convoStep.conditional = {
conditionGroupId
}
convoStep.conditional.skip = this.evaluateParams(params)
}
Botium Tools & Settings > Settings > COMPONENTS
, don’t
forget to define the component ref code with the “CONDITIONAL_STEP”
prefix:"ref": "MY-LOGICHOOK-NAME"