2. Understand your users
In the previous lesson, we created a new bot and edited its Introduction block. Now it's time to make your bot able to understand its users by powering it with our Natural language processing engine.
Last updated
In the previous lesson, we created a new bot and edited its Introduction block. Now it's time to make your bot able to understand its users by powering it with our Natural language processing engine.
Last updated
Humans begin to process speech from birth. We hear numerous sentences over time which help us understand new ones. Consider your bot as a baby: it needs you to 'teach' it many expressions to recognize ones it has never encountered before.
Teaching a bot to process language is called Natural language processing, which you’ll see referred to as NLP. For a deep dive in NLP, read more here.
In Chatlayer, building a NLP model is done in 3 steps:
Define what the users would mean (the intents).
Define how users could formulate those intents (the expressions).
With those intents and expressions, train the NLP so that your bot learns to properly label an expression with an intent.
Let’s build a small NLP model for our retail chatbot.
After the bot introduced itself and suggested a discount, we would like users to be able to type if they’re interested. To do so, we need to add a yes intent.
Intents are a group of expressions or utterances that mean the same thing. When you build a chatbot, an intent can be referred to as a user goal. For instance, the intent yes could be made of expressions like I agree, Yes, yes please, etc. Learn more about intent and expressions here.
To create an intent:
Under the NLP tab on the left-hand side, click on Intents.
Click on the + button at the top of the screen, or on the green Create intent button in the middle of the screen.
A Create intent window opens. Give your intent the name yes, and add a description to it, e.g. An intent to agree or say yes to a discount.
Click on Create.
Your intent now appears on your screen, with zero expressions in it. This means that it is empty. We need to add expressions to it so that we can use it.
To add expressions to your yes intent:
From your Intents page, click on the yes intent that we just created.
Type your expression in the text field. For instance, type yes please.
Let’s first add expressions manually. Either click on the + button next to it, or click Enter on your keyboard. You can add expressions like:
yes
oh yeah!
i'd love that
If you would like AI to generate expressions for you:
click the stars button next to the text field.
Accept the Generative AI terms and conditions.
You’re suggested a list of expressions based on the intent that you made. Select the generated expressions that you’d like to keep.
Click on Add selected.
The added expressions appear now as a list underneath your intent.
You've successfully created an intent! This means that your intent now has expressions. However, it's not yet utilized in the bot. Let's explore how to connect this intent to a block.
For now, your intent exists in your chatbot but it isn’t used inside the conversation. In other words, when a user says ‘yes’, it wouldn’t trigger any response from the bot.
To make your intent trigger a response, we need to insert this intent in the bot canvas.
To add your intent to your canvas:
Under Bot dialogs, click on Flow to access your bot canvas.
From the left-hand side, drag and drop an intent block to your canvas.
The Intent block opens on the right-hand side on the screen. From the dropdown, select yes, which is the intent that you just created.
Now, if the user answers ‘yes’, we would the bot to answer ‘Amazing!’. To do so, we should link the intent block to another one by using a Go-to connection.
On Chatlayer, a Go-to connection is represented by an arrow on the canvas. If the block A is linked to block B by a Go-to, it means that block B will happen just after block B in the conversation.
To connect your intent to a response:
Still from inside your intent block, click on Go to, at the bottom of the window.
Click on the placeholder to select a block where the bot should go to after this one. Create a new block by giving it a name. Type Yes to discount and select the Message block type.
Click Save.
The yes intent now appears on your canvas and it’s linked to a block called Yes to discount.
Yet, the content of Yes to discount block is still empty. To edit the content of this new block:
Click on the Yes to discount block to open it.
Add a text there that says: Amazing!
Save your changes.
The result on your canvas should look like this:
Time for testing the changes!
Reproduce what we did in step 3 to test your bot:
Enter one of the expressions of the yes intent.
Your bot should recognize the expression and answer Amazing!
Click on the Restart conversation icon at the top right corner of the Test window.
Now, enter something that wasn’t in your set of expressions, like yeah sure.
Your bot should display the Not understood block as follows:
The Not understood block is triggered when your bot didn’t understand what the user said.
This means that your bot doesn’t recognize ‘yeah sure’ as a yes intent. Why is that the case? Because you we haven’t trained the NLP model yet!
If you haven’t trained your NLP, your chatbot will only be able to recognize the exact expressions that you have entered in an intent.
Let's explore how to train the Natural Language Processing (NLP) model to recognize a wider range of expressions.
Training your NLP model allows your bot to understand new expressions that convey the same meaning as those already entered in an intent.
To train your NLP:
From your Intents tab, click on the Train button at the upper right corner of your screen.
A window pops up. Select English as the language that you want to train.
Click on Update.
You can see when was the last time your NLP was updated by checking the NLP dashboard. To do so, go to Dashboard under the NLP tab.
Tip: turn on the AI Intent booster to increase the recognition of your intents for smaller bots. This will be explored in a follow-up tutorial dedicated to the Chatlayer AI functionalities.
It’s time now to test the bot with our yeah sure again.
Your bot should recognize it, therefore answer with the right block!
Reproduce the same steps so that you add a no intent: create the intent, fill it with expressions, link it to a block, train your NLP and test it.
This is what it should look like on your canvas:
Every bot should have a way to redirect users to a human. Typically, this is what you want to happen if the user is not understood multiple times.
To edit your Not Understood block:
From your canvas, double click on the Not Understood block to open it.
Edit the text for the following: I’m sorry, but I didn’t get that. Please try a rephrase or send us an email with your question: email@company.com.
Save your changes.
It should look like so on your canvas:
In this lesson, you’ve learned how to:
In the next lesson, we will see how your bot can keep user input in memory to re-use it later.
3. Collect and display user inputYour feedback on the tutorial means the world to us! Please, let us know what you think through this short form.