Teneo Developers

Working with Global Context

Introduction

The Global 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 Context 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 Global Contexts are defined and maintained in the backstage of Teneo Studio and can be used in Flows whenever needed.

Global Contexts section

The Global Contexts are available in the backstage of Teneo Studio (Solution tab > Globals > Contexts), and the user has the options to perform the following actions:

  • Filter Scripted Contexts text field to filter on available list of Contexts
  • Add new Context
  • Delete existing Context
  • Search allows to search for a selected Context
  • Include (in Branching of solutions)
  • Exclude (from Branching of solutions)

Create a Global Context

To create a Global Context, follow the below steps:

  • Open the Contexts area of Teneo Studio (Solution tab > Globals > Contexts)
  • Click Add in the top of the view
  • The Scripted Context window opens
  • Give the Global Context a Name, Description and add Icons for its representation
  • Click the back-arrow in the top left corner
  • In the main view, write the execution script and add the expected states in the left-side panel
  • Remember to click Save to preserve the changes.

Global Context window

This Scripted Context window has two tabs: Scripted Context and Home.

Scripted Context window

The Scripted Context tab contains the following options:

  • Properties
    • Name field to add the name of the scripted context
    • Description field to add a description of the context
    • Large Icon large image representation of the context, click Change image to upload a different icon
    • Small Icon small image representation of the context, click Change image to upload a different icon.
  • Save
  • Close

The Name, Description and Icons of the Context are used throughout Teneo Studio; therefore it is recommended to choose a representative Name/Icon as well as write a description of its meaning and expected usage.

The Home tab contains the below areas:

  • Context Script field
  • Expected States panel
  • State Name
  • Evaluation Script

The top ribbon contains the following options:

  • Scripted Context area:
    • Close
    • Save
  • Script area:
    • Open with.. (open the script in an external editor)
  • Edit area
    • Undo
    • Redo
  • Branching area: (defines if the Context is included or not in a Localization setup)
    • Include
    • Exclude

While one user is editing a Global Context, it is locked for other users to avoid multiple users changing the same scripts at the same time.

Save

To save the Global Context, simply click Save in the top ribbon, alternatively press Ctrl+S using the keyboard.

It is mandatory to give a Context a Name, write a Context script and add at least one expected state. Otherwise Teneo Studio will not allow the user to save the Context.

This is because Contexts are assigned by values, so a Context with no value is not assignable and consequently useless.

Once the Context has been saved, the Global Contexts section in the backstage of Teneo Studio is populated with the new Context displaying a summary of the introduces values in the right-side panel.

Global Context view

Edit

Global Contexts can be edited by selecting the Context to edit and clicking Edit in the right-side of the window. Alternatively, double-clicking the name of a Context will also open it for edit.

If a Context is already opened in edit-mode, the Edit button will disappear and a Go to option appear for the user to navigate directly to the Context window.

If a Context is opened by another user, it will be locked for the current user and a little lock is displayed next to the Context name.

The properties and assignments of a Global Context are searchable from the backstage panel. Simply select the Context to search for and click Search in the menu above the listed Contexts.

Delete

To delete a scripted context, simply select the context to remove and click Delete in the menu above the list of contexts. The user is prompt by Teneo Studio to confirm the deletion, click Yes to continue.

If the Global Context is in use, the Item In Use message will be displayed, and the user has to select the Global Context and click Continue to confirm the deletion. Alternatively click Continue without selecting any Global Context in the list to abort the deletion.

Include and Exclude

Include and Exclude allows users working in the Master solution of a Localization setup to select if the Global Context should be included in a Local solution.

Read more

View History

The History of a Global Context is accessible in two ways:

  • Either by selecting the Clock icon available in the top of the right side panel of a selected Global Context, or
  • while editing the Global Context, in the backstage of the Scripted Context window (Scripted Context tab), selecting History.

Read more about Version history here.

Restore version

It is possible to restore a former version of a Global Scripted Context; to do so first open either of the views of the History.

By clicking the version number it is possible to open and review the former version of the Scripted Context in read-only mode. To restore, click Restore in the top ribbon of the window.

Version Flag

The button Set Stable, available above the select Global Context, allows to set the current version of the Global Context as stable when pressed; when a Global Context is opened in Edit mode, it is also possible to click Set Stable in the top ribbon of the window.

To set a previous version of a Global Context as stable, either open the History and in the History view, select the version of the Global Context which should be stable and click Set Stable in the top right area; or open the Global Context in Edit mode and go to the backstage by clicking Scripted Context in the top left corner, select History and in the list of versions, select the wanted version and click Set Stable in the top right area of the view.

To unset a stable version, select the Global Context (version) and click Unset Stable.

Learn more about Version Flags.

Assign Context

To assign Global Context, the user needs to first go to the Flow where the Context should be assigned and then select the Intent Trigger or Transition in the Flow graph to open the left-side panel, next follow the below steps:

  • In the Match Requirements section of the panel, click Add
  • Select Context in the drop-down menu
  • In the Context Match Requirement add, click Select Context
  • Again, in the drop-down menu, select the wanted Context (if any Global or Flow Variables exist in the solution, they may also be assigned)
  • Next, clicking the pencil-icon below States, select the expected state
  • Remember to Save the Flow to preserve the changes.

It is possible to add more than one Scripted Context to the same Intent Trigger or Transition; the assigned Context(s) are visible on the Intent Trigger/Transition in the Flow graph and the assigned values are displayed in an informative message when hoovering over either in the graph.

Expected states

By default, the Context will be assigned with the first expected state. If a Context has several expected states, the user should choose which to test against by clicking the pencil-icon below States and selecting/deselecting the wanted expected states.

It is possible to add more than one expected state if needed.

Merging solutions with Global Context

The merge of a solution during branching works as elsewhere by matching IDs.

The merge of a solution by import will override by Name, which is the same behavior as other Global data (e.g. listeners, integrations, etc.). This means that if a solution has a Context with a specific name and the solution to be imported has a Context with the same name, then the scripted Context's values of the original solution will be replaced with the ones from the solution being imported.

More information on how to merge solutions is available in the Import and Export section.

Advanced Studio search
Groovy scripts
Localization setup Properties lists
Global Scripted Contexts in the Knowledge Base