Teneo Developers

Advanced Concepts

Listeners can be used in multiple ways in Teneo. For this example, we will demonstrate one way of using a listener inside a flow. In the previous page on how to handle ambigous inputs, we demonstrated a way to handle partial understanding and catch keywords. Adding on to that, we will now add a listener to recognize if a coffee type is mentioned and the user wants to order it.

Before our changes, we would have a conversation like this:

User: espresso
Bot: You're talking about coffee. Would you please tell me what you wanted exactly? Did you want to order a coffee or see our selection coffees?

User: order
Bot: Ok, what coffee would you like?

After our modifications, it will look like this:

User: espresso
Bot: You're talking about coffee. Would you please tell me what you wanted exactly? Did you want to order a coffee or see our selection coffees?

User: order
Bot: Ok, a espresso will be ready for pickup in 5 minutes.

To achieve this we need to do the following:

Create a flow variable

Let us start off by opening the Partial Understanding: Coffee flow and creating a new flow variable to store the coffee type mentioned by the user.

  1. Open the Partial Understanding: Coffee flow in edit mode.
  2. While inside the flow, navigate to 'Flow' tab located.
  3. Click on 'Variables' add a new variable that has the name coffeeType and the value "".

Create a flow listener

Now it is time to add a flow listener to listen for the coffee type. We will also use the previously created COFFEES_SERVED.ENTITY for the condition.

  1. While inside the 'Variables' section, switch over to 'Listeners'.
  2. Click on the 'Add' button. This will open up a new flow listener.
  3. Name the listener Listen for coffee types.
  4. In the TLML Syntax field, paste in the following: %COFFEES_SERVED.ENTITY^{coffeeType = lob.coffeeType}.
  5. Click on 'Ok'.
  6. Click on the back arrow in the menu to return to the Home tab of the flow.

This can also be done by adding an Entity Match to the intent trigger.

The next step is to modify the flow link to send over the flow variable that stores the mentioned coffee type to the 'User wants to order a coffee' flow.

  1. While inside the flow, select the flow node 'User wants to order a coffee'.
  2. Navigate to the 'Target' section and select the drop-down menu right beside 'orderedCoffeeType'.
  3. From the drop-down menu, select the previously created flow variable 'coffeeType'. This will send the value from this flow variable to the 'orderedCoffeeType' flow variable inside 'User wants to order a coffee'.
  4. Save the flow.

Try it out

Let's go ahead and test the modified flow by mentioning a coffee type:

User: espresso
Bot: You're talking about coffee. Would you please tell me what you wanted exactly? Did you want to order a coffee or see our selection coffees?

User: order
Bot: Ok, a espresso will be ready for pickup in 5 minutes.

Next page
Scripting
Was this page helpful?