Bot Building & Training

  • No categories

Build your first chatbot

Building chatbot is fun. This article will guide you in building your first chatbot. We start with a basic bot which is as simple as greeting Hello World!. Then we move on to building a complex bot which can converse with users and answer complex queries.


Bot creation with token

Goto, login with OAuth.
Then click Create a new bot.

You cannot create a bot unless you have a token.
A token is like a ticket to create a bot.
So once you acquire the token, fill up the fields like bot name, description & token then click create.

Congrats, you have just created a new bot. Now you will see your new bot along with other bots in the sandbox section. Click on the bot and it will take you to the bot builder section.

What happens when a bot is just created?

When a bot takes birth, it contains only a single intent , that is Default intent. This default intent contains a default step.
So whenever a bot loads, It will first run this default intent’s default step.
This Default step is like a welcome section: If you want to display some content that shows up when the bot is loaded, then this is the place. Ex: Hi, This is X, your assistant. How may I help you. It is also used to show menu options.

Creating a welcome message

Let’s create a welcome message for the bot. To do that, go to default intent in the default category, then select default step. In that step you can add the content by choosing one or more forms of output like textbox / quick replies / cards / functions etc. Let’s choose a textbox and add the text Hello World!.

Hello World. is shown now whenever the bot loads. Try pressing the home button, It will again display this welcome text.

Creating a greeting text

Bot can understand greetings like hi, hello, good morning etc. You just have to put a response for the greeting.
In the Generic responses section you can set up a greeting text as shown below.

The bot shows this text whenever you greet the bot.
We are done with configuring welcome text and greetings.

Next, we move on to creating intents.
By which we can make the bot engage in conversations and answer queries.
You can add as many intents as you wish. The more the intents, the more the functionality of the bot.

Creating first Intent

Objective: To make the bot answer weather queries.
In this tutorial we’re going to create a weather intent which can give weather details of any city.
Bot should be able to answer queries like

What is the weather
I want to know weather details
Can you tell me the weather in bangalore.

To achieve that, we need to create a journey.
Lets create an intent weather_details (Intent and Journey both are synonymous)

You can create intent by going to the leftmost section Journeys and click on + New Journey

Fill name, description and hit start.

In this journey, we ask the user the name of the city and show him the weather details of that city.

We are now done with creating an intent. Now we have to train the intent. We can do that by adding utterances here. LINK TO TRAINING GUIDELINES

See the GIF below

Once you are done adding the utterances then train the intent by clicking on the button shown in the image. It will take a while to train. After the training is done you might want to click on the show performance as shown in the image to check the confidence of utterances.

All the confidence values are > .90. Now, any weather-related utterance will hit this intent. We are good to go.

Setting minimum confidence

This is done in main function. Without setting minimum confidence the bot will not give the response (even if the confidence values of your utterances is 0.99)

return app.start({minConfidence: 0.7});

After hitting this intent, we need to ask the user the name of the city. We can do that by creating a step. What is a step?


“Steps are the building blocks of conversation”

The purpose of a step is to ask the user something and take input. When an utterance hits an intent it will first go through all the steps first and then hits Action. We use steps to seek all the inputs required to process the answer. (Here city name is required to answer the weather query)

Go to weather_details intent and click +New Step. Then fill the name and description of the step.

We have created a step which takes city name from the user. (At this point we are done with taking required inputs for processing the answer).



"Action is where the intent logic is written"
Now is the time to take that city name from the step city and hit Weather API which gives the temperature and weather conditions of that city. All this logic is written in Action.

As we’re doing an API call here, we need to create a function. Then we need to link that function to the action of this intent.

Linking a function in an Action. See the GIF below.

If there is nothing to process, there is no need for a function, you can choose a textbox or other output formats like cards etc instead.

Creating a function

Goto developer section to create a function. See the below GIF.

Action function. Place this function in the action of weather_details

If user asks the bot “tell me the weather in Delhi”. Here’s the catch! the bot again asks the user to tell the city name. See the image below.

The bot shouldn’t go to the step again, instead skip the step.

Now, we’ll have to make the bot even more intelligent by identifying the city name in the input and skip the city step if it is present.

Our prediction model has a provision of identifying GPE ( Geo Political Entities).


If utterance contains delhi. Its a GPE (Political & City)

// If utterance contains Delhi. Its a GPE (Political & City)
global_entities: [
     text: "Delhi",
     label: "GPE"

     text: "Delhi",
     country: "India",
     label: "city"
// If utterance contains ‘USSR’. Its GPE (political)
global_entities: [
     text: "Ussr",
     label: "GPE"

So, in order to identify the entities beforehand, we need to write a function that executes before the steps. That is called as init function. What is init function?

Init Function

This function is executed immediately after hitting an intent, even before proceeding to the steps. Here we can identify the entities and also fill the steps in advance so that flow doesn’t hits the steps again.

Place the following  function in init function section (bottom-most) of weather_details intent.

Then ask the same question to the bot. “tell me the weather in Delhi”

Does it ask the city name again??

It won’t ask the city name again if the city is present in the user utterance.

Finally, We have skipped the step 🙂

Congrats. You have just created your first bot which tells you the weather details.

You must be logged in to post a comment.