Introduction To Dialogflow — Conversational User Interface

Introduction To Dialogflow — Conversational User Interface

In today’s world, We are living in space of Conversations.

What is Conversation space? One might ask.

By the term “Conversation space”, I am referring to the era where everything is done by just communicating with our electronic devices. For example, If we want to know What is today’s forecast? We can just ask our mobile phone and we get our answer. There are numerous such examples of Conversation space which has made our life both easier and more fun.

Let’s roll back to ancient times from where Technological Revolution started and progressed.

The conversational shift can be explained as we can see from the above image, we can notice that we have been upgrading in technical aspects every 10 years. First in the 1970s we had the Mainframes, then after 10 years in 1980s we had the Desktops, after that in the 1990s we had the Internet, In 2000s with the Introduction of iPhone we had the Smartphones and finally in 2010s we had the Assistants which made it possible to interact with machines as if we are communicating with the Humans.

Now, moving towards Conversational User Interface (CUI) most of the people might think it more like Graphical User Interface (GUI) which is incorrect. So, Let us understand difference between GUI and CUI.

GUI: GUIs display object that conveys information, and represent action that can be taken up by the user. The objects can change color, size or visibility when the user interacts with them.

CUI: CUIs on the other hand, enable users to interact with computers using voice or text, and the interaction usually mimics real life human communication.

So that now we have some idea on what Conversational User Interface is, we can take a dive and learn about Dialogflow and what it is primarily used for.

Dialogflow is a natural language understanding platform used to design and integrate a conversational user interface into mobile apps, web applications, devices, bots, interactive voice response systems, and related uses.

Dialogflow is a framework of Google. We can say that Dialogflow is a framework which enables us to build Conversation based AI applications which can include various use cases primarily which includes use case of Telecom providers where most of the Customer Service calls are managed and handled by the application we build using Dialogflow and thus live agent transfers or Human Intervention is reduced a lot thus saving costs of human training for companies which require Customer Service helplines.

Now that we have some basic understanding of what Dialogflow is, Let us deep dive into it and learn some basic terms and functionalities of Dialogflow!

To access Dialogflow, One can easily go to the website: and can sign in using their Google account as shown in the image below.

After signing in to Dialogflow and accepting the Terms of Service, we’ll get a layout shown in the below image.

Here as we have not created any Virtual Agent till now, so we do not have any functionalities to work upon, so to explore those functionalities, Let us create an Agent of our own by clicking on “Create Agent” shown in the image below and look what is in the box for us!

After clicking, we will be shown a page where we have to enter some details about the bot like Agent Name and Timezone in which you want your bot to be present, then click Create. The example of the same is shown below.

It will take a couple of seconds, After that our virtual agent will be created and this is what we will be able to see after that.

As we can see, there are 3 sections in the Home screen:

  1. On the left, we have all the functionalities which our bot can leverage from.
  2. The middle section contain all the Intents our Bot uses.
  3. The right section is the simulator where we can test out our Virtual Agent.

Trending Bot Articles:

1. How Conversational AI can Automate Customer Service

2. Automated vs Live Chats: What will the Future of Customer Service Look Like?

3. Chatbots As Medical Assistants In COVID-19 Pandemic

4. Chatbot Vs. Intelligent Virtual Assistant — What’s the difference & Why Care?

But to build our Virtual Agent we first need to learn some basic components involved in the development of the bot. Let us first learn about the most important component of the Bot which is the “Intent”.

Now, What is an Intent?

An Intent can be described as an Index of a book. As an Index contains all the topics involved in the book same way is for Intent. A bot can have multiple topics based on our use case and we can add funcionalities to each Topic (Intent) by clicking on that Intent. Intents help us to create a conversation flow and to add multiple functionalities to the bot.

We can see from the image above, we already have 2 Intents created for us which are the “Default Welcome Intent” and “Default Fallback Intent”.

Let us look how a Intent looks from inside by clicking on “Default Welcome Intent”

As we can see there are many options available to us, Let us try to understand each and every component involved here.

First we have Context and Events, let us keep these to the side for now, these will be covered later in the blog. After that we have a section of Training phrases.

Training Phrases are nothing but the “user utterances” which the bot expects. Training phrases should be according to the Intent we are working on, As this is a Welcome Intent we can see that there are some training phrases added which the user might say to start the Interaction with the bot such as “Hi”, “Hello”, etc. These phrases will help the bot to recognize that the user is trying to start the conversation with it. We should think from the user’s perspective while adding training phrases, The more the quality of training phrase we provide the better will be the accuracy of the bot.

Now, as we also expect the bot to give us an answer in return to the user query, So we have a section of “Responses” below “Training Phrases”.

Responses is the section where we can specify the response as we desire for a specific Intent. We can see here that some responses are already added and there are multiple responses added which means that when this Intent is triggered we can get any response at random from the responses listed. It’s totally our choice if we want to specify a single response or multiple responses.

Now let us look at a short demo of the concepts we have learned so far, If we enter a user utterance such as “Hi” we expect the bot to reply from the responses listed in the Default Welcome Intent.

As we can see on the Simulator section, we can see that after typing “Hi”, we got the response from the bot as “Greetings! How can I assist?” and even we can see below the Intent which is triggered i.e “Default Welcome Intent”.

Now, let us create our own Intent and the use case of that can be that we have to capture the phone number of the user.

On the Home Page, we can see an option to create an Intent, click on it and we can name the Intent as per our convenience but it should reflect the use case.

We can then add training phrases and the response as well. The example is shown as below.

We can see that after we have added some training phrases of Phone numbers, the phone number is highlighted automatically. These numbers are highlighted because these can be stored and can help us in our further processing. These numbers are stored in something called as Entity.

Entities help us to capture important data which can be used by us to further process and analyze the bot performance and also to to fetch more data through Api calls.

Now that we have created an Intent, we need to make a flow so that after the user encounters Greeting message, the flow should move forward towards capturing the phone number from the user. To achieve this we have something called as Context.

Contexts help us to make the conversation flow and to ensure that the flow goes on to our desired flow. There are 2 types of Contexts Output and Input Contexts.

Output Context is set on the Intent from where we want to shift the Intent.

Input Context is set on the Intent to which we want the user to land after the Intent on which we have set the Output Context.

So, to summarize with our use case, we want the user to go from “Default Welcome Intent” to “PhoneNumber” Intent. So, we can set an Output Context on the Default Welcome Intent and Input Context on the PhoneNumber Intent.

We have now set the Contexts in both the Intents. We can see that in Default Welcome Intent there is a number associated with the Context, that is nothing but the Lifespan of the Context.

Lifespan is the the count for which the Context remains valid, that means for that number of user-bot interactions the context remains active after that it gets expired. Also after every 20 minutes the Context gets expired itself.

Now that we have set the contexts let us try out the flow.

As we can see, the flow went as per our desired requirement and we can also observe that in the simulator all the relevant details are listed like Context, Intent Name, Entity Values etc. The phone number we provided is captured in the Entity we declared and also the value is stored in it.

Now as we have made a static bot, what if we want to make a more dynamic bot and handle it by writing code and manage multiple scenarios at once. We can do that using Fulfillment.

Fulfillment can be used to connect the Dialogflow bot to our code. We can achieve this in 2 ways either by enabling Webhook and we can create a https link and connecting the code or we can use the Inline Editor of the Dialogflow and can write our code over there.

In this way, we were able to understand the Basics of Dialogflow and also created a simple static bot of our own.

Hope this blog might have helped you to gain some insights into Conversational User Interface and Dialogflow!

Don’t forget to give us your 👏 !

Introduction To Dialogflow — Conversational User Interface was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.