Global Scripted Contexts
Introduction
The Global Scripted Contexts enable Teneo users to define context scripts to ensure that the end-user of the application is presented with the correct answer based on the context of a dialogue.
Global Scripted Contexts can be written and maintained by script-savvy users while other users easily apply them throughout the solution without needing to know how they work or how to script. All Scripted Contexts are defined and maintained in the backstage of Teneo Studio and can be used in Flows whenever needed.
View of Global Contexts
Scripted Context window
Basics
Open
Create
Edit
Save
Close
Delete
Filter
Usage search
To search for the usage of a Global Scripted Context in a solution, follow the below steps:
- In the backstage of Teneo Studio (Solution tab > Globals > Contexts), select the Scripted Context
- Click Search in the ribbon
- The Search results are automatically opened in the frontstage of Teneo Studio
Details
Definition and execution
A Global Context consists of a script and a set of expected states and are assigned as Matches to either triggers or transitions; once defined these scripts are executed at runtime calculating the current state of the defined context and testing it against the expected states. If successful, the trigger/transition is set off. By using context, the trigger and transition depend both on the established Matches and the scripted states.
Groovy
The main part of a Global Context is the script which defines how the context state should be determined. When executed at runtime, it will return a value representing the current state of the dialogue at the point when the assigned context is tested. The value returned by the scripted context definition can be any Groovy type or any custom type which can be usefully compared with Groovy's equal operator ==
.
Multiple assignments
Assigning multiple context states to a Match of a trigger/transition will apply the context with an OR operator; for example: LatestTopic
is Weather
OR Directions
OR Maps
.
Assigning multiple Contexts to a Match of a trigger/transition will apply the context with an AND operator; for example: LatestTopic
is Weather
AND UserLocationIsKnown
.