2. Understanding your users
In the previous tutorial, we created a new bot and added a greeting dialog. Now it's time to make your bot able to understand its users by powering it with our Natural Language Processing engine.
Before we continue with ChooChoo, let's take you through some concepts that you need to know to grasp how your chatbot can actually understand what users are saying.
The science behind a bot able to understand humans is called Natural Language Processing, or NLP. In Chatlayer, building an NLP model is done in 3 steps:
- 1.Define what the users would mean (or the intents)
- 2.Define how users could formulate those intents (or the expressions)
- 3.With those intents and expressions, train the NLP model so your bot learns to label expressions with intents
We will build an NLP model together for ChooChoo, but first, let's go through theory in a bit more details 👇
To build a chatbot that responds differently depending on what is asked, it is key to understand what the NLP engine is.
The Natural Language Processing (NLP) engine is the underlying AI algorithm that allows the bot to understand what the user is saying. And as each language has its own words and grammar, we have a separate NLP model for each language!
To be efficient, the NLP model of your bot needs to be trained. You will learn how to do that in the steps below.
The NLP of your bot is configured by making groups of expressions that we call intents 👇
An intent is a series of expressions (or utterances) that mean the same intention or goal from the user side. During the conversation, intents are recognised by the NLP engine and serve to steer the conversation in different ways.
For example: an intent can be a question, a statement, an answer to a question, or a greeting. Each intent can be expressed in many different ways, which is why we call them expressions.
The expression "How do I sign up for a free trial" is recognised by the NLP engine as an explain-free-trial intent, which triggers the correct response from the bot.
Here are some examples of intents and some expressions to formulate them:
Let's now incorporate those concepts to ChooChoo.
For our ChooChoo bot, we want to give ChooChoo the ability to answer basic questions about itself. To get started, we will create an intent for the question: Who are you?
- On the left side of the screen in the navigation menu, click on
NLPto navigate to the NLP module. Click the
To create intents, click on the Intents tab underneath the NLP module.
- Click on
Add Intentand name it Who are you and click on
Creating a new intent called "Who are you"
- Now you see that the intent is successfully created, without any expressions added to it (that is what the '0' means below the language)
The new intent is successfully added to the Intents list
Yet, since this intent has 0 expressions, this means that it cannot be recognised by the NLP model. Next step is about filling this newly-created intent with different expressions in natural language 👇
Now we have to make sure the NLP recognises the intent that was just created. This can be done by feeding the model with expressions.
Expressions are different ways your users will express one intent. In bot building, as in real life, there are more ways to say something or ask a question.
- Select the
Who are youintent in the Intents pane on the left hand side
- The Expressions pane will open in the right. Click on
Adding an expression to your intent
- Enter Who are you? in the open text field
- Click on
Add some more expressions by clicking
- What is your name?
- Can I know your name?
- Tell me more about yourself
- Please, I'd like to know who I am talking to
- How should I call you?
- Who is Choo Choo?
- Tell me what your name is
- Who are ya?
- What do people call you?
- Are you a train?
- Do you have a name?
This will result in the following screen:
Add varied expressions to your intents to make their recognition more accurate.
Let's try adding another intent and expressions:
Add another intent, like
Greetingand add some expressions:
- Hi there
- Good morning
We have defined two intents now: Who are you and Greeting.
Adding more intents
However, if we were now to say 'Good morning' to the bot emulator, nothing will happen. That is because the NLP is not trained yet, and the intent is not yet linked to a bot dialog. We will work on that in the next steps.
To make sure the bot can use the intents with expressions that were created, we now need to update or train the NLP.
Updating the NLP means that the newly added intents and expressions will be learned by the bot so that it can recognise a wide range of expressions as belonging to the correct intent. This step is crucial: if you do not update the NLP, the bot has no knowledge of natural language understanding.
- Click the
Update NLPbutton in the top right corner of the screen:
To train de NLP, click on the Update NLP button
- Select the language you used to add the expressions. You can view the status of the NLP update for each language by clicking on the Update NLP icon.
The NLP needs more intents and expressions to be trained.
- Click on
Updateto start the training. This can take a couple of minutes to one hour depending on the size of your chatbot. The more complex, the longer it will take.
The NLP is updating
That was a great first step to be able use the 'Greeting' and 'How are you' intent. The next step is to link these intents in the bot dialogs so that the bot can respond to them.
You have now taught the NLP to understand intents, congrats!
The only thing left to do is teaching ChooChoo how to respond. This means we are going to choose what the response (or flow) should be for each intent.
Let's add a new bot dialog that will serve as a response to the intent Who are you:
- Click on
Bot Dialogsmenu item in the navigation pane
- Open the
- Click on the grey button on top
+ Bot message
Settings, enter Who are you as the name
- Choose the Introduction dialog state as the parent
- Open the
NLPof that bot message
- Link the intent to the bot dialog in the bot dialog NLP tab as follows:
Link the Who are you dialog to the Who are you intent
- Go to
Bot Messagetab and add a text message that says:
I am Choo Choo, your personal assistant for booking train tickets
Your screen should look like this:
- Click on
- This will result in the following overview in the flow:
The Who are you dialog is successfully linked to the Who are you intent
If you now say 'Who are you' in the emulator, you immediately get the response that is typed in the 'Who are you' bot dialog. The dialog and the intent are successfully linked! 👏
See how the intent Who are you is recognised and triggers the Who are you dialog by testing your bot in the Emulator.
Now, you have a bot with the following configuration:
- 2 intents ('Greeting' and 'Who are you') and their expressions
- A bot message 'Who are you', with the intent 'Who are you' and four text messages in it.
You should now be familiar with:
- Adding an intent to a bot dialog
- Creating intents and expressions
- Training the NLP to use these intents and expressions
- Adding multiple text messages in one bot message
- Testing your intent and messages in the emulator
In the next tutorial we'll be gathering user input for booking a train ticket. Check the rest of the tutorial to learn more 👉🏻