In our Dialogflow tutorial, we are going to discuss the following topics-
What is Dialogflow
Dialogflow is defined as a Google service which operates on a Google Cloud Platform. The Dialogflow is an intuitive and user-friendly tool that includes some Google products such as Google Cloud Speech-to-Text and Google's machine learning expertise. It is mainly used to build actions for most of the Google Assistant devices.
In other words, Dialogflow is defined as an NLP (Natural Language Processing) platform, which is used to develop an application related to the conversations and experience for the customers of the company in different languages on numerous platforms. By using Google-powered, products developers can design text-based and voice-conversation interfaces in order to answer the queries of customers in various languages. For example - various companies use Dialogflow to make messaging bots that reply to the queries of the customers on different platforms such as Google Assistant, Slack, Facebook Messenger, Alexa Voice Search (AVS), etc.
Features of the Dialogflow
There are various features of the Dialogflow:
Develop Serverless Apps Easy
There is a unified code editor offered by the Google Dialogflow through which we can easily develop natively serverless apps which are connected to our conversational interface via firebase cloud functions.
Deliver Automated Phone Service
With the help of the Dialogflow phone gateway, within a minute we can easily add the dedicated phone number into our Dialogflow agent and the users who call the agent with the new phone number will contact your Dialogflow agent directly. The Phone Gateway is based on the cost invested by Google in various things such as speech recognition, phone connectivity, speech synthesis, natural language processing, etc.
Designed for a Voice-First World
With a single API request, we are able to extend our conversational interface to identify voice communications and produce a voice reply. Dialogflow supports synchronous modes and real-time streaming, which are powered by the Google Cloud Text-to-speech and Cloud Text-to-Speech.
Reply on Automatic Spelling Correction
In the chat environments, most of the users interact in a hurry, and sometime there may be situations where the users do not emphasize on accurate spelling or grammar in their chats. So, in that situation, there is a feature provided by the Dialogflow named automatic spelling correction that helps to automatically spell correction mistakes with the help of the technology used by Google for search.
Improve Experience with Built-in Analytics
In the Dialogflow, the integrated analytics dashboard provides you with a vision for conversational communication. Thus, you can customize your bot to better understanding and reply to the user intentions.
Understand User Sentiment
For the query of each user, Dialogflow performs sentiment analysis, which is powered by the Cloud Natural Language. The score of sentiment analysis is used to distribute the unfulfilled users to the live agents or to gain a well knowledge about which attempts lead to the highest client feeling.
Deploy Across Platforms and Languages
It supports more than 20 languages with 14 different platforms.
Bring your Enterprise Knowledge
With the help of the Dialogflow knowledge connectors, we can easily augment data in bulk from the enterprise to the agent that contains articles based on knowledge and FAQs. To extract the correct answer from the data corpus, the knowledge connectors of the Dialogflow use those technologies used by the Google Assistant and Google Search.
Powered by Google Machine Learning
The Dialogflow tool is powered by Google Machine learning. In the Dialogflow, the understanding of the natural language identify the intent of the users and helps to extract those entities which are prebuilt like a number, date, and time. By offering a small dataset, we can also train the agent to easily recognize the customer entity types.
Use Cases of Dialogflow
There are various use cases of Dialogflow:
1. Commerce: - The Dialogflow is used in business. By using Dialogflow, at any time, transactions can be possible with the users on any platform which the user prefers. If you want to purchase goods or schedule deliveries from your users, the Dialogflow provides the facility of self-service experience to those users who need rich and personalized replies.
2. Enterprise Productivity: - We can use Dialogflow for enterprise productivity. By using conversational skills inside the workplace apps makes it convenient for workers to access essential information related to the business and increase productivity, for example: offer sales with knowledge associated with the local opportunities.
3. IoT Devices: - The Dialogflow is also used in IoT devices. With the help of the conversational interface, we can make our IoT devices smarter. The Dialogflow adds an intelligent layer to the smart devices and allow devices to understand and respond precisely to the context of a user's interactions.
4. Customer Service: - With the help of the Dialogflow, we can create conversational interfaces that are able to perform different tasks such as scheduling appointments, replies general queries, following up on previous orders, etc.
Advantages of Dialogflow
There are various advantages of the Dialogflow:
1. Sentiment Analysis: - The Dialogflow can perform sentiment analysis for the queries of the user.
2. User-Friendly: - The Dialogflow is a user-friendly tool, and built with a serverless application structure and an integrated code editor.
3. Incorporates Google feature: - The Dialogflow includes various features of Google, such as speech-to-text and machine learning.
4. Swift and More Efficient Coding: - By simplifying the coding process, the Dialogflow helps us to save the time of the developers. The developers can efficiently perform all the tasks related to the coding because the system contains a built-in, inline code editor. By using this, their agents can be linked via Cloud functions or on-premise to their application.
5. Can Express itself via Natural Conversation: - With the help of Dialogflow, we can create a chatbot. And the chatbots can make a conversation in a natural manner. It simply means that although the customers speak to an application program or a computer, generally to ask for help or assistance, they will obtain in-context replies. When you communicate in a chatbot, then you will not feel like you are talking with a robotic or mechanical.
6. Powered by Google's Machine Learning: - In Dialogflow, the machine learning technology is used and it increase the Dialogflow's capabilities.
Why choose Dialogflow
There are various reasons for choosing Dialogflow:
1. Multi-channel Easy Integration: - The Dialogflow offers you single-click integrations to various types of the most popular messaging applications such as Twitter, Skype, Kik, Viber, Facebook Messenger, Telegram, Slack, Twilio, and also for several voice assistants such as Microsoft Cortana, Amazon Alexa, and Google Assistant.
2. Price: - The free edition of Dialogflow is also available if you only learn how to create a chatbot.
3. Natural Language Processing: - The Dialogflow uses the concept of NLP (Natural Language Processing), so the Dialogflow offers a good user experience. The agents of Dialogflow are better at NLP.
Basics of Dialogflow
Before using Dialogflow, there are various things which you should know about the Dialogflow.
Helps Users Interact with Technology
The traditional computer system needs predictable and structured input to perform function appropriately, and sometimes it makes the use of interfaces difficult and unnatural. Sometimes there may be situation where the end-users cannot grasp this structure input, and, in that situation, the end-users are having a tough time finding out what to do. Ideally, the interfaces are able to infer exactly what the end-user wants, based on the natural language end-users use.
For Example: suppose the request of the user is "How's the weather today"? the other users can also ask:
As you know, conversational experiences are challenging to implement for these simple questions. The natural language processing and interpreting need a parser of very robust language. Dialogflow provides you this type of parser so that you can offer a good quality conversational experience to the end-users.
The Dialogflow agent is defined as a virtual agent whose task is to manage the end -user conversations. An agent is a module that can understand the complexities of the human language. During a conversation, the Dialogflow converts the text of end-user or audio into the structured data so that your applications can understand this. The Dialogflow agent is designed to manage the kinds of conversation your system needs.
The Dialogflow agent is the same as an agent in a human call center. Both are trained to handle the conversation scenario and don't need to be over explicit in their training,
An intent classifies the intention of an end-user for one conversation turn. For every agent, we have to define various users, and our combined agent is capable of handling an entire conversation. At the time, when the end-user says or writes something which is denoted as end-user expression, then the Dialogflow check and matches the end-user expression to your agent's best intent. Intent matching is also called Intent Classification.
For example: If you need to make an agent for the weather, which has the capability to identify and respond to the queries of the end-users related to the weather. Then you have to define an intent for the weather forecasting questions. When an end-user asks, "what is the forecast?" then the Dialogflow check and match the end-user expression to the intent of the forecast. If we want to obtain the essential information from the end-user expression such as location, time for the weather forecast according to our desire, then we have to define our intent. The obtained information is essential to the system for performing the queries related to the system.
The following things are comprised in the basic intent:
1. Training Phrases: - Training phrases means an example phrases for what the end-users can say. If one of these phrases resembles an end-user expression, then the Dialogflow matches the intent. There is no need to define each possible example as the built-in machine learning of Dialogflow expands with other related phrases on your list.
2. Action: - For the agent, we can define an action. At the time, when we match an intent, then the Dialogflow gives the actions to the system, and the action can be used to trigger various actions that are already defined in the system.
3. Parameters: - At run time, if we want to march an intent then as a parameter the Dialogflow gives the value from the expressions of the end-user. Every parameter contains a type known as an entity type, and the entity type exactly dictates how data is retrieved. The parameters are not like raw input of end-user. Parameter means structured data, which is used to perform logic or produce responses.
4. Responses: - We can define speech, visual, or text replies to return to the end-user. These are able to give the answer to the end-user and also ask for more information to the end-user and can also terminate the conversation.
The below figure shows the basic flow for intent matching and responding to the end-user.
There is a type of every intent parameter, which is known as an Entity type. The task performed by the end-user is to explain how data can be extracted from the end-user expression. The Dialogflow offers you a various system entity which are predefined, which is able to match various types of common data. For example, there are various types of system entities for matching email addresses, colors, time, date, etc. For matching custom data, we can also make our custom entities. For example: we can define a fruit entity that matches the kinds of the fruits which are available to buy with the agent of a grocery store.
Dialogflow Console is defined as a web user interface which is provided by the Dialogflow. The Dialogflow console is used to build, test, and create agents. The Dialogflow console and Google Cloud Platform Console are different from each other. The main task of the Dialogflow is to control the Dialogflow agents, and the main task of the Google Cloud Platform Console (GCP) is to handle the settings of the Google Cloud Platform (GCP) Dialogflow such as billing and some other resources of the Google Cloud Platform (GCP).
With the help of Dialogflow Console, we can also create an agent.
The context of Dialogflow is the same as a natural language context. When a person tells you, "they are blue," you have to grasp the context to know which they are referring to. In the same way, for Dialogflow, in order to handle an end-user expression, the Dialogflow context must be provided to match an intent appropriately.
To handle the flow of the conversation, contexts are used. By setting input and output contexts, that are recognized by the string names, we can configure the contexts for the intents. If the intent is matched, then for that intent, any configured output context will be active. When the contexts are in the active state then the Dialogflow try to match intent configured to the input contexts which is corresponding to the contexts which are presently active.
The below figure shows an example which uses context for the banking agent:
The Follow-up Intents can be used to create contexts automatically for the pairs of intents. A follow-up intent means a child of the intent of its associated parent. When the follow-up intent is created, then automatically an output context will be added to the parent intent, and in the follow-up intent, the input context having a similar name will be added. A follow-up intent is matched only in one situation, and the situation is, if the parent intent is in the turn of previous conversational. Multiple levels nested follow-up intents can also be created in the Dialogflow.
In the Dialogflow, there are various types of predefined follow-up intents for the replies of the common end-user such as cancel, yes, no, etc. To manage the responses of the customer, we can also create our own follow-up intent.
User Interactions with Integrations
There are various types of conversation platforms on which the Dialogflow can integrate, such as Facebook, Slack, Google Assistant, etc. To create an agent for any platforms, you can use one of the options from the various integrations' options. In the Dialogflow, there is a facility of handling direct end-user interactions so that your more focus is to create an agent.
User Interactions with the API
If any of the integration options you are not using, then you have to write a code that can interact with the end-user directly. For each conversational turn, you have to interact with the API of Dialogflow directly so that you can send the expression of end-user and obtain intent matches.
The below figure shows how the processing flows when interacting with the API.
Fulfillment for Integrations
By default, the agent will react with a static response to a matched intent. You can get a more dynamic response with the help of fulfillment, if you use one of the integration options. For an intent when the fulfillment is enabled, then the Dialogflow answer to the intent by calling that service, which you define. For example: If the end-user wishes to schedule a shopping on Monday, then your service will search your database and provide the response to the end-user with details on the availability for Monday.
To enable fulfillment, every intent contains a setting option. When intent need a dynamic response or an action by your system, then for the intent, you have to enable the fulfillment. If without enabling the fulfillment, an intent is matched, it means the Dialogflow uses the static response that you defined for the intent.
If, with the fulfillment enabled, an intent is matched, then the request is sent by the Dialogflow with the information regarding the matched intent. Your system is able to perform any action which is needed and also provide a response to the Dialogflow with information to proceed.
The below figure shows the processing flow for fulfillment:
Components of the Dialogflow
There are various components of the Dialogflow:
1. Entity: - Entity is defined as a knowledge repository that is used by the agent to answer the questions of the user. There are various types of system entities, such as weather, location, date, etc.
2. Invocation: - Invocation is like saying hello to a friend.
3. Fulfillment Request: - The Dialogflow send a request to retrieve the necessary data, (sent to webhook) the webhook performs the task like determine how to respond and how to send back to the Dialogflow.
4. Intents: - Intents comprises logic and elements to parse the information of the user. It helps to map what the users are saying with the responses. There are various components in the intent, such as events, response, the user says, contexts, and action.
5. Response: - The backend system will produce a set of responses, including user calls, webhook, intentions, entities, etc.
6. Context: - The context is used to store the values of the parameter for several kinds of intent. With the help of the context, the broken conversation can also be repaired.
7. User Says: - User says means there are various forms of the same question that can be asked by the user. We can add more variations so that the agent can understand in a better way.
How to Create Your First Dialogflow Agent
There are various steps to create your first Dialogflow agent:
1. First, we have to log in to the Dialogflow. We can log in to the Dialogflow by using the link https://dialogflow.com/. After login successfully, we have to click on the Sign up for free.
Then we have to connect with the Google account. If you want to use a Dialogflow, then it is must that you have a Google account.
2. Next, we have to click on the create agent to create a new agent. For this, first select the three things: language, the default time zone, and the name for your new bot.
3. Then, create the bot say hello. The bot currently doesn't know how to respond to the user input. The journey to teaching it how to behave is just beginning. First, you have to model the personality of the bot a bit and answer hello to him/her and then present yourself.
4. Click on the option named Default Welcome Intent.
5. Next, we have to add 'hello' and 'hi' to training phases, and these will be in the text form and then click on the enter button.
6. Next, we have to go down on the option named Responses and remove or delete the existing ones.
7. Then, click on the ADD RESPONSES, and then we have to click on the Text response Then type the response which you want.
8. When you text the response appropriately, then you have to save the response by clicking on the Save button.
How to Import the Example File to your Agent
There are various steps to import the example file to your agent:
1. First, you have to download the new-agent.zip file.
2. Then go to the Dialogflow Console.
3. Then, choose an agent.
4. Next, click on the setting icon, which is present next to the agent name.
5. Then, choose the Export and Import
6. Last, select the option named Restore from Zip and then to restore the file which you downloaded, you have to follow some instructions on each step.
How to create a New Intent
In this section, we create an agent which is capable of answering the question such as "what is your name". for every intent we have to define various training phrases. A training phrases is also known as end-user expression. It is an example of what the possible questions the end-user can say or type to the agent. We can define any number of training phrases which offer Dialogflow, a different type of expressions which must match the intent.
There are following steps to create a new intent:
1. First, we have to click on the add intent + button on the left sidebar menu next to the intents.
2. Next, click on the get-agent-name, which is present in the Intent name
3. Then, click on the option named Add training phrases, which is present in the Training Phrases
4. Next, we enter the training phrases according to the requirement of the Intent. Then we have to click enter after every entry.
Note: In most of the cases, it is must that we have to enter at least 10-20 training phrases so that the intent matching is reliable.
5. Then, in the Response section, we have to enter the response, such as "My name is ABC" in the Text Response section.
6. Click on the Save button.
7. Then, we have to wait till the dialog of the Agent Training indicates that training is complete.
Type what is your name into the simulator? Click Enter.
Your agent gives correct responses to the expression, no matter if the expression may be a little bit dissimilar from the training phrases that you supplied.
For a machine learning model, the Dialogflow uses training phrases like an example, to match the expression of the end-user to the intents. Against each intent, in the agent, the model tests the expressions and then provides a score to each intent, and then the intent which contains the highest score is matched.
When the intent having the highest-scoring has a very less score, then the fallback intent is matched.
How to Create Parameters in Dialogflow
Whenever at runtime, the intent is matched, then as a parameter, the Dialogflow gives the values extracted from the end-user expression. And every parameter has a type which is known as an entity type. Type of entity dictates exactly how data is extracted.
There are following steps to create a parameter:
(create a new intent with parameters)
1. First, we have to click on the add intent + button on the left sidebar menu next to the intents.
2. Then, we have to give the name to the intent, and the name is as set-language, which appears at the top side of the intent form.
3. Now, we have to add the following training phrases:
4. Now, we click on the Save button, and then we have to wait for the Agent Training dialog indicating that Agent training completed.
Automatically, in the training phrases, the Dialogflow recognizes parameters which are known as system entities. These are the entities which the Dialogflow gives for various common data types like date, color, and location.
Note: We can annotate our training phrases manually if our training phrases are not annotated automatically.
In the Action and parameters table, the Dialogflow creates a row, which is present below the Training phrases.
Note: We can also manually annotate the entity in the training phrases if it is not detected automatically.
Test your Parameter
If you want to test your parameter then first you have to type 'I Know French' and then press enter.
We can easily find that the Dialog extracts the language parameter appropriately with the value Spanish and Spanish is appropriately inserted where the reference of the parameter was used in the response.
How to create your own Entities
Dialogflow provides you the facility to create your entities because there may be situations when you want to gather specific data from the users, which is not given by the system entities. So, to handle this, you can create a custom entity.
There are various steps to create your own entity:
1. First, you have to click on the button add entity +, on the left sidebar menu to the Entities
2. Then for the entity name, you have to enter language-programming.
3. Now, add the below entity entries:
4. Then, click on the Save button, and then wait till the Agent Training dialog indicates that Agent training completed.
The Dialogflow can easily handle a few things such as capitalization and plurality, but for the entries, you have to add all the possible synonyms. If you add more synonyms, then the agent can quickly determine the entities.
How to Use your New Entity
If you want to make the use of the new entity, then you have to add the training phrases to the set-language.
There are various steps to use your new entity:
1. irst, click on the option named 'Intents', which is present on the left sidebar menu.
2. Then, click on the intent set-language.
3. Next, you have to add the various training phrases:
4. Note that the programming language in these training phrases are annotated automatically and added to the section of Action and Parameters.
5. Next, you have to add another test response, which is $language-programming is a better programming language.
6. Then, click on the Save button, and then you have to wait till the Agent Training dialog indicates that Agent training completed.
Test your New Entity
If you want to test your new entity, then type I know how to code in py and press enter. We can easily see that the Dialogflow extracted the py from the parameter language-programming and recognized py as Python entity, and then in the response, value is inserted.
We can use contexts to manage the flow of conversations.
How to Add a Follow-up Intent
The follow-up intent is used to handle the conversation. In this to handle a conversation, there is no need for manual creation of the contexts.
When the follow-up intent is created, automatically, an output context will be added to the parent intent. In the follow-up intent, the input context having a similar name will be added. Only in one situation, a follow-up intent will be matched, and the situation is if the parent intent in the previous conversational turn is matched.
There are various steps to add a follow-up intent to the set-language intent:
1. First, choose the intent Set-language that is created previously.
2. Then, we have to update the test response in the Response
Wow! Just wow! I did not know that you knew the $language.
3. Then, click on the Save button, and then wait till the Agent Training dialog indicates that Agent training completed.
4. Now, click on the Intents option, which is on the left side of the sidebar menu.
5. Hover the mouse over the intent named set-language and then click on the Add follow-up intent.
6. Then, in the revealed list, click on the Custom
7. Last, click on the Save button, and then wait till the Agent Training dialog indicates that Agent training completed.
Automatically the Dialogflow gives the name to the follow-up intent, and the named is set-language-custom.
How to customize the Default Welcome Intent
If you want to customize the default welcome intent, there are few things which you have to keep in mind regarding your greeting, and the things are set expectations, let the user take control, and welcome the user.
There are various steps to customize the default welcome intent:
1. First, click on the Default Welcome Intent.
2. Next, navigate to the Responses section.
3. Now, remove all the default responses in the Text response.
4. Then, in the Test Response, type the response such as "Welcome. I can tell you the hours of the shop, or I can arrange an appointment. What one you want?". Click on the Save button.
5. Now, test the customize default welcome intent with the help of the simulator.
How to Create Response Variants
After creating a phrase of a new greeting, next step is to create some other variations. There are various variations responses which we include in the Default Welcome Intent:
If you add many responses for the intent, then the Dialogflow chooses one of the responses from the list in a random way.
How to Create a Custom Intent
Here let's take an agent of the car shop, and we want to perform two tasks from the car shop agent:
Now first, we build an intent for the customers, which helps the users to notify regarding the operation hour's for the car shop.
We can do this by writing a very Dialogflow sample as described below:
User: On what time you will be open.
Agent: We are available daily from 10 AM to 8 PM. Is there anything else that I should do for you?
We have to perform the following steps to make the intent which is able to handle this Dialogflow:
1. First, we have to create a new intent and give a name to the new intent as Hours.
2. Now, we enter the various training phrases in the hours intent training phrases section. On what time you will be open.
3. Next, in the Response section, we have to type the response in the table of the Text response: We are available daily from 10 AM to 8 PM. Is there anything else that I should do for you?
4. Then, we have to click on the Save button.
Add more Training Phrases
Previously, we added only one training phrase to the Hour's intent. That is "on what time you will be open,". This intent contains no sufficient or enough knowledge that can be helpful to recognize the other same words which have a similar meaning. So, we have to give more training phrases to the intent so that the agent can match different types of user words that can express a similar intention.
There are so many ways of forming the phrase in natural language having same meaning. We suggest that each intent starts with at least 10-20 training phrases, depending on the intent complexity. When we begin testing an agent, then using the training tool of Dialogflow, add more training phrases.
With the training phrase "On what time you will be open?", we can add various variations that user can say instead:
The following steps are performed to add these above variations:
1. First, click on the intent, which we have created already as Hours.
2. Then enter the above mention phrases in the Training phrases
3. Now, click on the Save
4. Then, we test the intent with the help of the simulator in the Dialogflow console.
How to Customize the Fallback Intent
In the Dialogflow, there is a Fallback Intent, which is matched when the utterance of the user did not matched with another intent. As the Default Welcome Intent, the name of the fallback intent name is Default Fallback Intent.
A Fallback intent is the one that prompts the users whose utterances are formed in such a way that the agent can understand it easily.
There are various steps to customize the fallback intent:
1. First, we have to click on the Default Fallback Intent.
2. Then, go to the Responses
3. Now, delete all the default responses which are present in the Test response section.
4. Next, we have to add the following training phrase in the Text response section:
5. Click on the Save button.
Create an Intent with Parameters
Now we will build an intent which is able to schedule an appointment for the shop of the car. It is not like that intent, which we created previously. This intent can help to perform more complex tasks.
Let's discuss the user-agent interaction that follows:
Agent: Welcome. I would tell you the hours of the shop, or I can make an appointment. What one you like?
User: I want to schedule an appointment at 5 PM today.
Agent: Ok, I schedule your appointment on Monday, July 1, at 5 PM. Good-bye.
The user utterance in the Dialogflow that is "I want to schedule an appointment at 5 PM today" comprises of some essential information, which is '5 PM' and 'today'. It helps to identify at which day and time the user needs to visit the shop of the bike. The response of the agent comprises of the information regarding the date and time mentioned in the utterance of the user, which is "Ok, I schedule your appointment on Monday, July 1 at 5 PM. Good-bye."
To identify the essential information is very easy for the human, but for the machine, it's not an easy task. So, we have to provide the capability to the intent to extract the essential information, parameters from the utterance of the user.
Extract Information using Entities and Parameters
In a Dialogflow, there is a concept of entities and parameters. Entities and parameters are used for information extraction from the utterances of the user and then transform the extracted information into a set of parameters, and then it can be processed by systems or functions to perform several tasks.
There are various steps to create a new intent with the parameters:
1. First, we create a new intent, and to create a new intent, click on the create intent option and provide a name to the intent as Make Appointment.
2. Then, add the following training phrases in the Training phrases section:
3. Next, we verify that the entities of the system, which are @sys.time and @sys.date, have appeared in the Action and Parameters
4. Then, we add the following response phrase in the Test response section:
5. Then, click on the Save
By using this setup, the Make Appointment intent verifies the user statements, captures words that are mapped to the built-in system entities of the Dialogflow, which are @sys.time and @sys.date. Then, places all the captured values in the $date and $time parameters. Thus, we use $time and $date system entities in the response to the values of time and date obtained from the user statement or utterances. "Ok, I schedule your appointment on Monday, July 1, at 5 PM. Good-bye."
In the Dialogflow, we can also create custom entities to extract uncategorized or uncommon parameters. In our case, however, the system entities are enough to capture the usual parameters like date and time.
Obtain Required Parameters using Slot-Filling
In addition to the current training phrases, now we are require to include some more training phrases, following the best practices from the previous section, which is "I want to schedule an appointment at 5 PM today".
Now we add the various training phrases:
Till now, every training phrase includes information such as date and time, which are 6 PM tomorrow, 5 PM today, noon on Monday. But in the real world, it is not must that the user utterances always contain all the needed parameters.
Now add the below training phrases:
The phrases which we used above indicate that the user needs to make an appointment or schedule an appointment. So, the new intent is able to match with such phrases to manage the job of appointment scheduling. However, the information regarding time and date are not included in the phrases. These types of phrases create problems because, without the information of time and date the intent cannot make an appointment.
So, to solve this problem, the Dialogflow offers a feature of Slot-filling, which ensures that the user gets all the required information from the user. If we want to enable the feature of slot-filling, then we have to mark the required parameters.
Suppose an intent contains necessary parameters, but it coincides with the utterance of the user, which lacks any needed parameters. In that case, the intent immediately queries the user to get all the parameters which are needed.
Let's have a look at the following:
Agent: Welcome. I can tell you the hours of the shop, or I can make an appointment. What one you like?
User: I want to fix my car.
Agent: Alright, I will help you with this. What day would you like to come?
Agent: And what time does it work for you?
User: 5 PM
Agent: OK, I got it. I've scheduled your appointment for Monday, July 14, at 5 PM. See you early. Bye-Bye.
We have to follow the following steps to make the $time and $date parameters available and include prompt questions about the parameters:
1. First, we have to click on the intent named Make Appointment.
2. Then we check the required boxes for the parameters, which are $time and $date in the Actions and Parameters Then, a column is created named PROMPTS.
3. Next, we check that if the parameter $date is located in the table below the parameter $time, then we drag the $date parameter row which is above the parameter $time. (The order in which the prompt questions are asked is decided by the placement in the table.)
5. For parameter $date, we have to click on the link named Define prompts that is present in the PROMPTS column, and then we add the prompts which are mentioned below:
5. Then, for parameter $time, we have to click on the link named Define prompt present in the PROMPTS column, and then we add the prompt which is mentioned below:
6. Click on the Save button.
7. Now, with the help of the simulator, we test the setup of the slot-filling in the Dialogflow console.
Now we have an intent to ensure that the date and time information is retrieved until a user states that they need to make an appointment.
However, currently, the intent can only respond to the mock-up response; the actual appointment cannot be scheduled. Now there is a need to make a backend process fulfillment, which is able to perform the job of appointment scheduling on Google Calendar.
Knowledgebase in Dialogflow
In the Dialogflow, there is a concept of the knowledgebase. We can define a knowledgebase as a set of knowledge document that we offer to the Dialogflow. The knowledge document comprises the information, which can be useful in the end-user's conversations. Few of the features of Dialogflow use the concept of knowledge bases when searching for the end-user expression response.
How to Create a Knowledge Base
There are various steps to create a knowledge base:
1. First, go to the Dialog Console.
2. Then choose the agent.
3. Now, click on the option named knowledge, which is present on the left side of the menu bar.
4. Next, click on the Create Knowledge Base
5. Then enter the name of the Knowledge base and then click on the Save button.
How to Add the Document to the Knowledge Base
Currently, there is no document contained in the new knowledge base. So, we have to add the document in the knowledge base as per our need.
There are various steps to add the document to the knowledge base:
Manage Knowledge Document
Manage knowledge document contains two essential points.
1. Update Knowledge Document Content: - If you want to update the content of the knowledge document, then you cannot automatically refresh your knowledge document.
You have to call the method named Reload on the Document type to refresh the content of the public URI document or cloud storage.
If you want to refresh upload raw content, rebuild your document using the methods delete and create on the document type.
2. Delete Knowledge Documents: - If you want to delete the knowledge document, then you have to call the method named delete on the Document
3. List Knowledge Documents: - If you want to create a list of all your knowledge document, then on the Document type, use the API and call the method list.
There are various knowledge document types that are supported:
The below table shows the supported MIME types by source and Knowledge Type:
Training in Dialogflow
After training the agent to develop a machine learning model mainly for the agent, the Dialogflow uses the training data. If we want to provide the training data directly, then the Dialogflow offers you the feature of the training phrases by which we can directly enter the training data to the intents. In the Dialogflow, there is a training tool that we can also use to improve, export, and import actual conversation data and to analyze our training data.
How to Execute Training
In the Dialogflow, whenever we save the agent, then automatically, the training is executed. The Dialogflow provides the training status whenever you save your agent, and the status is in the form of a pop-up notification. Before testing the agent, we have to wait until the training completes.
When our agent contains more than 780 intents, or the automatic training status setting is disabled, then we can execute training manually.
There are various steps to execute training:
1. First, go to the Dialogflow Console.
2. Then, select the agent.
3. Now, click on the setting button, which is next to the name of the agent.
4. Then, click on the ML Settings Tab.
5. Click on the Train button which is present on the bottom of the page.
If we want to execute the training by using API, then we have to call the method named train on the agent type.
With the help of the training tool, we can improve the training data. It is used to review conversations with the end-users that your agent had.
With the help of the training tool, we can do the following things:
If you want to use the training tool, then it is must that the logging is enabled because the training tool uses the history of the agent data to load the conversations. The training tool only displays the expressions of the end-user. With the help of the more complete agent history, we can view the conversation data of both agents as well as the end-user.
There are various steps to open the training tool.
When we open the training tool, then it will show you the list of conversations. This list contains all the recent conversations but in the reverse chronological order. In the list, each row gives you a summary of the conversations.
The below table describes each element of the UI.
Intent Matching with Follow-up Intents
The follow-up intent is matched after the parental intentions are matched. So, the intent language-custom is matched only after the set-language intent is matched. Suppose the users just asked the question that how long did you know $language? Now we can add the training phrases to the question for possible user answers:
There are various steps to intent matching with the follow-up intents:
1. First, click on the Intents option, which is present on the left sidebar menu.
2. Then, click on the intent named set-language-custom.
3. Next, add various training phrases:
4. Last, click on the Save button, and wait till the Agent Training dialog indicates that the Agent training completed.
Test your Follow-up Intent
If you want to test your follow-up intent, then, in the simulator, enter, I Know Spanish, and then respond to the question How long did you know Spanish with about 4 weeks.
As we know for the expression about 4 weeks, there is no response, and we can easily see that the expression is matched appropriately to the accurate intent set-language-custom. The parameter for the duration is accurately parsed (4 weeks).
Contexts and Parameters
In the context, the values of the parameter are stored. We can access the parameter values, which are defined in the intent Set-language when the output context of the set language intent is active.
In the set-language-custom, we can only ask one thing, which is the duration of the language that the user knows.
We have to perform the following steps to reference the language in the response:
1. First, update the intent set-language-custom to text the response, and the response is I cannot believe you know #set-language-followup.language for $duration!
2. Then click on the Save button, and then wait till the Agent Training dialog indicates that the Agent training completed.
The #set-language-followup.language reference is called a parameter reference for an active context.
Test the Context Parameter
If you want to test the context parameter, then type I know French in the simulator. Then answer the question as 'one week'. Note that the value of the parameter is received from the context.
Interaction with an Integration
There are various types of conversation platforms on which the Dialogflow can integrate, such as Facebook, Slack, Google Assistant, etc. To create an agent for any platforms, you can use one of the options from the various integration options. In the Dialogflow, there is a facility of handling direct end-user interactions so that your more focus is to create an agent.
How to Enable the Integration
There are various steps to enable integration:
1. First, go to the Dialogflow Console.
2. Then, select an agent.
3. Next, click on the option named Integration present on the left sidebar menu.
4. Then, enable Web Demo integration.
When the web demo enables the dialog, the window offers you the following:
How to Interact with your Agent
If you want to interact with your agent, use the above provided link, open the webpage of the agent. This webpage gives you a text chat interface. You have to type what's your name and then click enter. Then the agent provides the response with the response which you set up in the previous QuickStart.
How to Build Resume Chatbot for Google Assistant
There are various steps to build resume chatbot for Google assistant:
1. Google Signup
First, log in to the Dialogflow. We can log in to the Dialogflow by using the link https://dialogflow.com/. After login successfully, we have to click on the Sign up for free.
Then we have to connect with the Google account. If we want to use a Dialogflow, then it is must that to have a Google account.
2. Agent Creation
If we want to develop a new chatbot in the Dialogflow, then we have to create an agent. To create an agent, first click on the option name 'create agent' then, give a name to our agent, and then we have to select various things such as default time zone and default language as per our need.
3. Create New Intent
Next, we have to create a new intent. We can create a new intent by clicking on the symbol +, which is next to the intents option or by clicking on the button CREATE INTENT, which is present on the top of the Dialogflow window.
Type intent name (Introduction) and click on the Save button.
Then, in the training phrases section, there is a textbox. So, add the user expression in the textbox, and after enter, click on the Save button.
As per the intent, we need to enter the training phrases. We have to decide which type of user input is going to invoke this intent. Such as for the Introduction intent, we added "Introduce Yourself" and "Tell me about yourself'.
Then we go to the responses section. At least one response is required for each intent. So, we have to type the response in the Text response box and then press enter. After enter, the text responses, click on the Save button. Multiple responses can also be added in the responses section. Intent use responses in a random way from the list in which we have entered the responses.
4. Rich Responses
There are different types of responses available in the Dialogflow. We can have each one for different purposes so that our information is shown in a good way. For example: sometimes we may require to display some images, external links, or a list of items. Those cases lead to rich responses.
According to chat platforms such as Google, Telegram, Slack, Facebook Messenger, etc., there are various options available for the rich responses, but all the types are not supported on various chat platforms.
Now we have to click on the symbol +, which is near the default option in the response section, and then from the list choose the Google Assistant option.
Then click on the 'ADD RESPONSES' button, and we can see various kinds of responses.
5. Suggestion Chips in Welcome Intent
Suggestion chips are used as a guide for more conversation. Suggestion chips help to indicate what to do next, such as Introduction, Experience, Projects, contact.
6. Create Introduction Intent
For the introduction intent, we can add various training phrases such as:
There are various types of responses that we can use, such as Simple Response/ Basic Card/ List/ Carousel. But we use Simple Response for this intent.
7. Create Experience Intent
We can add various training phrases for the Experience intent such as:
We can use table card and simple response for the response.
If we want to represent our data in a data form, then table card is used, it also offers static data.
Note: If we want to use a table card response, then it require at least one simple response.
8. Create Projects Intent
For the project intent, we can use various phrases such as:
We can use a Simple Response or Browser Carousel Card for the response.
We can scroll browser carousel card horizontally. We used this card in browser to open selected external links of the website.
9. Create Career Objective Intent
For the career objective intent, we can use various training phrases like:
We can use Suggestion chips/Simple Response for the response.
10. Create an Area of Interest Intent
For the area of interest intent, we can add various training phrases such as:
We can use suggestion chips or simple response for the response.
11. Create Educational Qualification Intent
For the educational qualification intent, we can use the various training phrases such as:
For the response, we have various options such as suggestion chips, simple response, and basic card.
For display images, text description, title, subtitle we can use basic card response.
12. Create Strengths and Weakness Intent
For the strengths and weakness intent, we can use various training phrases such as:
We can use list and simple response for the response. With the help of the list response, we can display various items like a list.
We can see in the below image that in the response we have added the needed values. This mean that if the user clicks on the specific item, the next user input will be the key of that item.
13. Create Contact Intent
For the contact intent, we can use the various training phrases such as:
For the responses, we have different kinds of options such as Text Response/ Simple Response/ Browse Carousel Card.
14. Create References Intent
For the reference intent, we can use training phrases such as:
What are your references
For the response, we can use Basic card, Simple Response, Link out suggestion, and suggestion chips. We have used link out suggestion we want to link the external website URL. Anchor text will be the title of the link.
15. Create Exit Intent
For the exit intent, we can use various training phrases such as:
We can use Text Response/ Simple Response for the response.
We can see in the below figure that for end, the conversation of this intent, we select/ turn on "set this intent as end of conversation: switch/button/option.
If the user enters or type good bye, bye bye or bye then the simple response will be appear. When we make the intent as "End of conversation" then our conversation will end and user exit from the app. Now our resume chatbot has been created.
How to Build an Appointment Scheduler with Dialogflow
There are various steps to build an appointment scheduler with Dialogflow:
1. Create a Dialogflow Agent
If we want to build an appointment scheduler with Dialogflow then first we have to create a Dialogflow agent:
There are various steps to create a Dialogflow Agent:
In the Dialogflow, as a part of the agent, there are two types of default intents:
1. Default Fallback Intent: - It helps to capture those questions which the bot doesn't understand.
2. Default Welcome Intent: - The default welcome intent is matched whenever the end-user starts a conversation with your agent.
Test the Agent
There is a testing panel in the Dialogflow console that is used to test the agent. The testing panel appears on the right side of the Dialogflow console window.
Type "Hi" to test the agent. Then the agent will respond with the default greeting, which is defined in the default welcome intent. It will say, "Greetings! "Hello! How can I help you?" we can update the response.
If we type "set an appointment," then the agent will not be able to give the response to this because the agent does not know what to do and so it provides the response, which is defined in the default fallback intent. Because we have not created any intent that catch this specific question.
2. Create Intent
After creating the agent, we have to create the intent.
There are various steps to create the intent:
(a) First, click on the Intent option which is present on the left side of the Dialogflow window then click on the CREATE INTENT
(b) Then, click on the Training phrases and enter the various phrases:
When we enter the above phrases, we will see that the date and time are automatically recognized as system entities, which are @sys.date and @sys.time.
(c) Next, go to the Responses, and in the text response section, enter "you are all set, see you then! We can also write this in another way, like "You are all set for $date at $time." If we add a dollar($) sign, the system can easily access the entity values and click on the Add Responses.
(e) Then, click on the Save button. Then, we will test the agent.
Now, "set an appointment" will be tested. This is not really clear and you didn't need to deal with the situation. Thus, the default fallback intent handles this, and we can use slot filling for this purpose.
Slot filling enables you to build a parameter-value-collection conversation flow in a single intent. Slot filling is helpful in the situation where without a set of parameter values we cannot complete an action.
There are various steps to setup slot filling:
1. First, click on the 'Action and Parameter' option. Make the needed entities, and ask for the date and time in Dialogflow before answering.
2. For date, we enter or type "what date?"
3. For time, we enter or type "what time would you like to come in?"
4. Then, we click on the 'Save' button.
4. Test your Chatbot
Now our chatbot for appointment scheduler is ready and now we test the chatbot. To test the chatbot, we have to enter the various conversations in the testing panel of the Dialogflow console.
Now we can see in the above screenshot that the chatbot we developed is working correctly.
5. Enable One-Click Web Integration
If we want to share the schedule with others, use the option named one-click we integration. In Dialogflow, there are various types of integration available for the chatbot. Look at a sample chatbot web user interface.
There are various steps to use one-click web integration:
1. In the Dialogflow, click on the
2. Then enable the Web Demo.
3. Next to launch the Web Demo, click on the URL.
After performing the above steps, we are able to use the chat interface. We can use the chat interface by typing something where it says 'Ask Something'.
By using the below conversation, we can begin using the chat interface.
1. Enter "Hi" when you enter "Hi" or something then the chatbot will respond you.
2. Then, enter "set an appointment for 6 PM tomorrow" and then the chatbot will respond.
How to Build a Chatbot for FAQ with Dialogflow
There are various steps to build a chatbot for FAQ with Dialogflow:
Create an Agent
If we want to build a chatbot for FAQ with Dialogflow, create an agent and to create an agent we have to follow the various steps:
Now, we can create the agent by clicking on the Create new agent option, which is on the left sidebar menu.
(b) Next, give the name to the agent. We are building an agent for the FAQ. So, we give the related name to this as FAQ_agent. Click on the 'CREATE' button.
Enable Beta Features and APIs
We enable Beta features and APIs. After enabling the Beta features and APIs, we are able to create a knowledge connector.
Create a Knowledge Base
There are various steps to create a knowledge base:
(a) First, click on the option named "Create Knowledge Base."
(b) Then, give the name to the knowledge base, and then save it by clicking on the 'SAVE' button.
(c) Next, a knowledge document is required, which we will use to auto-generate the chatbot of the FAQ. We use this FAQ as a sample. For this purpose, we can also use our document.
(d) Now, move back further to the Dialogflow agent, and then build our first knowledge connector.
Now, the FAQ chatbot for Facebook is created by the knowledge connector, click on the Facebook FAQ.
We can see that the questions are parsed into the requests and answers.
Now, to enable the automated responses, we have to click on the Add response and then SAVE.
Before start testing our agent, firstly enable the chatbot. To enable the chatbot, click the checkbox next to the FAQ name and press enable.
After creating the knowledge base and adding the FAQ, our next step is to add some variants under the Responses section to check how the chatbot must present the knowledge base's response.
The following responses are added in the responses section:
Test your Chatbot
Now, with the help of the simulator, we can test the chatbot. To test the chatbot, type something in the simulator related to the FAQ. In this example, we created a FAQ chatbot for Facebook. To test the chatbot, we have to type the questions related to the FAQ Facebook chat, such as "Can my app use both standard messaging and message tags to send messages." After typing this question, we will get a response from the bot. Then, we can also try some more examples like "What happens if my bot messages a person more than once beyond the 24-hour standard messaging window". We will notice that the correct intent is still mapped even if we do not type the particular question from the FAQ. That's the specialty of the knowledge connector.