Easy Steps I use To Create My Chatbots Using Google Dialogflow

Original article was published by Lablonde Juliette Kalalizi on Artificial Intelligence on Medium


A chatbot is an application software that is created for end-users to conduct an on-line chat conversation using messages or text-to-speech, in order to provide direct contact with a live human agent.

Dialogflow Components

Agent: Agent can be recognized as a client support prominant, who directly help users to get awesome experience. Similarly in DialogFlow our chat bot on high level is called an agent. In Dialogflow, an agent is adjective related to human call center agent, both of them are trained by using training examples to handle expected dialogue scenarios.

For Dialogflow however the practice does not have to be overly explicit as for machine learning helps to make your agent smarter. If your agent can be smarter, the more people interact with it. If we take a look a bit deeper, we can see that in Dialogflow Agent serve as a Top-Level container for settings and data.

Intent: An agent connects to the user through an Intent, in general, the intent categorizes the discussion request the user is trying to make. For example, if a user would like to check his account details, then the request will be directed to AccountenquiryIntent. So intents are the monitors which redirect the type of question to a particular category.

In Dialogflow, the intent is the tool for understanding a user’s request. It is one of the most important parts of dialogue application. Example: In case of a hotel reservation bot, the user’s request of: “I want to book a room” which goes to the BookRoomIntent. And if the user want to ask: “Is the breakfast Included at the hotel?” this request can be matched with the ServiceIntent.

How Intent Works?

By providing a few examples behind the scenes, dialogflow uses machine learning to understand the examples that are provided. The phrases that might mean similar things will be provide automatically with the response.

Entities: Entities dispense with the data extraction part. They help to identify specific keywords which are crucial to direct to specific intent for the response. An entity is required when a user expresses an intent they often want your agent to act upon specific part of information that is contained in their statement. In Dialogflow , entities are recycled to extract important information from what an end-user says to provide specific details information that are required by an agent to help service their demand.

Context: Context is like the Natural Language understanding where to reply to the current dialogue, we need to get the context of the previous discussion. They help to connect each discussion section together so that the response from the chatbot is essential. Just like an everyday dialogue between 2 people, sometimes you need context in order to understand what have been discussed. Context is required to understand day to day conversation.

Fulfillment: This forms the determination of the dialogue that happens. It uses API to associate to the backend database to keep the conversation or to retrieve information for the database. Determine fulfillment as a code you want to write to interface the back-end services to reply to our dynamic requests.

Integrations: These are the outside applications which can be linked to the dialogflow so that our chat bot can prosper in the external world. Some applications include, slack, Facebook messenger, Tweeter, Twilio, Telegram, etc…

Let us dive into: To Do part

Now let us get started with implementing our first chatbot using google Dialogflow. In order to access the Dialogflow, we need a Google account. So make sure to have one and use the link to go to the DialogFlow page and Sign-in with Google. Accept the Terms and Conditions of Google and set your country. Then you will be taken to the Dialogflow console.

Screenshot: Author’s desktop

Create an Agent

The first step is to build an agent, which is our substancial chatbot. So click on Create Agent button on the left corner or the one that is available at the center page. Give a name to your chatbot and set the language along with the timezone over which it is going to work. Click on Create, once that is done.

Set up Intent

On the left corner of the screen, we might find a tab called Intent. By default, DialogFlow provides us with deficiency recession intent and Welcome message intent. If you click on any one intent, you might find:

Training Phrases: These are the suitable conversations which users might provide while interacting with the chatbot. We do not need to provide all possible conversation, but instead, we provide only few examples. The machine learning algorithm at the backend of the Dialogflow will practice with all suitable phrases.

Responses: These are the responses which the chatbot provides when it identifies one of the suitable training conversations. If the chatbot cannot recognize the input conversation, a disengagement question is given to the user to provide much clear input data.

Training Phrases

Screenshoot: Author’s desktop

Responses

Screenshot: Author’s desktop

OrderPizza Intent

To create an orderPizza Intent, click on Create Intent. So for example, if we are planning to create a chatbot which helps to order a pizza, we can create a custom intent called OrderPizzaIntent. In the Training Phrase you can set up conversation which takes the pizza size and pizza ingredients and create a response accordingly

Entities

Entities help to extract a specific portion of the data for the chatbot to reply effectively. For example, if the dialogue has: “I want to order a pizza today”, the system automatically understands today as the Datetime field and aids in chatbot’s response. We can create PizzaSize entity as well as pizzaIngredients. In the pizza order example, we can create the pizzaSize, pizzaIngredients as an orderEntity. To create this, click on Entity on the left corner tab and give name to the entity. Specify the variables along with synonyms. Here is an example

Using a PizzaIngredient entity in Intent

We can make the entity created as a secondary sample in the dialogue so that the user provides all the required information to the bot. To do this, open the Intent that has already been created and under section Actions and Parameters add the created entities name and the fallback response if the user does not provide it.

Screenshot: Author’s screen

Context

In each dialogue, the context of the conversation is important. This means that, if a bot has to answer the questions directly, it should understand what the user has replied before. To create this flow of discussion, we can add sub Intent to already existing Intent. For this to happen, go to the Intent page, and click on the Add follow-up intent

Select required intent which implement the discussion like: if the user replies positively we can use “Yes” follow-up intent which might request them to give contact/other details in case of the PizzaOrder bot. Some of the popular follow up intents include:

Fulfillment

The responses from the user can be kept in the Database on the back end using Fulfillment function. By default, the DialogFlow provides with two API options to connect to the backend — 1. Webhook 2. Inline Editor. The Fulfillment tab can be found on the left side of the screen

Integrations

We can integrate our chatbot with multiple available external apps like Facebook messenger, Slack, Twilio, our own website and many other places. For this, we just have to go to Integrations and turn on the apps to which we like to integrate.

Congratulations!!! You have just created your fully functional chatbot. There are many more advanced aspects which DialogFlow provides and can be very well be experimented 🙂

See you in the Next Article, have fun learning !!!!