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

The Global Scripts are available on the Solution dashboard in the Globals tile; clicking the right-pointing arrow takes the user to the list of Global Scripts.

View of Global Scripts

In this view the user will find:

  • The list of existing Global Scripts (if any)
  • The "Order" column indicating the execution order of Global Scripts, read more
  • Create button allowing to create a new Global Script
  • Text filter available in the top ribbon.

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.

The Global Script window is accessed from the list of Scripts by either creating a new Global Script or by clicking any existing Global Script.

Global Script window

The Global Script contains the following:

  • The path in the top ribbon allowing to easily return to the list of Global Scripts or the Solution dashboard
  • Script editor to define the execution script.

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.

To create a new Global Script, follow the below steps:

  • First, either:
    • Click the Create button next to Scripts in the Globals tile on the Solution dashboard, or
    • In the Global Scripts list, click on Create New Global Script

Create New Global Script

  • The Create Global Script opens, select the wanted Script type and click Next
  • Now, give the Global Script a Name and optionally write a description
  • Click Create
  • Now, in the Script editor, define the execution script in Groovy
  • Remember to Save the Global Script to preserve the changes.

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

To edit a Global Script, follow the below steps:

  • Go to the list of Global Scripts (Solution dashboard > Globals tile > Scripts)
  • In the list, select and click the script to open it
  • Now, perform any needed changes
  • Remember to Save the Script to preserve the changes.

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

To save a Global Script, follow the below steps:

  • Click Save in the top ribbon
  • Optionally, add a comment
  • Click Save to confirm the save action or Cancel to abort the save

The Save button is only visible when changes are performed to an already existing Global Script or if the Global Script has not been saved earlier

Successful save is confirmed with a "Document saved successfully!" message; by clicking elsewhere in the browser window the message is closed.

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.

To close a Global Script in Teneo Studio Web:

  • First, remember to Save if any changes were performed in the Global Script; Teneo Studio will prompt the user to save if unsaved changes are detected
  • Next, simply navigate back by using the back arrow of the browser or by clicking a location in the folder path available in the top ribbon.

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.

To delete a Global Script in Teneo Studio Web, follow the below steps:

  • Navigate to the list of Global Scripts (Solution dashboard > Globals tile > Scripts)
  • Hovering over the Script an icon of a recycle bin appears in the right side of the browser window, click on it
  • The user is prompt to confirm the deletion of the Global Script, click Delete to confirm the deletion.

Note that deletion of a Global Script currently cannot be undone in Teneo Studio Web, for this action please refer to the Recycle Bin available in Teneo Studio Desktop.

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.

A text filter is available in the top ribbon of Teneo Studio Web which allows to filter on the displayed list of documents; simply write the wanted letter combination to start filtering on the list.

The filter works on the following columns; Name, Description, Author.

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.

The Script Ordering allows the user to organize the order in which the Scripts are executed, the Scripts can be ordered by dragging/dropping them into the desired order; this is done in the list view of the Global Scripts by pressing the three horizontal lines in the far-left side of a Script and dragging it onto the wanted position where it is then dropped.

Note that it is not possible to drag/drop from one script type to another, only within the given script type. Also the option to drag/drop only appears when two or more Scripts of the same type are available.

When changing the order of one or more Scripts, remember to click Save in the top ribbon to preserve the changes.

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.