Teneo Developers

Extract Entities

Sometimes it's not enough to recognize which flow to trigger. Your bot may also need to extract some piece of information from the input to respond appropriately.

A typical use case is picking up the user's order and repeating it, like in this example:

User: I'd like to order a coffee.
Bot: Ok, what coffee would you like?

User: A cappuccino, please.
Bot: Ok, a cappuccino will be ready for pickup in 5 minutes.

In the following, we will show you how to create a flow that enables users to have this kind of conversation with your bot. This approach will make use of the entity we created earlier. These are the steps involved:

  • Add a new flow.
  • Set up a flow variable.
  • Add another output node.
  • Configure a data action to extract information.
  • Use the information in the output.

final flow layout

Create a new flow

We will begin by creating a new flow. Just as previous flows we have built, it will have a trigger and an output node.

  1. While inside the Flows folder, click on the 'Create' button followed by 'Create new flow'.
  2. Give the flow the name User wants to order a coffee.

We now need to create a flow variable. The flow variable will later hold the coffee type that the user has mentioned.

  1. Add a new variable below the flow descriptions and give it the name orderedCoffeeType.
  2. Put "" in the 'Variable value' field. This initializes the variable with the empty string.
  3. Finally, click on 'Create' to create your flow.

Let's proceed by further developing our flow.

Populate the trigger

  1. Name the trigger Order a Coffee.

Now it is time to populate the trigger:

  1. Paste the following learning examples into the User Intent fields:
  • A small filter coffee, please
  • Can I get a coffee?
  • Can I have a coffee, please?
  • Can I order a coffee
  • Can I order an espresso?
  • Can you get me a coffee
  • Could I get a large macchiato?
  • Could I have a flat white
  • Could I order a large americano
  • Give me a Frappuccino, please
  • I want a small cappuccino!
  • I want espresso
  • I want to order a coffee
  • I would like a coffee
  • I would like to order a coffee
  • I'd like a large espresso
  • I'd like to order an americano
  • May I have a filter coffee?
  1. It is now time to generate a Match Requirement. Click on the Plus icon under the trigger, followed by 'Match' and 'Generate a draft'. This will automatically generate a Match Requirement for the trigger.
  2. Your trigger is now configured.

Populate the output node

In the output node, we want to prompt the user to indicate the desired coffee type in more detail:

  1. Name the output node Ask for coffee type.
  2. Click on 'Edit' and paste the following: Ok, what coffee would you like?.

Extract information from the user input

So far so good. You now have a flow that triggers when users want to order a coffee and answers with a question about the coffee type. To be able to pick up the coffee type from the user input, we now need to proceed with the following:

  • Using After Match, extract the coffee type mentioned by the user.
  • Add an additional output node that will summarize the order including the coffee type.

Configure the transition

The transition after the output node should only be traversed if the user mentions a coffee type. To ensure that, we need to:

  1. Click on the Plus icon after the output node.
  2. Select 'Continue with', followed by 'Transaction'. This will create an additional output node.
  3. Select the Plus icon under the user intent.
  4. Click on 'Match', followed by 'Entity'.
  5. Select COFFEES_SERVED in the Entity field. This means that Teneo will only continue when the user mentions something which matches the entity.

Extract information from the entity

Finally, we will store the coffee type that the user has mentioned in the flow variable orderedCoffeeType, and we will do so using a data action:

  1. Click on the Plus icon under the Match we just created.
  2. Select 'After Match', followed by 'Entity'.
  3. Enter COFFEES_SERVED in the text field.
  4. Click the 'Add Variable Mapping' button. This will allow you to extract a value from the Entity to be stored in a variable.
  5. The 'Source' (left) field denotes the value of the NLU variable of the entity 'COFFEES_SERVED' that we want to store. In our case coffeeType.
  6. The 'Target' (right) field denotes the name of the variable where the extracted value is to be stored. In our case orderedCoffeeType.

Summarize the order

Now it's time to edit the last output node which will hold the summary of the user's order. This output will name the coffee type mentioned by the user, which we have stored in the variable orderedCoffeeType.

  1. Navigate to the last output node.
  2. Name this output node Summarize order.
  3. Click on 'Edit' and paste in the following answer to summarize the order: Ok, a ${orderedCoffeeType} will be ready for pickup in 5 minutes..
  4. Finally, save the flow.

Test the scenarios

Now it's time to test the flow!

User: I'd like to order a coffee.
Bot: Ok, what coffee would you like?

User: A cappuccino, please.
Bot: Ok, a cappuccino will be ready for pickup in 5 minutes.

Test yourself

If you have done the previous test yourself there should be a working entity for Coffee Sizes. Add that entity here and don't forget to try it in Tryout.