Table of Contents

Dialogflow & Landbot lesson 5: Entities and Landbot variables

Pau Sanchez Updated by Pau Sanchez

Prefer watching than reading? No problem, we've got you covered πŸ‘‡

One of the powerful features that Dialogflow offers is the ability to extract information (parameters) out of the user inputs and store it in a place where we can later use it. Those variables where we store those inputs are called "Entities". Here you have more information about entities and also a great video here

In this lesson we are going to use the example of a restaurant to "extract" such information. We want to give the opportunity to the user to tell us for when and how many people they want a reservation for.

So for example, if the users says "I want a table for 2 for Friday 14th" we will store "2" and "Friday 14th". This data, that will be captured in Dialogflow as entities, we can later store in Landbot variables, like @people and @reservation_date for example, and use it in our CRM or booking system, instead of storing the whole "I want a table for 2 for Friday 14th" which might not be really useful for our systems.

Let's do it!

  1. Create Intent

We will start by creating an intent for all those possible users that want to make a reservation. We will call it "reservation.trigger"

  1. Based on common sentences that we have from the past we have built a set of possible ways a user might tell us that is interested in making a reservation

As you can see some of them have all the information that we want (people and datetime of the reservation) and some others they might have only part or none. We will also deal with those types of users

  1. Now, one by one we will add those sentences in the intent we just created:

  1. Sometimes when we add a training phrase, Dialogflow will highlight part of the sentence, that part is what Dialogflow considers that is a entity

  1. If we scroll down, we will see the section "Actions and parameters", there is where we can set different configurations, like the name of the Parameter. Dialogflow automatically adds the entities that had been recognised while you were entering those training phrases

  1. There are two type of entities: System entities and Custom Entities. The main difference is that System entities are default Dialogflow entities, that are quick and ready to use. Custom Entities are not ready, and you need to create them from the "Entities" section, these ones are very useful for specific names or keywords, that Dialogflow doesn't have as default, like for example the name of the pizzas. In this lesson, we will use only System entities

  1. Now we want to add some more sentences that will add the entities that we want to use:
    "I would like to make a reservation for lunch for my 2 on October 21st."

Once submitted it will display the entities:

  1. Now we add the rest of Training Phrases

  1. In the section "Actions and Parameters" we will set the parameters as required, to make sure that the user gives us the required information:

  1. Once we set as Required, on the right side we will see that new options, called "Prompts"

  1. Now we need to set up each of the Prompts that will be triggered if the user input doesn't have the information ("entities required"). By clicking where it says "Define prompts..." it will open a modal to enter the texts
  2. We add a sentence that will "force" the user to give us the information we need
  3. And we do the same for all the prompts. In this case for 2

  1. And finally, we finish the setup of the intent with a Response sentence
  2. Now we do some tests and we will see how the information is captured

For simplicity we only take date of the reservation, but you can add another entity to specify the time

  1. Now let's go to Landbot to our Dialogflow block

  1. Inside the Dialogflow block, first we will set up the switch to "Show Advanced Configuration"

  1. To set up the block to store the entities in Landbot variables, we need to go to the "3. Save the Response" section and scroll to "Entities"

  1. Press "+ Add" to set up the first Entity to "catch"

  1. First we will add the "Parameter name", in our case the first one is "data-time"

So we add it with the same name:

  1. And now, we set the Landbot variable where we want to store the value, we will use @reservation_date
  2. After we can add the rest of entities we require to capture

And now we are done, in the next lesson, we will check how to "redirect" the user to a specific flow depending on parameters we captured with Dialogflow, like the name of the intent or some entities values

Next Lesson

Dialogflow & Landbot course 6: Combine NLP loop and Landbot flows Link to lesson

How did we do?

Dialogflow & Landbot lesson 4: Training phrases and responses for a FAQ

Dialogflow & Landbot lesson 6: Redirect user depending on Dialogflow response parameters (intent, entities and more)