Skip to main content

Conditional Logic Hooks

These basic conditional logic hooks are integrated into Botium. They will only be executed if specified conditions are met.

Conditional Time Based

This logic hook can be used only as a Bot Step. Read more about Conditional Bot Steps here

Overview:

This logichook checks if the current time is between the time period defined in the parameters. It can be used to validate the bot response when the bot gives different answers based on the current time.

Steps:
  1. On the left navigation pane, head to Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
  2. Click the + NEW button to add a new Convo, or select a previously created test case from the list.
  3. Add a new + BOT STEP
  4. Click the Edit icon, or anywhere inside the step, and search the list for the 'Conditional Time Based' logic hook.

  5. Configure the Logic Hook:
    Note: The parameters must be specified in a JSON object.
    1. Condition Group ID: Optional - If required, specify an ID for the Condition Group. Read here for more information on how to handle conditional groups
    2. Parameters as JSON Object: Click the INSERT SAMPLE button to generate a sample JSON object for the parameters, or enter the parameters directly.
      • Start: The start time of the period in mm:ss format (e.g. 08:01).
      • End: The end time of the period in mm:ss format (e.g. 16:55).
      • TimeZone: Optional - The chatbot timezone can be specified, otherwise the Botium server timezone will be used . For more info on timezones see the time zone identifier list - List of tz database time zones - Wikipedia
        Note: The start and end times are inclusive in the time period calculation.


      This is an example of verifying the chatbot greetings based on time:

  6. Click the APPLY CHANGES button to complete the step entry.

Note:
Example Botium Script:
#me
start conditional time-based logic

#bot
CONDITIONAL_STEP_TIME_BASED {
  "start": "8:00",
  "end": "16:30",
  "timeZone": "Europe/Vienna"
}|exampleGroupId
Explanation:
  • CONDITIONAL_STEP_TIME_BASED sets up a conditional logic based on the specified time parameters. In the example, the condition group exampleGroupId applies during weekdays from 8:00 AM to 4:30 PM

Conditional Business Hours

This logic hook can be used only as a Bot Step. Read more about Conditional Bot Steps here

Overview:

This logichook checks if the current time is between the time period defined in the parameters. It can be used to validate the bot response when the bot gives different answers based on the current time.

Steps:
  1. On the left navigation pane, head to Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
  2. Click the + NEW button to add a new Convo, or select a previously created test case from the list.
  3. Add a new + BOT STEP
  4. Click the Edit icon, or anywhere inside the step, and search the list for the 'Conditional Business Hours' logic hook.

  5. Configure the Logic Hook:
    Note: The parameters must be specified in a JSON object.
    1. Condition Group ID: Optional - If required, specify an ID for the Condition Group. Read here for more information on how to handle conditional groups
    2. Parameters as JSON Object: Click the INSERT SAMPLE button to generate a sample JSON object for the parameters, or enter the parameters directly.
      • Days: Array of the days, which are considered at the time period check (e.g. ["Monday", "Tuesday", "Wednesday"]).
      • Time period: Optional - You can define a time period with start and end time. If it is not specified then the days will be checked from the days array.
      • Start: The start time of the period in mm:ss format (e.g. 08:01).
      • End: The end time of the period in mm:ss format (e.g. 16:55).
      • TimeZone: Optional - The chatbot timezone can be specified, otherwise the Botium server timezone will be used . For more info on timezones see the time zone identifier list - List of tz database time zones - Wikipedia
        Note: At a minimum, either the days or the start and end times must be specified. The start and end times are inclusive in the time period calculation.


  6. Click the APPLY CHANGES button to complete the step entry.

Note:
Example Botium Script:
#me
start conditional time-based logic

#bot
CONDITIONAL_STEP_BUSINESS_HOURS {
  "days": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
  "start": "8:00",
  "end": "16:30",
  "timeZone": "Europe/Vienna"
}|Group 1
Explanation:
  • CONDITIONAL_STEP_BUSINESS_HOURS sets up conditional logic based on the specified business hours. In the example, the condition group Group 1 applies during weekdays from 8:00 AM to 4:30 PM in the Europe/Vienna time zone.

Conditional Capability Value Based

This logic hook can be used only as a Bot Step. Read more about Conditional Bot Steps here

Overview:

This logichook checks if the capability value is equal to the given value from the parameters. It can be used to validate the bot response when the bot gives different answers based on a capability value(E.g. Mobile or Web chatbot connection).

Steps:
  1. On the left navigation pane, head to Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
  2. Click the + NEW button to add a new Convo, or select a previously created test case from the list.
  3. Add a new + BOT STEP
  4. Click the Edit icon, or anywhere inside the step, and search the list for the 'Conditional Capability Value Based' logic hook.

  5. Configure the Logic Hook:
    1. Condition Group ID: Optional - If required, specify an ID for the Condition Group. Read here for more information on how to handle conditional groups
    2. Parameters as JSON Object: Click the INSERT SAMPLE button to generate a sample JSON object for the parameters, or enter the parameters directly.
      • capabilityName: The capability, which value will be checked.
      • value: The expected value.
      • jsonPath: Optional - You can define a json path, if your capability is a json object and you would like to check a specific property of that.
  6. Click the APPLY CHANGES button to complete the step entry.

It’s possible that the same chatbot has a version for mobile and for web with only slight differences. With this type of conditional logic hook you save a lot of duplicated work. As you can see here in this example, both of the chatbot connections will answer with ‘Hi,’ but the next bot message is different based on the CHATBOT_TYPE capability value.

Note:
Example Botium Script:
#me
start conditional time-based logic

#bot
CONDITIONAL_STEP_CAPABILITY_VALUE_BASED {
  "capabilityName": "CHATBOT_TYPE",
  "value": "Mobile",
  "jsonPath": "$.optionally.define.jsonpath"
}|capabilityGroup
Explanation:
  • CONDITIONAL_STEP_CAPABILITY_VALUE_BASED {"capabilityName":
          "CAP_NAME", "value": "value", "jsonPath": "$.optionally.define.jsonpath"} |
          my_capability_group
    sets up conditional logic based on the specified capability values.
  • In the example, the condition group capabilityGroup applies if the capability CHATBOT_TYPE has the value Mobile and optionally uses the jsonPath to define a specific path.

Conditional JSON Path Based

This logic hook can be used only as a Bot Step.

Overview: This guide explains how to set up a logic hook in Botium to apply conditional logic based on JSON Path expressions.

Steps:
  1. On the left navigation pane, head to Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
  2. Click the + NEW button to add a new Convo, or select a previously created test case from the list.
  3. Add a new + BOT STEP
  4. Click the Edit icon, or anywhere inside the step, and search the list for the 'Conditional JSON Path Based' logic hook.

  5. Configure the Logic Hook:
    1. Condition Group ID: Specify the Condition Group ID.
    2. Params as JSON Object: Click the INSERT SAMPLE button to generate a sample JSON object for the parameters, or enter the parameters as a JSON object directly.

  6. Click the APPLY CHANGES button to complete the step entry.

Note:
Example Botium Script:
#me
start conditional JSON path logic

#bot
CONDITIONAL_STEP_JSON_PATH_BASED {
  "jsonPath": "$.jsonpath.on.botMsg",
  "value": "value"
} | JSONgroup
Explanation:
  • CONDITIONAL_STEP_JSON_PATH_BASED {"jsonPath":
          "$.jsonpath.on.botMsg", "value": "value"} | JSONgroup
    sets up conditional logic based on the specified JSON Path expression.
  • In the example, the logic hook checks if the JSON Path expression $.jsonpath.on.botMsg evaluates to value. If this condition is met, the logic group JSONgroup is applied.

Was this article helpful?

0 out of 0 found this helpful