Listeners

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.

Scope

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.

  • A flow listener will listen to all inputs of a flow including inputs that trigger the flow.
  • A trigger / transition listener is defined in relation to a specific point of a flow; it will only kick in for inputs of the trigger or transition where the listener was added.

Components

A listener is made up of two parts: a condition and an operation. 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.

Fields of a listener

Sometimes you can extract the information you want in the condition itself. In that case, you don't need to specify an operation. In the example below the listener extracts the destination mentioned in the user input. More on how to extract data from inputs here.

Listener with a condition

If you need additional programmatic logic, for example to further process what you have extracted, you can add it to the operation:

Listener with an operation

Use cases

  • Flow listeners - Flow listeners are defined for a flow and listen to all inputs that trigger or pass through a flow. They are generally used when your bot should pick up certain pieces of information wherever they are mentioned in the flow dialog. Slot filling flows typically make use of flow listeners.
  • Trigger/transition listeners - Trigger or transition listeners are attached to a specific trigger or transition of a flow. A trigger/transition listener can be the best solution when you need to pick up something that can be interpreted differently depending on where you are in the flow. For example, if a flow should pick up two dates from a user (like an arrival and departure date for a holiday), you can add a listener to the transition where the user is asked for the arrival date and another listener to the transition for the departure date.

Execution order

In addition to flow listeners Teneo also allows you to create global listeners that listen to any input, independent of flow. 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?