Dialogflow - Creating Custom Entities



Dialogflow allows you to create your own entities as there can be cases in which you want to get specific data from users which is not given by the system entities. So you can create a unique entity to handle this.

Dialogflow uses entities to understand and extract important information from user input. For example, "London" is a key phrase in the query "Book a flight to London" and Dialogflow has to identify it as a place. Entities help Dialogflow find and understand these important elements.

Types of Entities

There are two types of entities available in Dialogflow −

  • System Entities: Dialogflow comes with built-in system entities. For example, Dialogflow already knows places, numbers, dates and so on.

  • Custom Entities: Use Custom Entities to create your own entities. For example, if you are creating a pizza ordering bot so you can create an entity called "PizzaToppings" that can tell when customers mention specific toppings like cheese, pepperoni or mushrooms.

Create Your Own Entities

There are some steps you need to follow to create your own entity −

Steps 1: First you need to click the button called 'Entities +' which is present on the left sidebar menu.

Dialogflow Entities

Step 2: After that you have to give the entity name suppose i want to enter programming-language.

Dialogflow Entities Name

Step 3: Now you can add the entity entries like the below −

Dialogflow Entity Entries

Step 4: And then you have to click on the Save button and wait till the Agent Training dialog shows that Agent training has been completed.

Dialogflow Entity

The Dialogflow can easily manage some things, such capitalization and plurality but you have to add as many synonyms as you can for the items. Adding more synonyms will help the agent recognize the things more quickly.

Use your New Entity

If you want to use the new entity so you have to add the training phrases to the set-language. Use your new entity by doing the following −

Step 1: First select the 'Intents' option from the menu on the left sidebar.

Dialogflow Intent

Step 2: And then you have to click on the intent set-language.

Dialogflow Select Intent

Step 3: After that you need to add the various training phrases like I know Java and I can write code in Java.

Dialogflow Intent

Step 4: Keep in mind that these training phrases' programming language is automatically tagged and added to the Action and Parameters section. The next test response you have to give is $programming-language is a good programming language.

Dialogflow Add Test Response

Step 5: After that you have to wait until the Agent Training dialog box shows that Agent training is finished before clicking the Save button.

Dialogflow Use your new entity

Test your New Entity

Type "I know how to code in java" and hit "Enter" to test your new entity. It is clear that the Dialogflow identified the Java entity and extracted the Java from the programming-language parameter. The value was then added into the response.

Dialogflow Test your New Entity
Advertisements