/  Technology   /  Machine learning   /  Building a Chatbot using Google’s DialogFlow
Building a Chatbot using Google's DialogFlow 12 (i2tutorials)

Building a Chatbot using Google’s DialogFlow

A chatbot is an Artificial Intelligence software that can simulate the conversation with User in natural language through mobile apps, websites, messaging applications, telephone. It is the one of the most advanced interactions between humans and machines.

Chatbot is a Question Answering system leveraging Natural Language Processing. It has two main tasks.

1. Analyzing User Request.

2. Processing User Request.

3. Giving Adequate Response.

Chatbot analyses the Users intent and extracts the Entities from the User’s Request. Once the user intent is analyzed, the chatbot has to Process the User Request and give adequate Response to the User.


The first step in creating Chatbot is to create Agent. It is a virtual agent which handles the conversations with the users. It is a Natural Language Understanding module which can differs or variate the Human language. DialogFlow Agent is similar to Human call center Agent, we train them both to handle expected different conversational scenarios, training does not need to be overly explicit.

Agent can support different languages, Exporting and Importing etc.,

Building a Chatbot using Google's DialogFlow 1 (i2tutorials)

For Example:

here I have taken my Agent as Trip Planner. This will help the User to Book Flight Tickets, Book Rooms, Book Car. We have to describe our Bot in the Description, and Define the Default Time Zone.


An Intent categorizes the user’s intentions for one conversation turn. We can create many intents for an agent. A Combination of many intents contribute a complete Conversation. When the user asks or says something, the Agent matches the query to the best matched Intent. Matching an Intent is also known as Intent classification.

Building a Chatbot using Google's DialogFlow 2 (i2tutorials)

In our Trip Planner, bot have to book Flight Tickets, book Rooms, book Car. So, these are required Intents for our Bot. As discussed above many Intents can be created in an Agent Trip Planner. By clicking on Create Intent option, we can create an Intent.

When we create an Intent, Contexts, Events, Training Phrases, Action and Parameters, Responses are created.

Building a Chatbot using Google's DialogFlow 3 (i2tutorials)

Follow up Intents:

Follow up Intents are the additional or child Intents to the Parent Intents. These are nested under the Parent Intent in order to have a smooth conversation with user without questioning the same details of the User again and again. These are designed to handle the preset replies like “yes”, “no”, “cancel” etc.,

We can create the Follow up Intent by clicking the custom option of the Parent Intent. The input of the Follow up Custom is always the Parent Intent. We should give the separate response for the Follow up Intent. It also requires some Training Phrases which are connected to the Parent Intent.

To create Intent Training Phrases, Action and Parameters, Response are required. For a Follow up Intent, Context is also required along with Training Phrases, Action and Parameters, Response. Output Context of the Parent Intent is the Input Context of the Follow up Intent. If the Parent Intent has no Follow up Intent, then the Parent Intent does not require any Input or Output Contexts.

Building a Chatbot using Google's DialogFlow 4 (i2tutorials)

Building a Chatbot using Google's DialogFlow 5 (i2tutorials)

Here, I have taken Book Flights-Room as Follow up Intent. This will help User to give the Information only once. If the User Book Flight Tickets using this Bot, he also wants to book a room, he does not need to give the whole information again and again. This Follow up Intent books room directly.


Contexts are used to refer the parameter values as the User moves between the Intents throughout the conversation.

Training Phrases:

Training Phrases are the Example Phrases which the User may type or say. Within an Intent we are able to define the list of Training Phrases. This list defines Different phrases which can be used by the User in order to trigger the desired Intent. The more Triggering Phrases are defined, the easier User can trigger into the Respective Intent.

Building a Chatbot using Google's DialogFlow 7 (i2tutorials)

I have given 6 training phrases, but for better triggering of Intent, minimum of 10 training phrases which leads to same meaning are required. In the same way different Training Phrases are given to each Intent in the Agent.

Action and Parameters:

When an Intent is matched at runtime, DialogFlow provides the Action value to request. It is used to trigger specific logic in your service.

When an Intent is matched at runtime, DialogFlow provides the Extracted values from the User expression as Parameters. Each Parameter has a type called Entity Type which dictates exactly how the data is extracted from User Request.

Parameters are the structured data that can easily perform logic or generate Responses. When Intent is matched at runtime, DialogFlow provides Parameter data to your request which maps Parameter names to the Parameter Values.

Building a Chatbot using Google's DialogFlow 7 (i2tutorials)

When we define the Entity, the Action and Parameters are displayed with different colors. We have to tick the required Parameter for the Intent as per the Requirement.


Entities are generally keywords which are extracted from the request of the User, such as Name, Location, Date, Time etc., When the User sends the Request, DialogFlow search for the Entities and the value of the given Entity can be used within the request.

DialogFlow has some predefined Entities, whereas we can also create our own Entities as per the User’s Request or Intents. While creating Entities, we can also provide synonyms to the words which makes User to trigger the desired Intent easily.

Building a Chatbot using Google's DialogFlow 8 (i2tutorials)

Here, For Trip Planner Agent, we require different Entities such as Flight Type, Room Type, Car Type which are not default. Entities like City, Date, Time are default ones which need not to be created.


Fulfillment is used to connect the service to the Agent. When the User sends the Request, Bot needs to request the information to fulfill the User’s Request. Fulfillment allows you to take Actions based on the User’s expressions and send the dynamic responses back to the User.

Each Intent has setting to enable Fulfillment. When an Intent with Fulfillment enabled is matched, DialogFlow sends the request to the Webhook service with the information about the matches Intent. Service sends the Webhook response to the DialogFlow which contains the response that should be sent to the User. Webhook response may or may not be same as the response mentioned in the Intent.


DialogFlow integrates with many conversation platforms such as Facebook Messenger, Slack, Viber, Twitter, Twilio, Skype, Telegram, Kik, Line, Cisco Spark, Amazon Alexa, Microsoft Cortana. These Integrations provide Platform specific features for building Responses.

Building a Chatbot using Google's DialogFlow 9 (i2tutorials)

Small Talk:

Small Talk is used to provide casual conversations with the User. After enabling the Small Talk, you can customize the responses.

Building a Chatbot using Google's DialogFlow 10 (i2tutorials)


Response is the content which the DialogFlow sends to the User once the request has completed.

Building a Chatbot using Google's DialogFlow 11 (i2tutorials)

Every intent has its respective Response which is given as default.

Leave a comment