Last Updated on June 6, 2022

Chatbots help increases user engagement, and can often be used to boost a website’s conversion rate. In fact, according to this data from the firm Comm100, chatbots are able to handle close to 69% of all the chats from start to finish. All this points to the fact that your business website could only benefit from using a chatbot. But is building a chatbot for your website easy? If you ask us, it is.

In this post, we will teach you how to build a chatbot using Dialogflow (Google API). We will give you step by step instructions on how to build a chatbot, and, by the end of this tutorial, you will have a bot ready to do your bidding.

Before we begin, here are a few terms you should be familiar with:

  1. USER:  A ‘user’ is any human being that builds a bot, trains a bot, interacts with a bot, or in general, uses a bot as a means to an end. Only human beings can be users, and chatbots cannot be ‘users.’
  1. AGENTS: Chatbots are also referred to as ‘agents.’ An ‘agent’ is usually the name given to a support agent,  which is another way of calling a chatbot.
  1. EXPRESSIONS: Whatever you say to a bot is an expression. If you wish to interact with a bot, you would often ask it a question, such as “What are your pricing options?” or “When is the last train to Busan?” These sentences, in technical terms, are called Expressions, and we will be learning more about them as we progress.
  1. INTENTS:  We know what ‘Expressions’ are, but how does a chatbot understand these expressions? This is where Intents come in. Different expressions can mean the same thing, and this meaning is called an ‘intent.’ For instance, a user query can range from “When will this model of phone launch?”or “ When will this model of phone be available?” We can easily say that the intent of the user here is ‘model availability.’ You can group various such expressions into intents, making it that much easier for the bot to respond.
  1. RESPONSES:  This is the output by the chatbot when it receives a properly formatted input, which will satisfy the user’s query. For instance, when the user’s expressions trigger the intent ‘ model availability,’ the response will be something like “ The model will be available from the second week of February.” A good chatbot will give straightforward, simple responses.
  1. ENTITIES: Intents will help the chatbot understand the motivation behind each user query, but there is useful information present in the natural language input of the user. Dialogflow uses something called ‘entities’ to extract this useful information from the natural language input. Entities help in picking out specific pieces of information that your users mention, such as a product name or a street address.
  1. ACTIONS: Actions are Dialoglow mechanisms that help identify and annotate the keywords by connecting them with Entities. Actions also act as prompts that help extract useful information from the user.

Now that you know most of the common terminologies that we are going to use, let us see them in action. We are going to build a simple TicketBot that will book tickets based on user inputs. Here we go:

Step 1: Setting up a Dialogflow account

Creating an agent

Sign up for Dialogflow and open your dashboard. The first step is creating an agent, which essentially is the bot you are building.

You can create one through the console by following these instructions:

  1. Go to the Dialogflow ES Console.
  2. Click Create Agent in the left menu.
  3. Enter your agent’s name, default language, default time zone, and GCP project, then click the Create button.

Step 2: Developing the Bot – Preset intents

Dialogflow gives you access to basic intents such as the Default Welcome Intent and Default Fallback Intent. When the bot doesn’t know what to respond or when it needs to welcome someone on to your website, it uses the Default Welcome Intent.

To activate this, click on the Default Welcome Intent button. When you scroll to the ‘Training phrases’ section, you will see a list of expressions that a user may speak to your TicketBot. If you observe closely, you can get to know that all of them mean essentially the same thing, and have been clubbed under the ‘Default Welcome Intent.’

Almost everything that a user might say to start a conversation is covered in this section, so the next step is to test out our TicketBot to see how it is greeting the customers. Type in something to begin the conversation, like ‘Hi’ or ‘Hello’.

And that’s it!! Our TicketBot is now live. We will now see how we can make edits to these responses. The TicketBot will return a random response to other expressions.

Step 3 – Modifying Default Welcome Intent – Creating custom responses

In the ‘Responses’ section, we can see the different welcome messages that our TicketBot will reply to when users enter certain expressions. What we are going to do is create a custom Welcome response for our movie theatre: RVR Cinemas.

Our message will go something like this:

“Hey there! Welcome to RVR Cinemas. My name is Ticket Bot.”

Delete the other redundant messages by clicking on the trashcan button on the right. And now, add another line to your Default Welcome message by clicking on the “Add Response” > “Text Response.”

Make sure you insert text that reads like a human is typing from the other side. The conversation should flow smoothly. Type in something like, “How can I help you?”

And this is what your Welcome Message would look like:

Step 4 – Creating new Intents

Time to train our TicketBot to assist new visitors to your website with some common questions.

“What are your show timings?”
“Which movies are playing during the Matinee?”

We will create the intents for these questions, and train the bot to give us appropriate responses.

Start by creating a new intent, by clicking on the‘+’ sign next to the ‘Intents’ button. Make sure you name your intents clearly so that it is easier to decipher them in the future. Also, make sure to group various expressions clearly under well-defined intents. Make sure you keep your Responses accurate and to the point.

Let us now see how we can respond to the intent of the first question: Show timings.

Now that you know how to create intents, let’s take things to the next level so that the TicketBot can actually book a ticket.

Step 5 : Working with Entities, Actions and Parameters

We are now going to train our TicketBot to book a movie ticket at RVR Cinemas. The process is pretty straightforward, provided you read carefully. Let’s go.

Click on the ‘+’ button next to the ‘Entities’ button in the left menu and make sure you are adding “ MovieNames” and “MovieTimings” separately. Corresponding to the movie names, make sure you add all the alternate names that the users might type when enquiring about a particular movie.

It is now time to create the Intent. You can give the intent a specific name such as “Book Ticket.”

 The next step is to add Parameters in DialogFlow, naming them precisely so that you know which Parameter corresponds to which entity. 

Next to the Parameter, enter the Entity that you have created with the “@” Symbol and enter the corresponding value that starts with the “$” sign. You need to enable Prompts for these bookings, so make sure you check the “Required” field.

We need to ask the User which movie he/she would like to see, which we can do with the help of Prompt Messages. We can ask questions like:

Which movie would you like to see? We are screening ‘Finding Dory,’ ‘The Dark Knight Rises,’ ‘Avengers Endgame,’ ‘Spiderman: Into the Spiderverse,’ ‘The Martian,’ and ‘Avatar.’”
“What time do you want to watch the movie? We screen movies at 11 am, 2 pm, 6 pm and 9 pm.”

It is now time to add Training phrases. This could range from “Book movie ticket,” to “Book Ticket,” encompassing all the questions that a possible user might ask to the bot.

Step 6: Add a concluding Response

It is now time to end the conversation that the website visitor has been having with the bot, with the help of concluding responses. If you wish, you could add the ‘$” value in the message. This will help the message be clearer, since it will extract useful information from the Parameters. There is a small toggle button at the bottom that will trigger that this is the end of the conversation.

Your movie ticket for $MovieName with $MovieTimings has been booked. You can collect the tickets at the counter 15 minutes before the movie begins.”

Step 7: Add DialogFlow to your Website

Kommunicate provides a no-code integration with Dialogflow. You can easily deploy your bot on websites, mobile apps, Facebook, or WhatsApp using Kommunicate.

Here are the instructions to integrate Dialogflow with Kommunicate:

  1. Open Dialogflow agent settings (gear icon on the left panel).
  2. Click on the Google Cloud link, which is mentioned in the Google project bar.
  3. On the Google Cloud page, navigate to the Credentials section by clicking on APIs & services.
  4. Under the Credentials section, find the service account and click on edit for Dialogflow integrations.
  5. At the bottom of the screen, click on the ADD key button and create a key option. Download the JSON key
  6. Now, open the Kommunicate dashboard and navigate to the Bot Integrations section.
  7. Choose Dialogflow ES.
  8. Now, give your bot a name and choose an avatar.
  9. In the next section, upload your JSON key, knowledge-base ID (optional), and choose the default language.
  10. In the next step, select whether to enable chatbot to human hand-off or not.
  11. Now, move to the Install section, and follow the instructions to integrate the Kommunicate chat widget into your website, mobile apps, and other platforms.

For detail of how to integrate Dialogflow with the website click here

Step 8: Training the Bot

Remember that your chatbot is an intelligent algorithm with machine learning capabilities, and you can refine it further by interactions and training. Training the bot also helps fix errors and improves accuracy.

To train the bot, navigate to the “Training” section in the left menu. What you see here are a series of conversations that are arranged in rows of data. You can view each session by clicking on it, and then, if there is an intent mismatch, you can go ahead and correct it.

Observe how we train the bot to give a response to a question that the bot is unfamiliar with, using a Fallback intent.

User: When do you screen The Hobbit: An Unexpected Journey?

Intent: Book ticket

User:  I don’t see the listing of the new Hobbit movie.

Bot: Default Fallback intent

What?

Bot: Default Fallback intent

There will be instances where the bot does not know the response to a particular question. In this case, it does not know the answer to the question, “ When do you screen the movie, “The Hobbit: An Unexpected Journey.”

There could be other questions such as:

“When do you screen the new Hobbit movie?”
“Can I book all the tickets for a particular show?”
“When will RVR Cinemas introduce midnight shows?”

To answer these questions, use the Default Fallback intent so that you can give the user the answer to the questions they are looking for.

The bot is collecting all this information and storing it in the form of sessions. Training the bot involves collecting these new expressions and classifying them under intents. From the bot’s conversation history, you can find the list of questions that triggered Fallback Intents. You can continue adding these questions into new intents, and then train the bot using the steps mentioned above. The more intents you provide, the more trained your bot will be, which is sure to leave your user impressed.

<Kommunicate Dialogflow Dashboard showing the above conversation>

And before you know it, we have reached the end of the tutorial!!! Congratulations on creating a TicketBot that you can show off to your family and friends. 

Parting thoughts:

Before we let you go, Below is a video tutorial explaining how you can build a Dialogflow bot, in simple steps. Play around with actions, intents and parameters, and create different kinds of bots that serve different purposes. The more you train yourself and your bot, the smarter both of you get. Chatbots are going to dominate the customer service niche if they are not doing so already, and with a platform like Dialogflow to help you build the bot, there is no limit to the things you can do.


Kommunicate is a modern customer messaging suite to add live chat and chatbot to your websites and social media pages. You can signup for free here and start delighting your customers right away.

1 Comment

  1. I think this is one of the most vital information for
    me. And i’m glad reading your article. But should remark on some
    general things, The website style is great, the articles is really great :
    D. Good job, cheers

Write A Comment