Teneo Developers

Script and listener events in the matching process

Script code execution

Script code is executed during a dialogue when it has been defined in an event that is triggered, or when a script node is reached in the matching process. The operation specified for a listener will only be carried out if, in addition, the listener's condition is fulfilled by the user input.

System and non-session scripts

These events do not occur during the matching process:

  • Solution loaded: This script runs once subsequent to loading of the knowledge base. It usually contains definitions of utility functions that are called from other script locations. This is the place to write general scripting functionalities.
  • Solution unloaded: This script runs once directly before the knowledge base is unloaded.

Session scripts

These events occur during the matching process:

  • Begin dialog: scripts here will be performed once, at the start of each session.
  • New session: this script runs following the Begin dialog script, subsequent to the beginning of a new session started by a new user.
  • Timed-out session: if the session was started by a user whose session was timed out, this script will run instead of the New session script. A session usually times out after 10 minutes of inactivity.
  • Pre-processing: this script runs before the sentences in the user input are separated for processing (before simplification). With pre-processing global scripts, the user input string can actually be changed.
  • Pre-matching: scripts here are run before matching, but after the input is separated into words.
  • Post-processing: post-processing scripts are executed after the conversational AI application has created a response, consisting of output text, emotion and output parameters, but before the response is given. The post-processing script makes it possible to change the response data.
  • End dialog: scripts here will be performed once, at the end of each session.
  • Global pre-listeners: these scripts are executed with every request, before the matching takes place.

Flow level scripts and listeners

Scripts and listeners can be executed depending on the events in the matching process. During this process, several transitions may be followed, and multiple Flows may be raised. Therefore, the actions described below can be carried out several times for different Flows.

Additionally, multiple script nodes may be reached during the matching process, and the code in those nodes will be executed. Similarly, script expression in conditions will be executed when the conditions are evaluated. However, those script locations will not be mentioned in the description below.

Do not write long scripts in solutions, build a proper Java class or library instead, which can be included as a JAR file in the solution resources. Then, just call the methods from the scripts.

Flow triggered

  1. Global post-listeners
  2. Flow actions:
    a. Flow post-listeners
    b. Trigger/transition listeners
    c. Global on top
    d. Flow on top.

Flow resumed

  1. Global on top
  2. Flow actions:
    a. Flow on top.

Flow B called from Flow A (Flow B being a Sub-flow)

  1. Global on top
  2. Flow actions:
    a. Flow on top (Flow B).

Return to Flow A from Flow B (Flow B being a Sub-flow)

  1. Global on drop

  2. Flow actions:
    a. Flow on drop (Flow B)

  3. Global on top

  4. Flow actions:
    a. Flow on top (Flow A).

  1. Global on drop
  2. Flow actions:
    a. Flow on drop (Flow A)
  3. Global on top
  4. Flow actions:
    a. Flow on top (Flow B).

Scripts/listeners executed inside a Flow

Input consuming transition followed

  1. Global post-listener
  2. Flow actions:
    a. Flow listeners
    b. Transition listener.

Non-input consuming transition followed

No listeners are executed in this case.

The Flow reaches the end-node

  1. Global on drop
  2. Flow actions:
    a. Flow on drop.

Global Scripts
Listeners and Variables in Teneo Studio
Scripts in Teneo