Build an informative chatbot using Google’s Dialogflow

Aug 29 2019 in AI-ML
Image
  • Why Chatbots?
  • Getting Started
  • Intents, Entities and Contexts
  • Trying out the default bot
  • Building your first bot
  • Testing the bot on Demo UI

Why Chatbots?

Dialogflow is an all-in-one tool for building chatbots which can be deployed on multiple messaging platforms such as Actions on Google (Google Assistant), Facebook Messenger, Amazon Alexa, Slack, WhatsApp and more. Building a natural language conversational tool isn’t easy but with the help of Dialogflow and Google’s Natural Processing Engine, it seems like the future is here. It is also highly scalable as it runs on the Google Cloud Platform. It uses machine learning to understand the context of the conversation and helps you find meaningful insights from a user’s conversation. Learn more about how useful it is and how companies are using it here (https://dialogflow.com/).

Building a chat bot can gives new ways for users to interact with your apps through text and voice. In a recent study conducted by Nielson Incorporated, users are more likely to interact more with a chatbot than a real human being. Also, many enterprises have reported that their customer satisfaction both in terms of information collection and customer support have increased by 200% by incorporating a chatbot into their platform.

Getting Started

On the landing page of Dialogflow, click on Go to Consoleand Sign Up/Sign In with your Google Account. You should be logged in after this.

Now you should see the main menu of DIalogflow. Click the small arrow to the right and create

a new Agent. An agent is basically everything related to your chatbot including the chatbot itself. Click on Create a new Agent and give your agent a relevant name. Also, select your language and location. Dialogflow also offers location based, region specific languages support. You can learn more about it on their site. Select existing Google Cloud project or create a new one. If you are new to Google Cloud, a project is just a common name given to all the services which your app or organization uses on Google Cloud Platform. Click on Create once you are done with this. You’ll now be redirect your agent page.

Intents, Entities and Contexts

An intent is an action that is invoked when a predefined conversation is started. For example, let’s say we have an intent saying “Hello”. Whenever the user says “Hello” or “Hi” or any related welcome message, the “Hello” intent is triggered. All of your defined intents can be found on the menu at the left. An entity is a property or behavior that can be used by intents to recognize certain information such as location, date, time or any custom defined properties. Dialogflow provides a set of predefined entities such as location, date, time, currency and more which can be used right out of the box.


A context helps you keep track of the current state of the conversation. It is unique to every conversation. It lets you maintain the flow of conversation from one intent to another. You can use combinations of input and output contexts to control the conversational path the user takes through your dialog.

Trying out the default bot

When you create your agent, Google creates two intents for you. One is a welcome intent and the other is a fallback intent.


Click on the Default Welcome Intent and observe how an intent is created. You’ll notice a bunch of stuff like Contexts, Events, Training Phases, Action and Parameters, Responses and Fulfillment. For this tutorial, we won’t be using any contexts. Events are invoked when your bot is deployed of Google Assistant. Training Phases and the those sentences that you want your bot (in the context of this intent) to be trained on. Responses are different replies that your bot should reply with when the intent is invoked or the user sends a query related to the Training Phases. We’ll talk about Actions and Parameters, Fulfillment in another article. For now, understand that your bot’s single conversation will consist of all these components.


On the right side of Dialogflow, you’ll notice a console that lets you test your bot for a single conversation. Go ahead and send a ‘Hi’ to it and see the response you get.

You can see that sending a “hi” triggered the ‘Default Welcome Intent’ and also gave the reply that was specified in the response section. So that was just the default bot you just tested!

Building your first bot

In this tutorial, we’ll build a simple bot that gives users information about our company RubyKraft. To get started, create an agent (or use the one we created is the previous section). Since RubyKraft is a custom word, it becomes an entity. We’ll create an Entity called ‘rubykraft’ and then give synonyms like rubykraft, ruby kraft, company and more. This helps dialogflow pick up some information from a conversation. Don’t forget to save the entity.

We’ll create a new intent and call it “rubykraft.introduction”. The user is expected to ask about rubykraft, once the reply is given to them, the conversation has to be moved on and the user is expected to ask about services.Add an output context and call it “rubykraft-services”. In the training phrases section, write phrases that the user is expected to input like ‘tell me something about rubykraft’.

Notice how dialogflow is smart enough to recognize information from your phrase and highlight your entity. This is where you can see the power of dialogflow. This entity can be anything and was pre-defined. Now add some responses as shown.

Again, save the intent by click the save button at the top. Do not forget this as dialogflow will not keep copies of your intents.

In the next conversation, the user is expected to ask about services. So, we’ll create an entity called ‘services’ and provided synonyms.

Now we’ll create an intent and call it ‘rubykraft.services’. Here we have to give the input context as ‘rubykraft-services’ (recall that this was the output context of the previous conversation). Here we expect the user to ask about services provided by rubykraft.

Go ahead and add responses as you like.

Finally save the intent.

Testing the bot on Demo UI

Once you are done following the steps above, in the left menu, click on Integrations. Here you can see all the different services your bot can be deployed on. For our Demo purpose, turn on the “Web Demo” button.

n the prompt provided to you, edit the URL however you like and you are good to go! Now visit the URL (in our case it is https://bot.dialogflow.com/rubykraft-intro). Go ahead and run your query on the demo chat UI provided!

Our bot is working as expected! How exciting isn’t it? Feel free to explore.

Are you an enterprise or small business looking for high quality chatbots? Contact us at https://www.rubykraft.com/contact now! We at RubyKraft have mastered the art of maintaining creativity and sophistication yet meeting all our professional standards while we relay our services to you. Learn more about us here: https://www.rubykraft.com/about

Let's build something great

Get a customized quote for your product