Creating a custom Entity
Lab Steps
Introduction
Entities are objects within Dialogflow that can be used as parameters within Intents. Dialogflow comes with many predefined system entities but also allows you to expand the set to include user-defined options. In the previous step Dialogflow was incorrectly identifying your account number as a phone number. This is because Dialogflow does not know what an account number looks like! In this lab step, you will be creating a custom entity that captures the account number.
Instructions
-
Click Entities on the left hand side of the Dialogflow Menu.
This will bring you to an empty Entity Creation Menu. This menu is where you manage the creation and definition of the Entities that will slot in as parameters.
-
Click Create Entity in the top right corner.
If the Create Entity button is greyed out ensure you have Custom and not System selected. Each entity needs a name that should be machine safe. That is because this entity will be passed to the back-end service in a production use case and will need to be parsed by code. This can make white spaces and special characters difficult at times.
-
Name the entity account_number.
Entities can have one of many configurations in order to find matches. In the case of account number, it follows the same pattern every time so Regexp Entity is a good option to get started.
-
Click Regexp Entity. This will cause the checkbox to have a check and grey out Define Synonyms. The state of Define Synonyms as checked or unchecked does not matter.
-
Where the dialog box days Enter Value copy in (\d{5,5}[A-Za-z]{1,1})
You now need to save this entity and go back to complete our original Intent. The number of blank rows at the bottom does not affect behavior.
-
Click Save.
Summary
In this lab step, you created a custom entity. Entities are useful to identify key parameters within an end-user query. Entities can be customized to match your application or draw from Google’s large library of pre-built ones.