1. Introduction to Dialogflow
Do you want to build a chatbot that can understand natural language and provide relevant responses to your users? If so, you might want to use Dialogflow, a powerful and easy-to-use platform for creating conversational agents.
Dialogflow is a Google service that allows you to design, build, and integrate chatbots with various platforms, such as websites, mobile apps, messaging apps, voice assistants, and more. You can use Dialogflow to create chatbots that can handle common tasks, such as booking appointments, ordering food, answering FAQs, or providing customer support.
But how does Dialogflow work? How does it understand what your users are saying and what they want? The answer lies in two key concepts: intents and entities.
Intents and entities are the building blocks of Dialogflow. They help you define the user’s intentions and the relevant information for your chatbot. In this blog, you will learn what intents and entities are, how to create and manage them in Dialogflow, and what are the best practices for designing them.
By the end of this blog, you will be able to build chatbots with Dialogflow that can understand natural language and provide meaningful responses to your users.
Are you ready to get started? Let’s dive in!
2. What are Intents and Entities?
Before you can create a chatbot with Dialogflow, you need to understand what intents and entities are and how they work. Intents and entities are the core components of Dialogflow that enable your chatbot to understand natural language and provide relevant responses to your users.
Intents are the main way to define the user’s goals or intentions when they interact with your chatbot. For example, if your chatbot is a pizza ordering bot, some possible intents are: order pizza, cancel order, track order, etc. Each intent represents a specific action that the user wants to perform with your chatbot.
Entities are the pieces of information that are relevant to the user’s intents. For example, if the user wants to order a pizza, some possible entities are: pizza size, pizza type, toppings, delivery address, etc. Each entity represents a parameter that your chatbot needs to know to fulfill the user’s intent.
Intents and entities are closely related. You can think of intents as the verbs and entities as the nouns of your chatbot’s language. Together, they form the basis of natural language understanding (NLU) in Dialogflow.
But how does Dialogflow recognize the user’s intents and entities? How does it match the user’s input to the appropriate intent and extract the relevant entities? The answer lies in another key concept: training phrases.
Training phrases are the sample sentences that you provide to Dialogflow to teach it how to identify the user’s intents and entities. For example, if your intent is order pizza, some possible training phrases are: “I want a large pepperoni pizza”, “Can I order a medium cheese pizza with mushrooms?”, “Please deliver a small veggie pizza to my address”, etc. Each training phrase should reflect how a real user might express their intent to your chatbot.
Dialogflow uses machine learning to analyze the training phrases and learn how to match the user’s input to the correct intent and extract the relevant entities. The more training phrases you provide, the better Dialogflow can understand the user’s language and handle variations and synonyms.
Now that you have a basic idea of what intents and entities are and how they work, let’s see how to create and manage them in Dialogflow.
2.1. Intents
In this section, you will learn how to create intents in Dialogflow and how to add training phrases to them. You will also learn how to test your intents and how to modify them if needed.
To create an intent, you need to follow these steps:
- Go to the Dialogflow console and select your agent.
- Click on the Intents tab on the left sidebar.
- Click on the Create Intent button on the top right corner.
- Give your intent a descriptive name that reflects the user’s goal. For example, order pizza, cancel order, track order, etc.
- Click on the Save button to create your intent.
Once you have created your intent, you need to add training phrases to it. Training phrases are the sample sentences that you provide to Dialogflow to teach it how to identify the user’s intent and extract the relevant entities. You can add as many training phrases as you want, but you should aim for at least 10 to 15 per intent.
To add training phrases, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Training Phrases section.
- Click on the Add Training Phrases button.
- Type or paste your training phrases in the text box. You can also use the @ symbol to insert predefined system entities or custom entities that you have created. For example, @sys.date, @sys.time, @pizza-size, etc.
- Click on the Done button to save your training phrases.
After you have added your training phrases, you can test your intent and see how Dialogflow matches the user’s input to it. You can also see how Dialogflow extracts the entities from the user’s input and assigns them to the parameters of your intent.
To test your intent, you need to follow these steps:
- Click on the Try it now button on the top right corner of the console.
- Type or paste a user input that matches your intent in the text box. For example, “I want a large pepperoni pizza”.
- Press the Enter key or click on the Send button to send your input to Dialogflow.
- Observe the response from Dialogflow in the right panel. You can see the name of the matched intent, the confidence score, the extracted entities, and the assigned parameters.
If you are satisfied with the result, you can move on to the next step. If not, you can modify your intent and add more training phrases or edit the existing ones. You can also delete your intent if you don’t need it anymore.
To modify your intent, you need to follow these steps:
- Select your intent from the Intents tab.
- Make the changes that you want in the intent name, training phrases, parameters, responses, or fulfillment.
- Click on the Save button to update your intent.
To delete your intent, you need to follow these steps:
- Select your intent from the Intents tab.
- Click on the Delete button on the top right corner.
- Confirm your action by clicking on the Delete button in the pop-up window.
Now you know how to create and manage intents in Dialogflow. In the next section, you will learn how to create and manage entities.
2.2. Entities
In this section, you will learn how to create entities in Dialogflow and how to assign them to the parameters of your intents. You will also learn how to use system entities and custom entities to define the types and values of your entities.
Entities are the pieces of information that are relevant to the user’s intents. For example, if the user wants to order a pizza, some possible entities are: pizza size, pizza type, toppings, delivery address, etc. Each entity represents a parameter that your chatbot needs to know to fulfill the user’s intent.
To create an entity, you need to follow these steps:
- Go to the Dialogflow console and select your agent.
- Click on the Entities tab on the left sidebar.
- Click on the Create Entity button on the top right corner.
- Give your entity a descriptive name that reflects the type of information that it represents. For example, pizza-size, pizza-type, toppings, etc.
- Define the values and synonyms for your entity. For example, for the pizza-size entity, you can define the values as: small, medium, large, and extra large. You can also add synonyms for each value, such as: s, m, l, xl, etc.
- Click on the Save button to create your entity.
Once you have created your entity, you need to assign it to the parameters of your intents. Parameters are the variables that store the values of the entities that are extracted from the user’s input. For example, if the user says “I want a large pepperoni pizza”, the parameter pizza-size will store the value large, and the parameter pizza-type will store the value pepperoni.
To assign an entity to a parameter, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Parameters section.
- Click on the Add Parameter button.
- Give your parameter a name that matches the entity name. For example, pizza-size, pizza-type, toppings, etc.
- Select the entity type from the drop-down menu. You can choose from the predefined system entities or the custom entities that you have created. For example, @pizza-size, @pizza-type, @toppings, etc.
- Click on the Done button to save your parameter.
Dialogflow will automatically detect and assign the entities from the training phrases that you have added to your intent. You can also manually annotate the entities in the training phrases by selecting the words and choosing the entity type from the drop-down menu.
Dialogflow provides a number of system entities that cover common types of information, such as dates, times, numbers, colors, etc. You can use these system entities to simplify your entity creation and extraction. For example, you can use the @sys.date system entity to extract any date format from the user’s input.
You can also create custom entities that define your own types and values of information. You can use custom entities to handle specific or complex information that is not covered by the system entities. For example, you can create a custom entity for pizza types that includes the values and synonyms of different pizza varieties.
Now you know how to create and manage entities in Dialogflow. In the next section, you will learn how to define parameters and how to use them in your responses and fulfillment.
3. How to Create and Manage Intents and Entities in Dialogflow
In the previous sections, you learned what intents and entities are and how they work in Dialogflow. In this section, you will learn how to create and manage them in Dialogflow using the console and the API. You will also learn how to use the built-in features and tools that Dialogflow provides to make your chatbot more intelligent and user-friendly.
Creating and managing intents and entities in Dialogflow is easy and intuitive. You can use the Dialogflow console, which is a web-based interface that allows you to design, build, and test your chatbot. You can also use the Dialogflow API, which is a RESTful API that allows you to programmatically interact with your chatbot and perform various operations, such as creating, updating, deleting, or querying intents and entities.
The Dialogflow console and the API have different advantages and disadvantages. The console is more user-friendly and convenient, but it has some limitations and restrictions. The API is more flexible and powerful, but it requires more technical skills and knowledge. You can choose the method that suits your needs and preferences.
Whether you use the console or the API, you need to follow the same basic steps to create and manage intents and entities in Dialogflow. These steps are:
- Create an intent and give it a name that reflects the user’s goal.
- Add training phrases to the intent that represent how the user might express their intent.
- Create an entity and give it a name that reflects the type of information that it represents.
- Define the values and synonyms for the entity that represent the possible values that the user might provide.
- Assign the entity to a parameter of the intent and select the entity type.
- Test the intent and the entity and see how Dialogflow matches the user’s input to the intent and extracts the entity value from the input.
- Modify or delete the intent or the entity if needed.
You can find detailed instructions and examples on how to perform these steps using the console or the API in the Dialogflow documentation.
Dialogflow also provides some built-in features and tools that can help you create and manage intents and entities more easily and effectively. Some of these features and tools are:
- Predefined system entities: These are entities that cover common types of information, such as dates, times, numbers, colors, etc. You can use these entities to simplify your entity creation and extraction.
- Template mode: This is a mode that allows you to create intents and entities using templates that are based on common chatbot scenarios, such as booking, ordering, reservation, etc. You can use these templates to speed up your chatbot development and customization.
- Smart suggestions: These are suggestions that Dialogflow provides to help you add more training phrases or entity values to your intents and entities. You can use these suggestions to improve your chatbot’s natural language understanding and accuracy.
- Validation and optimization: These are features that Dialogflow provides to help you validate and optimize your intents and entities. You can use these features to check for errors, warnings, or best practices violations in your intents and entities and fix them accordingly.
By using these features and tools, you can create and manage intents and entities in Dialogflow more efficiently and effectively.
In the next section, you will learn some best practices for designing intents and entities in Dialogflow.
3.1. Creating Intents
In this section, you will learn how to create intents in Dialogflow using the console and the API. You will also learn how to add training phrases to your intents and how to test them.
An intent is a way to define the user’s goal or intention when they interact with your chatbot. For example, if your chatbot is a pizza ordering bot, some possible intents are: order pizza, cancel order, track order, etc. Each intent represents a specific action that the user wants to perform with your chatbot.
To create an intent using the console, you need to follow these steps:
- Go to the Dialogflow console and select your agent.
- Click on the Intents tab on the left sidebar.
- Click on the Create Intent button on the top right corner.
- Give your intent a descriptive name that reflects the user’s goal. For example, order pizza, cancel order, track order, etc.
- Click on the Save button to create your intent.
To create an intent using the API, you need to follow these steps:
- Prepare a JSON request body that contains the name and other properties of your intent. For example, {“displayName”: “order pizza”, “priority”: 1, “webhookState”: “WEBHOOK_STATE_ENABLED”, …}
- Send a POST request to the projects.agent.intents endpoint with your agent’s project ID and the request body. For example, POST https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/intents
- Receive a JSON response that contains the name and other properties of your intent. For example, {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”, “priority”: 1, “webhookState”: “WEBHOOK_STATE_ENABLED”, …}
Once you have created your intent, you need to add training phrases to it. Training phrases are the sample sentences that you provide to Dialogflow to teach it how to identify the user’s intent and extract the relevant entities. You can add as many training phrases as you want, but you should aim for at least 10 to 15 per intent.
To add training phrases using the console, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Training Phrases section.
- Click on the Add Training Phrases button.
- Type or paste your training phrases in the text box. You can also use the @ symbol to insert predefined system entities or custom entities that you have created. For example, @sys.date, @sys.time, @pizza-size, etc.
- Click on the Done button to save your training phrases.
To add training phrases using the API, you need to follow these steps:
- Prepare a JSON request body that contains the training phrases and other properties of your intent. For example, {“displayName”: “order pizza”, “trainingPhrases”: [{“type”: “EXAMPLE”, “parts”: [{“text”: “I want a large pepperoni pizza”}]}, {“type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium cheese pizza with mushrooms?”}]}, …]}
- Send a PATCH request to the projects.agent.intents endpoint with your agent’s project ID, the intent ID, and the request body. For example, PATCH https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/intents/{intent-id}
- Receive a JSON response that contains the training phrases and other properties of your intent. For example, {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”, “trainingPhrases”: [{“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “I want a large pepperoni pizza”}]}, {“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium cheese pizza with mushrooms?”}]}, …]}
After you have added your training phrases, you can test your intent and see how Dialogflow matches the user’s input to it. You can also see how Dialogflow extracts the entities from the user’s input and assigns them to the parameters of your intent.
To test your intent using the console, you need to follow these steps:
- Click on the Try it now button on the top right corner of the console.
- Type or paste a user input that matches your intent in the text box. For example, “I want a large pepperoni pizza”.
- Press the Enter key or click on the Send button to send your input to Dialogflow.
- Observe the response from Dialogflow in the right panel. You can see the name of the matched intent, the confidence score, the extracted entities, and the assigned parameters.
To test your intent using the API, you need to follow these steps:
- Prepare a JSON request body that contains the user input and other properties of your query. For example, {“queryInput”: {“text”: {“text”: “I want a large pepperoni pizza”, “languageCode”: “en”}}, “queryParams”: {“timeZone”: “America/New_York”}}
- Send a POST request to the projects.agent.sessions.detectIntent endpoint with your agent’s project ID, a session ID, and the request body. For example, POST https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/sessions/{session-id}:detectIntent
- Receive a JSON response that contains the name of the matched intent, the confidence score, the extracted entities, and the assigned parameters. For example, {“responseId”: “response-id”, “queryResult”: {“queryText”: “I want a large pepperoni pizza”, “action”: “order pizza”, “parameters”: {“pizza-size”: “large”, “pizza-type”: “pepperoni”}, “allRequiredParamsPresent”: true, “fulfillmentText”: “Okay, I have a large pepperoni pizza for you. Anything else?”, “intent”: {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”}, “intentDetectionConfidence”: 1.0, …}}
Now you know how to create and manage intents in Dialogflow using the console and the API. In the next section, you will learn how to create and manage entities in Dialogflow.
3.2. Adding Training Phrases
In this section, you will learn how to add training phrases to your intents in Dialogflow using the console and the API. You will also learn how to test your training phrases and how to modify them if needed.
Training phrases are the sample sentences that you provide to Dialogflow to teach it how to identify the user’s intent and extract the relevant entities. You can add as many training phrases as you want, but you should aim for at least 10 to 15 per intent.
To add training phrases using the console, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Training Phrases section.
- Click on the Add Training Phrases button.
- Type or paste your training phrases in the text box. You can also use the @ symbol to insert predefined system entities or custom entities that you have created. For example, @sys.date, @sys.time, @pizza-size, etc.
- Click on the Done button to save your training phrases.
To add training phrases using the API, you need to follow these steps:
- Prepare a JSON request body that contains the training phrases and other properties of your intent. For example, {“displayName”: “order pizza”, “trainingPhrases”: [{“type”: “EXAMPLE”, “parts”: [{“text”: “I want a large pepperoni pizza”}]}, {“type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium cheese pizza with mushrooms?”}]}, …]}
- Send a PATCH request to the projects.agent.intents endpoint with your agent’s project ID, the intent ID, and the request body. For example, PATCH https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/intents/{intent-id}
- Receive a JSON response that contains the training phrases and other properties of your intent. For example, {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”, “trainingPhrases”: [{“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “I want a large pepperoni pizza”}]}, {“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium cheese pizza with mushrooms?”}]}, …]}
After you have added your training phrases, you can test them and see how Dialogflow matches the user’s input to your intent and extracts the entities from the input. You can also see how Dialogflow assigns the entities to the parameters of your intent.
To test your training phrases using the console, you need to follow these steps:
- Click on the Try it now button on the top right corner of the console.
- Type or paste a user input that matches one of your training phrases in the text box. For example, “I want a large pepperoni pizza”.
- Press the Enter key or click on the Send button to send your input to Dialogflow.
- Observe the response from Dialogflow in the right panel. You can see the name of the matched intent, the confidence score, the extracted entities, and the assigned parameters.
To test your training phrases using the API, you need to follow these steps:
- Prepare a JSON request body that contains the user input and other properties of your query. For example, {“queryInput”: {“text”: {“text”: “I want a large pepperoni pizza”, “languageCode”: “en”}}, “queryParams”: {“timeZone”: “America/New_York”}}
- Send a POST request to the projects.agent.sessions.detectIntent endpoint with your agent’s project ID, a session ID, and the request body. For example, POST https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/sessions/{session-id}:detectIntent
- Receive a JSON response that contains the name of the matched intent, the confidence score, the extracted entities, and the assigned parameters. For example, {“responseId”: “response-id”, “queryResult”: {“queryText”: “I want a large pepperoni pizza”, “action”: “order pizza”, “parameters”: {“pizza-size”: “large”, “pizza-type”: “pepperoni”}, “allRequiredParamsPresent”: true, “fulfillmentText”: “Okay, I have a large pepperoni pizza for you. Anything else?”, “intent”: {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”}, “intentDetectionConfidence”: 1.0, …}}
If you are satisfied with the result, you can move on to the next step. If not, you can modify your training phrases and add more or edit the existing ones. You can also delete your training phrases if you don’t need them anymore.
To modify your training phrases using the console, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Training Phrases section.
- Click on the Edit button next to the training phrase that you want to modify.
- Make the changes that you want in the text box. You can also change the entity type or value by selecting the word and choosing the option from the drop-down menu.
- Click on the Done button to save your changes.
To modify your training phrases using the API, you need to follow these steps:
- Prepare a JSON request body that contains the updated training phrases and other properties of your intent. For example, {“displayName”: “order pizza”, “trainingPhrases”: [{“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “I want a large cheese pizza”}]}, {“type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium veggie pizza with olives?”}]}, …]}
- Send a PATCH request to the projects.agent.intents endpoint with your agent’s project ID, the intent ID, and the request body. For example, PATCH https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/intents/{intent-id}
- Receive a JSON response that contains the updated training phrases and other properties of your intent. For example, {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”, “trainingPhrases”: [{“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “I want a large cheese pizza”}]}, {“name”: “projects/{project-id}/agent/intents/{intent-id}/trainingPhrases/{training-phrase-id}”, “type”: “EXAMPLE”, “parts”: [{“text”: “Can I order a medium veggie pizza with olives?”}]}, …]}
To delete your training phrases using the console, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Training Phrases section.
- Click on the Delete button next to the training phrase that you want to delete.
- Confirm your action by clicking on the Delete button in the pop-up window.
To delete your training phrases using the API, you need to follow these steps:
- Prepare a JSON request body that contains an empty array for the training phrases and other properties of your intent. For example, {“displayName”: “order pizza”, “trainingPhrases”: []}
- Send a PATCH request to the projects.agent.intents endpoint with your agent’s project ID, the intent ID, and the request body. For example, PATCH https://dialogflow.googleapis.com/v2/projects/{project-id}/agent/intents/{intent-id}
- Receive a JSON response that contains an empty array for the training phrases and other properties of your intent. For example, {“name”: “projects/{project-id}/agent/intents/{intent-id}”, “displayName”: “order pizza”, “trainingPhrases”: []}
Now you know how to add and manage training phrases in Dialogflow using the console and the API. In the next section, you will learn how to define parameters and how to use them in your responses and fulfillment.
3.3. Defining Parameters
In this section, you will learn how to define parameters for your intents in Dialogflow and how to use them in your responses and fulfillment. You will also learn how to set the parameter types, values, and prompts.
Parameters are the variables that store the values of the entities that are extracted from the user’s input. For example, if the user says “I want a large pepperoni pizza”, the parameter pizza-size will store the value large, and the parameter pizza-type will store the value pepperoni. You can use these parameters to customize your responses and fulfillment according to the user’s preferences.
To define parameters for your intents, you need to follow these steps:
- Select your intent from the Intents tab.
- Scroll down to the Parameters section.
- Click on the Add Parameter button.
- Give your parameter a name that reflects the entity that it stores. For example, pizza-size, pizza-type, delivery-address, etc.
- Select the entity type for your parameter from the drop-down menu. You can choose from the predefined system entities or the custom entities that you have created. For example, @sys.number, @sys.date, @pizza-size, etc.
- Set the value for your parameter using the $ symbol and the name of the parameter. For example, $pizza-size, $pizza-type, $delivery-address, etc.
- Optionally, you can set the following properties for your parameter:
- Required: If you check this box, Dialogflow will prompt the user to provide the value for this parameter if it is not given in the input. For example, if the user says “I want a pizza”, Dialogflow will ask “What size of pizza do you want?”
- Prompts: If you check the Required box, you can enter one or more prompts that Dialogflow will use to ask the user for the parameter value. For example, “What size of pizza do you want?”, “Do you want a small, medium, or large pizza?”
- Is List: If you check this box, Dialogflow will allow the user to provide multiple values for this parameter. For example, if the user says “I want a pizza with cheese and mushrooms”, Dialogflow will store cheese and mushrooms as the values for the parameter toppings.
- Click on the Save button to save your parameter.
Once you have defined your parameters, you can use them in your responses and fulfillment to customize your chatbot’s behavior. You can use the $ symbol and the name of the parameter to insert the parameter value in your response. For example, “Okay, I have a $pizza-size $pizza-type pizza for you. Anything else?”
You can also use the # symbol and the name of the intent and the parameter to access the parameter value from a different intent. For example, if you have an intent called confirm order, you can use #order pizza.pizza-size to get the value of the pizza-size parameter from the order pizza intent.
Additionally, you can use the original or resolved fields to access the original or resolved value of the parameter. For example, if the user says “I want a pizza tomorrow”, Dialogflow will store tomorrow as the original value and 2021-01-21 as the resolved value for the parameter delivery-date. You can use $delivery-date.original or $delivery-date.resolved to access these values.
Now you know how to define and use parameters in Dialogflow. In the next section, you will learn how to create and manage entities.
3.4. Creating Entities
In this section, you will learn how to create entities in Dialogflow and how to use them in your intents and parameters. You will also learn how to set the entity types, values, and synonyms.
Entities are the pieces of information that are relevant to the user’s intents and that your chatbot needs to know to fulfill them. For example, if the user wants to order a pizza, some possible entities are: pizza size, pizza type, toppings, delivery address, etc. Each entity represents a parameter that your chatbot needs to store and use.
To create an entity, you need to follow these steps:
- Go to the Dialogflow console and select your agent.
- Click on the Entities tab on the left sidebar.
- Click on the Create Entity button on the top right corner.
- Give your entity a descriptive name that reflects the parameter that it represents. For example, pizza-size, pizza-type, toppings, etc.
- Click on the Save button to create your entity.
Once you have created your entity, you need to add values and synonyms to it. Values are the possible options that the user can provide for the entity. For example, if your entity is pizza-size, some possible values are: small, medium, large, etc. Synonyms are the alternative ways that the user can refer to the same value. For example, if your value is large, some possible synonyms are: big, huge, extra large, etc.
To add values and synonyms, you need to follow these steps:
- Select your entity from the Entities tab.
- Scroll down to the Entity Values section.
- Click on the Add Value button.
- Type or paste your value in the Value column. For example, small, medium, large, etc.
- Type or paste your synonyms in the Synonyms column. You can add as many synonyms as you want, separated by commas. For example, big, huge, extra large, etc.
- Click on the Save button to save your values and synonyms.
After you have added your values and synonyms, you can use your entity in your intents and parameters. You can use the @ symbol and the name of the entity to insert it in your training phrases or parameter types. For example, @pizza-size, @pizza-type, @toppings, etc.
Dialogflow will automatically recognize the values and synonyms of your entity from the user’s input and assign them to the corresponding parameters. For example, if the user says “I want a big cheese pizza”, Dialogflow will assign the value large to the parameter pizza-size and the value cheese to the parameter pizza-type.
You can also use the original or resolved fields to access the original or resolved value of the entity. For example, if the user says “I want a big cheese pizza”, Dialogflow will store big as the original value and large as the resolved value for the entity pizza-size. You can use @pizza-size.original or @pizza-size.resolved to access these values.
Now you know how to create and use entities in Dialogflow. In the next section, you will learn how to edit and delete intents and entities.
3.5. Editing and Deleting Intents and Entities
In this section, you will learn how to edit and delete intents and entities in Dialogflow. You will also learn how to use the bulk edit and delete features to save time and effort.
Editing and deleting intents and entities are simple and straightforward tasks in Dialogflow. You can edit or delete any intent or entity that you have created or imported in your agent. You can also edit or delete the predefined system intents and entities that Dialogflow provides by default.
To edit an intent or an entity, you need to follow these steps:
- Select the intent or the entity that you want to edit from the Intents or Entities tab.
- Make the changes that you want in the name, training phrases, parameters, responses, fulfillment, values, synonyms, or any other property of the intent or the entity.
- Click on the Save button to update the intent or the entity.
To delete an intent or an entity, you need to follow these steps:
- Select the intent or the entity that you want to delete from the Intents or Entities tab.
- Click on the Delete button on the top right corner of the console.
- Confirm your action by clicking on the Delete button in the pop-up window.
Editing and deleting intents and entities one by one can be tedious and time-consuming, especially if you have a large number of them. To make your life easier, Dialogflow offers the bulk edit and delete features that allow you to edit or delete multiple intents or entities at once.
To use the bulk edit feature, you need to follow these steps:
- Go to the Intents or Entities tab and select the Bulk Edit button on the top right corner of the console.
- Select the intents or entities that you want to edit by checking the boxes next to their names.
- Click on the Edit button on the top right corner of the console.
- Make the changes that you want in the name, training phrases, parameters, responses, fulfillment, values, synonyms, or any other property of the intents or entities.
- Click on the Save button to update the intents or entities.
To use the bulk delete feature, you need to follow these steps:
- Go to the Intents or Entities tab and select the Bulk Delete button on the top right corner of the console.
- Select the intents or entities that you want to delete by checking the boxes next to their names.
- Click on the Delete button on the top right corner of the console.
- Confirm your action by clicking on the Delete button in the pop-up window.
Now you know how to edit and delete intents and entities in Dialogflow. In the next section, you will learn some best practices for designing intents and entities.
4. Best Practices for Designing Intents and Entities
In this section, you will learn some best practices for designing intents and entities in Dialogflow. These best practices will help you create more effective and user-friendly chatbots that can handle a variety of user inputs and scenarios.
Here are some of the best practices that you should follow when designing intents and entities:
- Use descriptive and consistent names for your intents and entities. This will help you organize your agent and make it easier to understand and maintain. For example, use order pizza, cancel order, track order, etc. for your intents, and pizza-size, pizza-type, toppings, delivery-address, etc. for your entities.
- Use the right entity type for your parameters. This will help Dialogflow recognize and validate the user’s input and provide more accurate responses and fulfillment. For example, use @sys.number for numerical values, @sys.date for dates, @sys.time for times, etc. You can also create your own custom entities for specific parameters, such as @pizza-size, @pizza-type, etc.
- Provide enough and diverse training phrases for your intents. This will help Dialogflow learn how to match the user’s input to the correct intent and extract the relevant entities. For example, provide at least 10 to 15 training phrases per intent, and use different ways of expressing the same intent, such as “I want a large pepperoni pizza”, “Can I order a big pizza with pepperoni?”, “Please deliver a huge pizza with pepperoni to my address”, etc.
- Use synonyms for your entity values. This will help Dialogflow handle variations and synonyms of the same value and provide more natural and flexible responses. For example, use small, little, tiny, etc. as synonyms for the value small in the entity pizza-size.
- Use the required and is list properties for your parameters. This will help Dialogflow prompt the user to provide the missing or multiple values for your parameters and ensure that your chatbot has all the information it needs to fulfill the user’s intent. For example, use the required property for the parameters pizza-size and pizza-type, and use the is list property for the parameter toppings.
- Use the original and resolved fields for your entities. This will help you access the original or resolved value of the entity and use it in your responses and fulfillment. For example, use the original field to repeat the user’s input and use the resolved field to perform calculations or validations.
By following these best practices, you can design intents and entities that can handle natural language and provide relevant responses to your users. In the next and final section, you will learn how to conclude your blog and provide a summary of the main points.
5. Conclusion
You have reached the end of this blog on building chatbots with Dialogflow. In this blog, you have learned how to use intents and entities to define the user’s intentions and the relevant information for your chatbot. You have also learned how to create and manage intents and entities in Dialogflow, and how to use parameters, values, synonyms, original and resolved fields, and the bulk edit and delete features. Finally, you have learned some best practices for designing intents and entities that can handle natural language and provide relevant responses to your users.
By following this blog, you have gained a solid understanding of the core concepts and features of Dialogflow that enable you to create conversational agents that can understand natural language and provide meaningful responses to your users. You have also acquired the skills and knowledge to design and build your own chatbots with Dialogflow using intents and entities.
We hope that you have enjoyed this blog and found it useful and informative. If you have any questions, feedback, or suggestions, please feel free to leave a comment below. We would love to hear from you and help you with your chatbot projects.
Thank you for reading this blog and happy chatbot building!