Teneo Developers

Global Scripts

Introduction

The Global Scripts available in Teneo Studio include two script "levels": Session Scripts and Engine Scripts, both are described further in the below Script types section. The scripting language in Teneo Studio is Groovy, and Teneo Studio provides basic support for syntax highlighting.

View of Global Scripts

The Global Scripts are found in the backstage of Teneo Studio: Solution tab > Globals > Scripts.

View of Global Scripts

In this view the user will find:

  • Left side:
    • Text filter and Add button
    • List of Global Scripts
    • Global Script Ordering
  • Right side:
    • Ribbon options allowing to Edit, view History, set/unset Stable version, include/exclude in Branching
    • Details of the selected script providing a read-only summary
    • Global Script's Id

Global Script window

The Global Script window is accessed by either adding a new script or by editing an existing script.

Global Script window

The Global Script window includes:

  • Home tab with
    • Top ribbon
    • Script editor
  • Script tab with access to the backstage of the script

For more details see the Edit section further below.

Basics

Create

In the Global Scripts section in the backstage of Teneo Studio (Solution tab > Globals > Scripts), simply follow the below steps to create a new Global Script:

  • Click Add next to the text filter
  • In the drop-down menu, select the wanted Global Script type
  • The Script window opens, now enter the script in the editor
  • Optionally, click the Script tab to access the Properties to give the script a Name and write a Description
  • Lastly, remember to Save the script to preserve the changes.

It is possible to add several scripts of the same type: this can become very useful when organizing and breaking down scripts which else could become very long. It also allows for multiple users to work with scripts of the same type at the same time.
To add a new script of an already existing type, simply follow the above steps and select the same script type again. When more than one script exists of the same type, remember to organize the scripts in the wanted Script Ordering.

Edit

To open a Global Script, select it in the list of Global Scripts and click Edit in the right side of the window.
After opening the Global Script, it is possible to modify the script or other details (e.g. the name and description); below please find an overview of the available options and buttons.

Global Script: top ribbon

The top ribbon of the Global Script window provides the following options.

SectionButtonCommentMore information
ScriptCloseClose the Global Script window
SaveSave the Global Script in the current state; clicking the lower part of the button allows the user to save the script with or without a comment
Open With...Allows to open the script in an external script editor; when the button is clicked for the first time the user will be prompted to select the script editor
EditUndo/RedoUndo/redo changes performed in the Global Script
Stable VersionSet/UnsetSet the current version of the Global Script as stable or unset itVersion flag
BranchingInclude/ExcludeInclude or Exclude the Global Script from branching when working in a Localization setupLocalization setup

Script tab

The Script tab allows to access the backstage of the Global Script window where the following options are available.

Menu itemCommentMore information
SaveSave the Global Script in the current state
PropertiesAllows to edit the name and description of the Global Script
InfoProvides information about the selected script typeScript types
HistoryLists the history and versions created each time the Global Script is saved, comments added at save are displayed here.Open a previous version by clicking the version number; restore a previous version by opening the specific version and clicking Restore in the top ribbonVersion flag
CloseClose the Global Script window

Save

To save a script with a comment follow the below steps:

  • Click Save in the top ribbon of the Script window
  • In the dialogue box (optionally) write a comment
  • Click Continue

To save directly and bypass the comment, press the Alt key while clicking the Save button.

Clicking the lower part of the Save button allows to select between Save with comment and Save without comment

Close

The Global Script window can be closed by performing one of the following actions:

  • Click the X in the top, right corner of the window
  • Click the Close button in the top ribbon
  • In the Script backstage, click Close in the left-side menu

In case of unsaved changes, Teneo Studio prompts the user to Save Changes or Discard Changes.

Delete

Follow the below steps to delete a Global Script:

  • In the Global Scripts in the backstage of Teneo Studio (Solution tab > Globals > Scripts), select the script(s) to delete
  • Click Delete in the ribbon in the right side of the view
  • Teneo Studio prompts the user to confirm the deletion, click Yes
  • When the deletion is completed, click OK in the confirmation message.

Read more about deletion and usage check

If a Global Script is deleted by mistake, it can be restored from the Recycle Bin.

Filter

A text filter is available at the top of the list of Global Scripts; to filter on the available scripts, simply write the wanted letter combination to start filtering on the list.

Script Ordering

The Script Ordering allows the user to organize the order in which scripts of the same type are executed, this is done at the bottom of the Global Scripts view.

Script Ordering

The following buttons are available:

ButtonCommentMore information
EditOpens Script Ordering in edit-mode. Selecting a script allows to move it up/down by clicking the blue arrows in the right side of the list of Global Scripts; remember to Save ordering to preserve the changes, click Continue in the save prompt or Cancel to omit the changes.
HistoryLists the history and versions created each time the Script Ordering is saved, comments added at save are displayed here. View a previous version by selecting it in the History window. Set a previous version as stable by selecting it and clicking Set Stable in the top right corner of the History window. Restore a previous version by clicking Restore in the top right corner of the History window.History
Set Stable/Unset Stable *Set the current version of the Global Script Ordering as stable or unset itVersion flag

* It is compulsory to set a version of the Script Ordering to stable when using the Version flag feature of Teneo Studio.

Details

Script types

The Global Scripts are divided between Session Scripts and Engine Scripts:

The Session Scripts all have read and write access to session data, read-only access to solution data and are connected to and occur within the scope of a session, on top of this, with Session Scripts it is possible to control and manipulate the input processing.
The Engine Scripts, on the other hand, have read and write access to solution data and are not connected to nor have access to any particular session.

The Session Scripts and Engine Scripts include different types of scripts, which are all presented in the below table. For each of the different scripts types it is possible to add one or more scripts which are then executed in the order defined by the user in the Script Ordering.

Script levelScript typeComment
Session ScriptBegin dialogBegin dialog scripts are executed at session start and are the very first global scripts to execute when an end-user talks to the solution.
Session ScriptNew sessionNew session scripts run following the Begin dialog scripts, subsequent to the beginning of a new session started by a new user. If the session was started by a user whose session was timed out, the Timed-out session scripts are run instead.
Session ScriptTimed-out sessionThese scripts run when an end-user, whose session timed out, resumes the dialogue with the AI application. Usually, a session times out after 10 minutes of inactivity.
Session ScriptPre-processingPre-processing scripts run on each transaction before a sentence in a user input is separated for processing (before simplification). In these scripts, a user input can be manipulated before the input and dialogue processing begin and before Engine tests it against Flow triggers or transitions. A more common use of the Pre-processing scripts is to access other elements of the incoming http request than the user input string.
Session ScriptPre-matchingThese scripts execute before matching, but after the input is separated into words (after sentence segmentation and tokenization).
Session ScriptPost-processingThe Post-processing scripts are executed after the Engine has created a response (Output answer), but before the response is given to the end-user. The scripts allow to change the response data, i.e. Output text, Emotion and Output parameters.
Session ScriptEnd dialogThe End dialog scripts execute once, at the end of each session/dialogue.
Session ScriptPre-loggingThe Pre-logging scripts allow for (partial) access to the dialogue history through engineAccess and are executed after a session has completed and after the End dialog scripts, but before the data is written to logs. The Pre-logging scripts allow to modify content fields, for example, input/output text, input/output parameter values and Variable values, and enables the removal of data which should not be logged.
Session ScriptOn topThe On top scripts are executed whenever a Flow reaches the top of the flow stack (either by being triggered or by regaining the top position after being interrupted by the triggering of another Flow).
Session ScriptOn dropThese scripts execute when a Flow is dropped (finished or "stuck").
Engine ScriptSolution loadedThe Solution loaded scripts execute subsequent to loading of the solution; they usually contain definitions of utility functions that are called from other script locations. General scripting functionalities are usually written in Solution loaded scripts.
Engine ScriptSolution unloadedThe Solution unloaded scripts run once directly before the solution is unloaded.