Listeners help your bot pick up relevant pieces of information from user inputs, even when these have not been explicitly prompted for. You can think of a listener as a fly on the wall, silently listening and registering things.
Listeners are often used to extract entities from user inputs.
When you add a listener to a flow, you can choose to make it listen to all inputs that trigger or pass through the flow or to make it only listen on a particular trigger or transition.
|Type||Description||How to add|
|Flow listener||Listens to all inputs that pass through a flow including inputs that trigger the flow.||- Open your flow in edit mode
- Go to the 'Flow' tab on the top left
- Select 'Listeners' from the purple bar on the left hand side.
|Trigger / transition listener||Is defined in relation to a specific point of a flow; will only kick in for inputs of the trigger or transition where the listener was added.||- Open your flow in edit mode
- Select the trigger or transition
- Open the 'Listeners' panel on the right of the 'Flow' window.
A listener is made up of two parts: a condition and an optional script. The condition determines what patterns should be listened for, e.g. the name of a city. The operation defines what should happen when the condition is met, for example setting a variable, or updating a counter.
Sometimes you can extract the information you want in the condition itself. In that case, you don't need to specify a script. In the example below the listener extracts the destination mentioned in the user input. More on how to extract data from inputs here.
If you need additional programmatic logic, for example to further process what you have extracted, you can add it to the script field:
If you find yourself creating the same listener on multiple triggers or transitions, you might want to check if you can use flow listener instead.
In addition to flow listeners Teneo also allows you to create global listeners that listen to any input, independent of the flow.
Global listeners, just like flow listeners, help your bot pick up relevant pieces of information from user inputs, even when these things have not been explicitly prompted for. You can think of a listener as a fly on the wall, silently listening and registering things. However, global listeners listen to any input in a conversation, whereas flow listeners only listen to inputs that trigger or pass through a particular flow.
It can be very tempting to use a global listener any time you want to pick something up from an input. For example, you could create a global listener that stores the name of a user in a global variable 'userName' whenever a name is encountered in an input. However, this is generally not a good practice. Because the global listener operates on each input, it might accidentally overwrite 'userName' with any name, like the name of the user's sister for example. In general it is best to use a flow listener for the flow where you specifically anticipate to receive a particular detail and only use global listeners to listen for things that transcend flows.
Global listeners are made up of the same parts as flow listeners: a condition and an operation. The condition determines what patterns should be listened for, e.g. a postive sentiment. The operation defines what should happen when the condition is met, for example updating a counter or adding an annotation. An example of a global listener that counts the number inputs in a conversation that express a positive sentiment could look like this:
You manage global listeners in the Globals area of your solution:
There are two types of global listeners, pre matching listeners and post matching listeners.
You can find more details about the order in which Teneo executes listeners (and other tasks) in the Input processing path reference.
Was this page helpful?