DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Categorizing Content Without Labels Using Zero-Shot Classification
  • Exploring the Landscape of Generative AI
  • An Introduction to BentoML: A Unified AI Application Framework
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning

Trending

  • The Modern Data Stack Is Overrated — Here’s What Works
  • How AI Agents Are Transforming Enterprise Automation Architecture
  • Understanding IEEE 802.11(Wi-Fi) Encryption and Authentication: Write Your Own Custom Packet Sniffer
  • Accelerating AI Inference With TensorRT
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Dialogflow CX Entity Types

Dialogflow CX Entity Types

Learn what a Dialogflow CX entity type is and how easy it is to create entity types and evolve your NLU in Dialogflow CX, either with the console or the CX CLI!

By 
Xavier Portilla Edo user avatar
Xavier Portilla Edo
DZone Core CORE ·
Jan. 26, 23 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
3.8K Views

Join the DZone community and get the full member experience.

Join For Free

Previous Requisites

Here are the technologies used in this project

  1. Google Cloud Account 
  2. Dialogflow API enabled
  3. Dialogflow CX CLI - Installed and configured

What Are Entity Types?

Show me yesterday's financial news

One of the most important parts of NLU is the entity types or entities. These are the key information in a text, such as names, dates, products, organizations, places, or anything we want to extract from the text. We call this concept “entities." For example, let’s take a look at the order_intent intent:

  1. I want a pizza.
  2. I want 3 Cokes.
  3. Give me two burgers.

As you can see in the example above, we can extract 2 entity types: quantity and order_type. We can extrapolate the utterances above like this:

  1. I want {quantity} {order_type}.
  2. Give me {quantity} {order_type}.

We can think about entity types as variables as well.

It is a good practice to test your training phrases with your end users. This will allow you to detect missing training phrases in your NLU.

Dialogflow Console

Dialogflow Console is a web interface where you can design your conversations by creating agents and within an agent, create flows, intents, entity types, etc. On the Dialogflow Console, you can create and interact easily with your intent. To do that you just need to go to the Dialogflow CX Console. This is what it looks like:

Dialogflow CX Console

You will find your entity types in the Manage tab and the clicking in the entity types section:

Find your entity types in the Manage tab and the clicking in the entity types section

With the Dialogflow CX Console, you can do the following:

  1. Create an entity type: When you create an entity type, you can add synonyms.
  2. Delete an entity type.
  3. Train and validate your NLU.

When you are creating an entity type, you can specify whether or not it has synonyms or if it is a regexp entity. If you choose the regexp option, the classifier will use a regular expression instead of synonyms during query classification.

These are the entity types that you can use in your intents:

  1. Custom entities: Entity types created by the developer
  2. System entities: The ones available in Dialogflow CX (number, dates, colors, etc.)
  3. Session entities: These are dynamic entities that can be extended during the users’ sessions.
  4. Regexp entities: Entities that are regular expressions

Whenever you create, modify or delete an entity type it is important to re-train your Dialogflow CX flows. This will re-train your NLU. By doing this your bot will “understand you,” including your latest changes.

Dialogflow CX CLI

The Dialoglfow CX CLI or cxcli is a command line interface tool that you can use to interact with your Dialogflow CX projects in a terminal. It is an open-source project created I created. With the cxcli, you can interact easily with your Dialogflow CX entity types.

All of the commands that you have available in the cxcli to interact with your entity types are located down the cxcli entity-type command.

Create

You can create an entity type using this tool. This command has this usage:

cxcli entity-type create [entity-type-name] [parameters]


You can find the full usage here. It is important to explain the --entities parameter. It is a list of the entities with their synonyms, comma separated. This parameter has the following format:

entity1@synonym1|synonym2,entity2@synonym1|synonym2


Here you have an example: pikachu@25|pika,charmander@3. 

This a simple example of the cxcli entity-type create command:

cxcli entity-type create order_type --entities "pizza@piza|pizzas,burguer@hamburguer|burguers" --agent-name test-agent --project-id test-cx-346408 --location-id us-central1


The command above will give you an output like this one:

$ cxcli entity-type create order_type --entities "pizza@pizza|pizzas,coke@coke|cokes" --agent-name test-agent --project-id test-cx-346408 --location-id us-central1
INFO Entity Type created with id: projects/test-cx-346408/locations/us-central1/agents/40278ea0-c0fc-4d9a-a4d4-caa68d86295f/entityTypes/457a451d-f5ce-47da-b8dc-16b17d874a5d 


You can see the order_type entity type on the Dialogflow CX Console:

You can see the order_type entity type on the Dialogflow CX Console

Delete

Also, an entity type can be deleted. The usage of this command is pretty much similar to the one used for creating an entity type:

cxcli entity-type delete [entity-type-name] [parameters]


You can find the full usage here. This a simple example of the cxcli entity-type delete command:

cxcli entity-type delete pokemon --agent-name test-agent --project-id test-cx-346408 --location-id us-central1


The command above will give you an output like this one:

$ cxcli entity-type delete pokemon --agent-name test-agent --project-id test-cx-346408 --location-id us-central1
INFO Entity Type deleted                 

Resources

If you want to check the full usage of the cxcli entity-type command, please refer to this page.

If you want to learn more about Dialogflow CX entity types, check the official documentation.

Conclusion

This was a basic tutorial to learn what a Dialogflow CX entity type is. As you have seen in this example, creating entity types and evolving your NLU in Dialogflow CX either with the console or the cxcli is very easy!

I hope this tutorial will be useful to you.

That’s all folks! Happy coding!

Command-line interface Dialogflow entity Natural language generation Machine learning

Published at DZone with permission of Xavier Portilla Edo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Categorizing Content Without Labels Using Zero-Shot Classification
  • Exploring the Landscape of Generative AI
  • An Introduction to BentoML: A Unified AI Application Framework
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: