Global Listeners
A Global Listener listens for user input anywhere in the solution; this type of Listener can be used when wanting to listen for certain user inputs regardless of the Flow or transition. Just like Flow Listeners, Global Listeners help your bot pick up relevant pieces of information from user inputs, even when these things have not been explicitly prompted for.
The sections on this page provide information about the various aspects of Global Listeners:
Concept
A Global Listener listens for user input anywhere in the solution; this type of Listener can be used to listen for certain user inputs regardless of the Flow or transition. Just like Flow Listeners, Global Listeners help your bot pick up relevant pieces of information from user inputs, even when these things have not been explicitly prompted for.
Global Listeners are made up of the same parts as Flow Listeners: a TLML Syntax condition, which determines what patterns should be listened for, and an optional Execution Script, which defines what should happen when the TLML Syntax matches.
For example, you may have a Listener where:
- The TLML Syntax is set to match the name of a city, e.g.
%TO.FW.LEX >> %CITY.ENTITY^{destination = lob.city} - The Execution Script finds airports close to the city, e.g.
nearbyAirports = AirportChecker.findAirports(destination)
Be careful not to accidentally overwrite variables with the use of Global Listeners. For example, creating a Global Listener that stores the name of a user in the variable 'userName' whenever a name is encountered is risky, as it might accidentally overwrite 'userName' if several names are mentioned in the input.
In general, it is best to use a Flow Listener for the Flow where you specifically anticipate receiving a particular detail and only use Global Listeners to listen for things that transcend flows.
Global Pre Listeners vs Global Post Listeners
There are two types of Global Listeners, pre matching Listeners and post matching Listeners. The difference between the two is the execution order:
- Global Pre Listeners are run before the user input is tested against triggers, so if the user input matches a Global Pre Listener, the Listener's Execution Script is executed immediately before any Flow is triggered.
- Global Post Listeners are executed after a Flow is triggered.
Global Pre Listeners listen to inputs before Teneo tries to match the user input to a trigger or transition and are best suited when you want to do things that are important during matching. For example, you may want to add Annotations that can then influence if a particular trigger or transition should match.
A Global Pre Listener can first annotate a postal code in a user input and then use a TLML Syntax that says 'you should only match if a postal code is present in the input'. Because the annotation is added before Teneo tries to match the TLML Syntax, the annotation will be taken into account.
Global Post Listeners act on inputs directly after Teneo finds a matching trigger or a transition waiting for a new input. You can't use them during the matching process, because by the time the Post Listeners are executed, the matching process is already completed.
A Global Post Listener can check if the currently triggered Flow was stored in a particular folder, like the 'Flows' folder. If true, the Listener would then perform the task specified in the Listener's operation
This means that if you wish to perform an action before a Flow is triggered, you should use Global Pre Listeners, while Global Post Listeners should be used for those tasks which are performed after the user input has triggered a Flow.
Listener Ordering
You can have multiple Listeners in a solution. The Listener Ordering allows the user to organize the order in which the Listeners are executed. Setting an execution order for the Listeners is crucial because it also dictates in which order the variables are populated.
For example, you may find the following ordering:
- In first position, a Listener that listens for a user's name and populates the value of the user name variable.
- In second position, a Listener that listens for a user's child's name and populates the value of the user's child name variable.
This means that the user name Listener listens first, waits for the variable value to be found (in this case, the user's name mentioned in the user input) and assigns it to the user name variable. Only after that would the second Listener start listening for the user's child's name in the user input, which is eventually assigned to the user's child name variable.
How To
Open
- Teneo Studio Desktop
- Teneo Studio Web
To open a Global Listener from the backstage of Teneo Studio, simply double-click the Listener; alternatively click the Edit button available in the right-side top of the view.
To open a Global Listener from the list of Listeners (Solution dashboard > Globals tile > Listeners), simply click on the name of the Listener to open it.
Close
- Teneo Studio Desktop
- Teneo Studio Web
To close a Global Listener, either:
- Click the X in the top, right corner of the Global Listener window
- Click the Close button available in the top ribbon
- In the Global Listener's backstage, click Close in the left-side menu
If there are unsaved changes, Teneo Studio will prompt the user to Save or Close without saving.
To close a Global Listener in Teneo Studio Web:
- First, remember to Save if any changes were performed in the Global Listener; 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.
Create
- Teneo Studio Desktop
- Teneo Studio Web
To create a new Global Listener, follow these steps:
- In the Global Listeners view, click Add and select Pre-Listener or Post-Listener in the dropdown.
- The new Listener window opens.
- Write a Name and optionally a Description.
- Click the back-arrow in the top left corner when done.
- In the TLML Syntax field, write the syntax that will be used when testing user inputs.
- In the Execution Script field, write - in Groovy - what the Listener should do when the TLML syntax is matched.
- If required, the following properties can be modified below the Execution Script field:
- Test sentence from: select either Last to first (default) or First to last
- Limit unused words to: tick this option to set the number of accepted unused words
- Stop after: select between First match, Current sentences tested (only Global Post-Listeners) and All sentences tested
- Remember to click Save in the top ribbon.
To create a new Global Listener follow these steps:
- First, either:
- Click the Create button next to Listeners in the Globals tile on the Solution dashboard, or
- In the Global Listeners list, click on Create New Global Listener
- The Create Global Listener opens, select between Pre Listener and Post Listener and click Next.
- Now, give the Global Listener a Name and optionally write a description.
- Click Create.
- In the If input Matches (TLML) field, write the TLML syntax that should be used when testing user inputs.
- In the Then execute (Groovy) field, write the Groovy script which should be executed when the TLML syntax is matched.
- Remember to Save the Global Listener to preserve the changes.
Edit
- Teneo Studio Desktop
- Teneo Studio Web
To edit a Global Listener in Teneo Studio Desktop, follow these steps:
- Navigate to the backstage view by clicking the Solution tab.
- Select Globals; this will open a window with all your Global Pre Listeners and Post Listeners.
- Click on the Listener you wish to edit; an editing section will open on the right.
- Click Edit (or Go to if you previously opened the Listener) and edit the Listener.
- Remember to Save the Global Listener to preserve the changes.
To edit a Global Listener in Teneo Studio Web, follow these steps:
- Go to the list of Global Listeners (Solution dashboard > Globals tile > Listeners).
- In the list, select and click the Listener to open it.
- Now, perform any needed changes.
- Remember to Save the Listener to preserve the changes.
Save
- Teneo Studio Desktop
- Teneo Studio Web
To save a Global Listener with a comment follow these steps:
- Click Save in the top ribbon of the Global Listener.
- Optionally, write a comment in the dialogue box.
- Click OK.
To save directly and bypass the comment, press the Alt key while clicking the Save button.
To save a Global Listener, follow these 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 Listener or if the Global Listener 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.
Delete
- Teneo Studio Desktop
- Teneo Studio Web
To delete a Global Listener, follow these steps:
- In the backstage of Teneo Studio (Solutions tab > Globals > Listeners) select the Listener(s) to delete.
- Click Delete in the top, right side of the list.
- Teneo Studio prompts the user to confirm the deletion of the selected Listener(s).
- Click Yes to continue.
Read more about deletion and usage check here.
If a Global Listener is deleted by mistake, it can be restored from the Recycle Bin.
To delete a Global Listener in Teneo Studio Web, follow the below steps:
- Navigate to the list of Global Listeners (Solution dashboard > Globals tile > Listeners).
- Hovering over the Listener 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 Listener, click Delete to confirm the deletion.
The deletion of a Global Listener currently cannot be undone in Teneo Studio Web. For this action please refer to the Recycle Bin available in Teneo Studio Desktop.
Order
- Teneo Studio Desktop
- Teneo Studio Web
Listener Ordering is handled at the bottom of the Global Listeners view in Teneo Studio Desktop:
- Select the listener you want to move up/down by clicking the blue arrows in the right side of the list of Global Listeners.
- Remember to Save ordering to preserve the changes.
- Click Continue in the save prompt or Cancel to omit the changes.
You can also view previous versions:
- Select the version in the History window to view it.
- Set the 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.
To order your Global Listeners in Teneo Studio Web, follow these steps:
- In your solution dashboard, navigate to the Globals section.
- Select Listeners; a new page with all your Global Listeners will open.
- Order the Listeners by dragging/dropping them into the desired order by pressing the three horizontal lines in the far-left side.
- When changing the order of one or more Listeners, remember to click Save to preserve the changes.
It is not possible to drag/drop from Pre to Post nor from Post to Pre, only within the given Listener type.
The option to drag/drop only appears when two or more Listeners of the same type are available.
Filter
- Teneo Studio Desktop
- Teneo Studio Web
To filter your Listeners in Teneo Studio Desktop, follow these steps:
- In an open solution, navigate to the backstage view and select listeners.
- Find the Filter Listeners bar on the left side and perform the search.
To filter your Listeners in Teneo Studio Web, follow these steps:
- Go to the list of Global Listeners (Solution dashboard > Globals tile > Listeners).
- Select Filter documents in the path in the upper part of the page and perform the search.
UI
Global Listeners Overview
- Teneo Studio Desktop
- Teneo Studio Web

In this view, you will find:
- Left side:
- Text filter
- Add button
- List of existing Global Listeners in solution
- Listener Ordering including buttons to edit, view history, and set/unset stable
- Right side:
- Ribbon options allowing to Edit, Delete, view History, set/unset Stable version, include/exclude in branching (Localization setup)
- Details of the selected Listener providing a read-only summary
- Global Listener's Id

In this view you will find:
- The list of existing Global Listeners (if any).
- The "Order" column indicating the [execution order](listener ordering) of Global Listeners.
- Plus button allowing to create a new Global Listener.
- Text filter in the top ribbon.
Global Listener Window
- Teneo Studio Desktop
- Teneo Studio Web
When clicking Add or Edit, the Global Listener window will open; the window consists of two tabs: Listener allowing to access the backstage of the window and the Home tab presenting the main view of the the Global Listener.
The Home tab of the Global Listener window contains the following:

Top ribbon
| Section | Item | Description | Related Pages |
|---|---|---|---|
| Listener | Close | Close the Global Listener window. | |
| Save | Save the Global Listener in the current state; clicking the lower part of the button allows the user to save the Flow with or without a comment. | ||
| Execution | 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. | |
| Edit | Undo/Redo | Undo/redo changes performed in the Global Listener | |
| Stable Version | Set/unset | Set the current version of the Global Listener as stable or unset it | Version Flags |
| Branching | Include/Exclude | Include or Exclude the Global Listener from branching when working in a Localization setup. | Localization setup |
Listener editor
| Section | Item | Description | Related Pages |
|---|---|---|---|
| TLML Syntax Editor | TLML Syntax | Defines TLML Syntax Match. | TLML Syntax Match Teneo Linguistic Modeling Language (TLML) |
| Execution Script | Execution Script | An optional Groovy script that will be executed if TLML Syntax matches. | Groovy basics |
| Advanced settings | Test sentences from | Selects how sentences in input are tested. Select 'First to last' if Engine should start testing at the first sentence and work forward, or leave the default 'Last to first' if Engine should test the last sentence first and move backwards. | |
| Limit unused words to | Specifies a maximum number of words which the user input may contain (beside those matching the TLML syntax) for the match to be satisfied. The Listener will only execute if the TLML Syntax has fewer unused words than the defined limit. | ||
| Stop after* | Determines when TLML Syntax will stop evaluating. |
*The Teneo Engine stops testing sentences and user inputs once a match is found, but the Stop after setting allows to modify this behavior providing the following options:
- First match (Default): testing is stopped when a match is found
- All sentences tested: the TLML Syntax of the Global Listener is tested against all the sentences in the user input creating an array of results
- Current sentences tested (only Post-Listeners): the TLML Syntax of the Global Listener attempts to match against the most recent syntax (the previous trigger or input consuming transition).
The Listener tab opens a Properties window consisting of a left-side menu with the following options and information:

| Item | Description | Related pages |
|---|---|---|
| Save | Save the Global Listener in the current state. | |
| Properties | Allows to edit the name and description of the Global Listener; the Id of the Listener is available in the lower area of the window. | |
| History | Lists the history and versions created each time the Global Listener 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 ribbon. | Version Flags History |
| Close | Close the Global Listener window. |
The Global Listener window contains the following:

| Item | Description | Related Pages |
|---|---|---|
| Path | Allows to return easily to the list of Global Listeners or the Solution dashboard. | |
| TLML Syntax editor | Defines the syntax that will be used when testing user inputs. | TLML Syntax Match Teneo Linguistic Modeling Language (TLML) |
| Script editor | Define what the Listener should do when the TLML syntax is matched. | Groovy basics |
Listener Ordering
The Listener Ordering is only available in the Global Listeners Overview in Teneo Studio Desktop.

| Item | Description | Related pages |
|---|---|---|
| Edit | Opens Listener Ordering in edit mode. | |
| History | Lists the history and versions created each time the Listener Ordering is saved. Comments added at save are displayed here. | History Version Flags |
| Set/Unset Stable | Set the current version of the Global Listener Ordering as stable or unset it. |
It is compulsory to set a version of the Listener Ordering to stable when using the Version flag feature of Teneo Studio.
Practical Examples
Sentiment Detection
Listeners can be used in multiple ways in Teneo. For this example, we will demonstrate how we can detect sentiment in Teneo and react accordingly when bad sentiment is detected.
Before our changes, we would have a conversation like this:
User: You are so bad. Bot: Really? That's very sad. I will try to perform better in the future.
After our modifications, it will look like this:
User: You are so bad. Bot: We do not condone this type of behavior. I understand that you're upset, but please don't speak to me that way.
To achieve this, we need to do the following:
- Create a Global Variable.
- Add a Global Listener.
- Recognize bad sentiment from the user.
Create a Global Variable
- Teneo Studio Desktop
- Teneo Studio Web
First, we will create a Global Variable to store the user input sentiment.
- Navigate to the Globals section in the Solution backstage.
- Select Variables and click Add to create a new Global Variable.
- Give the Global Variable the name
isUserNegative, an optional description, and set the initial value tofalse. This will turn to true if the variable is detected in the next step. - Save the Global Variable.
First, we will create a Global Variable to store the user input sentiment.
-
Navigate to the Globals section in the Solution Dashboard.
-
Click the plus icon for Variables to create a new Global Variable.
-
Add the name
isUserNegativean optional description, and set the value tofalse. This will turn to true if the variable is detected in the next step. -
Save the Global Variable.
Create a Global Listener
- Teneo Studio Desktop
- Teneo Studio Web
We will create a Global Listener to only react to negative inputs from the user.
- Navigate to the Globals tab in solution backstage and open the Listeners section.
- Click Add and create a new Pre Listener.
- Add the name
Negative Sentiment Detector, and optionally, a description for the Listener. - Use the arrow in the top left corner to move to the Listener tab and edit the Listener.
- In the TLML field, paste in the following:
%SENTIMENT_NEGATIVE_HIGH_CONFIDENCE.INDICATOR. - Below, in Execution Script, add the following Groovy code:
isUserNegative = true. - Save the Listener.
We will create a Global Listener to only react to negative inputs from the user.
-
Locate the Listeners section on the dashboard and click the plus icon to create a new Pre Listener.
-
Click on 'Next' and name the Listener
Negative Sentiment Detector. -
In the TLML field, paste in the following:
%SENTIMENT_NEGATIVE_HIGH_CONFIDENCE.INDICATOR. -
Below, execute the following Groovy code:
isUserNegative = true. -
Save the Listener.
The Teneo Sentiment NL Analyzer categorizes sentiment into negative, neutral and positive categories with either high confidence (clear, specific statements) or low confidence (partial statements or keywords that can vary according to context).
Teneo can detect five levels of sentiment:
- Negative High
- Negative Low
- Neutral
- Positive Low
- Positive High
Split the Path
- Teneo Studio Desktop
- Teneo Studio Web
The next step is create a new Flow that will trigger once bad sentiment is detected with our Global Variable 'isUserNegative' turning from false to true.
- Navigate to the Flows folder and create a new Flow called
Negative Sentiment Detected. Reuse the same name for the trigger node. - Name the trigger
Negative Sentiment Detectedand add some positive examples in User Intent, such as:You are so badGo to hellThis is the worst thing that ever happened
- In the Match section, add a Match for a Global Variable, and select 'isUserNegative'.
- Enter
trueas the 'Evaluation script'. This will cause the following intent to only trigger when actual bad sentiment from the user is detected.
The next step is create a new Flow that will trigger once bad sentiment is detected with our Global Variable 'isUserNegative' turning from false to true.
- Navigate to the Flows folder and create a new Flow called
Negative Sentiment Detected. Reuse the same name for the trigger node. - Name the intent node
Negative Sentiment Detectedand click edit to add some examples, such as:You are so badGo to hellThis is the worst thing that ever happened
- Below the intent node, click the plus icon to add a Match for Global variable, and select 'isUserNegative'.
- Enter
trueas the 'Evaluation script'. This will cause the following intent to only trigger when actual bad sentiment from the user is detected.
Modify the Output
- Teneo Studio Desktop
- Teneo Studio Web
Now we need to finish the flow by adding a fitting answer when the user is using negative sentiment.
- Navigate to the output node and name it
Bad sentiment detected. - Click edit to add the following answer:
We do not condone this type of behavior. I understand that you're upset, but please don't speak to me that way.
Now we need to finish the Flow by adding a fitting answer when the user is using negative sentiment.
- Navigate to the output node and name it
Bad sentiment detected. - Click edit to add the following answer:
We do not condone this type of behavior. I understand that you're upset, but please don't speak to me that way.
Reset Sentiment Detector
- Teneo Studio Desktop
- Teneo Studio Web
- Within the Flow, select the 'Scripts' symbol on the left to add a new Flow Script.
- Enter the following script:
isUserNegative = falsein the 'On Drop' section. - Save the Flow.
Now that we have created the Flow, we need to make sure we push back the Boolean to false again so that it does not keep triggering. This can be done with a Flow Script.
- Within the Flow, select the 'Scripts' symbol in the ribbon bar and add a new Flow Script.
- Enter the following script:
isUserNegative = falsein the 'On Drop' section. - Save the Flow.
Try it out
Let's go ahead and test the Flow:
User: You are so bad.
Bot: We do not condone this type of behavior. I understand that you're upset, but please don't speak to me that way.