Context restrictions

In Teneo you can add constraints to a trigger or transition by using context restrictions. The role of a contextual restriction is to make sure an input not only matches a trigger or a transition, but that additional information is evaluated before the flow is triggered or the transition is traversed. This contextual information varies depending on the current conversation.

There are two different types of context restrictions:

  • Scripted context restrictions, which use a script to evaluate if a context is true.
  • Variable-based context restrictions, which evaluate if a variable exists or has a particular value.

For example, the class trigger below contains a scripted context restriction that prevents it from triggering if the confidence score of the input is lower than 0.80 (which corresponds to 80%):

Trigger with context restriction

You add a restriction to a trigger or a tranistion in the tab where you provide the learning example inputs:

Add context restriction to trigger

Predefined context restrictions

The Teneo Dialog Resources (TDR) come with a number of predefined (scripted) contexts out of the box, you can find their definitions in the globals section of your solution:

Predefined Scripted Contexts

  • Class Confidence High - Restricts class triggers to only fire when the confidence score is 0.80 or higher
  • Class Confidence Medium - Restricts class triggers to only fire when the confidence score is 0.60 or higher
  • Disable trigger - Prevents a trigger from triggering - if applied to a class trigger, the learning examples will still be used to train the machine learning model
  • Follow up of Flow - Checks if the previous input triggered the same flow as the trigger that is currently evaluated. This allows you to determine if an input is a follow up of the same flow.
  • Follow up of Folder - Checks if the previous input triggered a flow in the same folder as the current one. This allows you to determine if an input is a follow up of a flow in the same folder.

For a practical example of how to use a predefined context, please read How to deal with follow-ups.

Variable-based context restrictions

Variable-based context restrictions evaluate if a global or a flow variable matches a particular value. They are applied to triggers and transitions. Only if the input of the user matches the trigger or transition and if the variable that is used in the context restriction matches the desired value, then the trigger or transition will be traversed.

Variable based context

In the image above the syntax trigger 'Can I have one of those?' is context restricted by the global variable 'coffeTypeInFocus'. If an input matches the trigger, it can only fire if the variable 'coffeTypeInFocus' is not empty, and the context thus evaluates to true.

To learn how to use a variable-based context, head over to How to share information between flows.

Scripted context restrictions

The predefined contexts that come with the Teneo Dialog Resources (TDR) are essentially scripted contexts. However, you are not limited to using just those. You can add your own scripted contexts too. They are created and maintained in the same place (in the Globals section of your solution) where you find the predefined contexts.

A scripted context consists of a script and one or more expected states (outcomes). Once a trigger or transition with the applied scripted context is up for evaluation, the script is executed. If the outcome of script matches the desired state of the context restriction, the trigger or transition will fire.

Scripted context definition

For a practical example of creating a custom scripted context, see How to define a scripted context.

Was this page helpful?