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 Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Dialogflow CX Intents

Dialogflow CX Intents

Explore this tutorial to learn how to easily create intents and evolve your NLU in Dialogflow CX, using either the console or the CX CLI.

Xavier Portilla Edo user avatar by
Xavier Portilla Edo
CORE ·
Jan. 24, 23 · Tutorial
Like (1)
Save
Tweet
Share
1.57K 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 

What Are Dialogflow CX Intents?

Slot -> Utterances -> Intent graphic

Before we start talking about intents, it is important to understand what NLU is. Natural Language Understanding (NLU) is a subset of Natural Language Processing (NLP). It helps a “machine” to be able to understand human language. In Dialogflow CX, this is an important part, since it will help to predict the user’s intention, allow us to act in a “smarter” way, and avoid the already typical question: “I did not understand you, could you repeat it?” We call these intentions, proposals, or user requests, which the machine must classify. These are the “intents." 

Each intent has training phrases. For example, the welcome_intent intent can have these 3 training phrases:

  1. "Hi"
  2. "Hello"
  3. "What’s up?"

As you can see in the example above, our intention with the welcome_intent intent is to start a conversation when a user says any of these training phrases. An intent can have multiple entities. The entities are going to be explained in a future article.

To showcase another example, if we take a look at the image above, we will see the get_info intent. This intent has multiple training phrases as well:

  1. "Tell me info about Pikachu"
  2. "Tell me information about Pikachu"
  3. "Info Pikachu"
  4. "Pikachu"

So we can request information about a certain Pokemon in multiple ways. In this example, pikachu is an entity.

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 intents in the Manage tab and the clicking in the intents section:

Find your intents in the Manage tab and the clicking in the intents section

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

  1. Create an intent: When you create an intent, you can add training phrases and add a description or labels to that intent. You can add entity types as well to an intent.
  2. Delete an intent.
  3. Train and validate your NLU.

Whenever you create, modify, or delete an intent, 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 Dialogflow 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 I created. With the cxcli, you can interact easily with your Dialogflow CX intents.

All of the commands that you have available in the cxcli to interact with your intent are located down the cxcli intent command.

Create

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

cxcli intent create [intent-name] [parameters]


You can find the full usage here. It is important to explain the --training-phrases parameter. Why? Because it is the most important parameter. It is a list of the training phrases for this intent, comma separated. For the entities used in this intent, add @entity-type to the word in the training phrase. This is the format:

word@entity-type


Here you have an example: hello, hi how are you today@sys.date, morning!

This a simple example of the cxcli intent create command:

cxcli intent create test_intent --training-phrases "hello, hi how are you today@sys.date, morning"  --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 intent create test_intent --training-phrases "hello, hi how are you today@sys.date, morning"  --agent-name test-agent --project-id test-cx-346408 --location-id us-central1
INFO Intent created with id: projects/test-cx-346408/locations/us-central1/agents/40278ea0-c0fc-4d9a-a4d4-caa68d86295f/intents/a7870357-e942-43dd-99d2-4de8c81a3c09 


You can see the test_intent on the Dialogflow CX Console:

You can see the test_intent on the Dialogflow CX Console

Delete

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

cxcli intent delete [intent-name] [parameters]


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

cxcli intent delete test_intent --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 intent delete test_intent --agent-name test-agent --project-id test-cx-346408 --location-id us-central1
INFO Intent deleted                 


Resources

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

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

Conclusion

This was a basic tutorial to learn what a Dialogflow CX Intent is. As you have seen in this example, creating intents 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 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.

Popular on DZone

  • Type Variance in Java and Kotlin
  • Exploring the Benefits of Cloud Computing: From IaaS, PaaS, SaaS to Google Cloud, AWS, and Microsoft
  • What Java Version Are You Running? Let’s Take a Look Under the Hood of the JDK!
  • Distributed SQL: An Alternative to Database Sharding

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: