Beginner’s Guide to creating Chatbots using Dialogflow (

Suraj Kumar
Jan 25, 2018 · 5 min read

1. Objective

In this article I will show you how to create a simple Chatbot using Dialogflow. You will find here details about the tools and the technology used for the purpose. The article also has a walkthrough of Dialogflow (previously and outlines the chronological flow, so that by the time you finish reading, you will have a basic idea of how to create a Chatbot like RepoFinder.

2. Why You Need A Chatbot

Gartner predicted that by 2020, 85% of customer interactions will be managed without a human.

Google also declared an imminent shift from a mobile first world to an AI first world. Companies across various industries are riding the wave and have deployed AI powered chatbots for their businesses. Chatbots, if they can fulfil their potential will be much more sophisticated than traditional apps. They can understand natural human language, by virtue of which, chatbots will be much more interactive and engaging . As AI improves in the future, talking to a Chatbot will be like talking to someone who has the empathy of a real human and a brain reminiscent of Google.

Now let’s get back to building a bot.

3. Tools And Technology Used

  • Dialogflow: Bot framework to create intelligent chatbots, which you can then integrate with your apps.
  • Node.js: To define the fulfilment logic, which eventually processes the data.
  • Kommunicate: Once you build your chatbot with Dialogflow then you can easily add it to your website or apps using Kommunicate. If you don’t have a/c, please signup here for free.

Now let me help you get familiar with DialogFlow, but first a little about the project as I will be drawing inferences from it in the course of this article:

4. Creating Your First Chatbot — RepoFinder (Project Name)

RepoFinder helps you find open source development libraries from Github, based on your input.

4.1. Creating Agent

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. In our case, we’ve named it RepoFinder.

4.2 Creating Intents

Next you will have to create Intents. Intents basically help the bot perceive the user’s input and decide the subsequent action. Intents can be created both from the console or by calling APIs.

DialogFlow by default gives two intents: Default Fallback Intent, Default Welcome Intent.

More Information on creating Intents is here

4.3. Creating Entities

Once Intents are created, you need to define entities. Entities are powerful tools used to extract parameter values from the user’s query. Any actionable data that you want to get from a user’s request, should have a corresponding entity.

Consider our agent RepoFinder. The user says “Tell me the best Chat SDK on GitHub” — this should tell the agent that the user needs some info on Chat SDK.

So how do you configure the agent to do it? Well, for each user expression mapped to an intent, the agent needs to figure out the respective input that the user wants info about. This, the agent does with the help of Entities.

So for each intent that you create, every user expression should contain a corresponding entity, which your bot agent needs to figure out. Now by default, the agent can’t do that — you need to train it to do so.

4.4 Training Agent

Dialogflow provides a training tool that allows you to add annotated examples to relevant intents in bulk (see screenshot below). It helps to improve the classification accuracy of agent. Here you will also receive a log of all the queries sent to your agent and what the agent responded in return. This is very useful if you tell your agent something and it responds with an output you don’t like. It can also be helpful if you realize later on that you forgot a synonym of an entity and users are using that a lot, then you can go and tell your agent what to do in that case.

4.5 Actions

Now your bot is all set to function. Every time it receives a query, it will first capture the intent and then extract the entity. The next step is to generate a response, which the user is ideally seeking. This you can do by leveraging webhooks to fetch data from external sources (GitHub API server in our case). This you can do in the Fulfillment Section, by specifying the webhook URL.

The penultimate step is to tell the intent to use this webhook to respond with the data that was returned from it.

5. Integrating RepoFinder in Application/Website

The image below demonstrates the integration architecture and the sequence of information flow:

  1. User comes to website and asks for required library.
  2. Website uses Applozic Chat APIs to send message to application server.
  3. Application server sends the query to Dialogflow agent.
  4. Agent uses machine learning algorithms to match the user’s requests to specific intents and uses entities to extract relevant data from them → thereby processes natural language to convert it to actionable data.
  5. RepoFinder returns the actionable result to application server

A part of Response of RepoFinder look like this:

Dialogflow agent’s response with all the details available here.

6. Application server calls Github search APIs/ Internal database to get the list of libraries related to the keyword.

7. Application server then sends the list of libraries back to User again by calling Applozic APIs.

6. RepoFinder Is Ready To Help You

You can checkout RepoFinder here.

You can get the full project with source code on github.

Applozic is on a mission to bring real time communication to every connected application in a matter of few mins.

Want to bring real time communication capabilities to your apps?

Applozic Engineering

Applozic provides Chat SDKs and APIs to power White-label…

Applozic Engineering

Applozic provides Chat SDKs and APIs to power White-label IP-Messaging in mobile and web apps. The blog has all the stories, flim-flams and geeky tales from the makers of Applozic.

Suraj Kumar

Written by

Technical Lead | Engineering Intelligent Applications @Applozic

Applozic Engineering

Applozic provides Chat SDKs and APIs to power White-label IP-Messaging in mobile and web apps. The blog has all the stories, flim-flams and geeky tales from the makers of Applozic.