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.

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:

  1. Define what the users would mean (the intents).

  2. Define how users could formulate those intents (the expressions).

  3. 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.

Step 4: Add an intent

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.

Create an intent

To create an intent:

  1. Under the NLP tab on the left-hand side, click on Intents.

  1. Click on the + button at the top of the screen, or on the green Create intent button in the middle of the screen.

  2. 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.

  1. 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.

Add expressions to an intent

To add expressions to your yes intent:

  1. From your Intents page, click on the yes intent that we just created.

  2. Type your expression in the text field. For instance, type yes please.

  3. 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

  1. 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.

Make your intent trigger a response

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.

Add an Intent block to your canvas

To add your intent to your canvas:

  1. Under Bot dialogs, click on Flow to access your bot canvas.

  2. From the left-hand side, drag and drop an intent block to your canvas.

  1. 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.

Connect your intent to a response

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:

  1. Still from inside your intent block, click on Go to, at the bottom of the window.

  2. 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.

  1. 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:

  1. Click on the Yes to discount block to open it.

  2. Add a text there that says: Amazing!

  3. Save your changes.

The result on your canvas should look like this:

Time for testing the changes!

Test your bot

Reproduce what we did in step 3 to test your bot:

  1. Enter one of the expressions of the yes intent.

  2. Your bot should recognize the expression and answer Amazing!

  1. Click on the Restart conversation icon at the top right corner of the Test window.

  1. Now, enter something that wasn’t in your set of expressions, like yeah sure.

  2. 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.

Step 5: Train your NLP

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.

Train the NLP model

To train your NLP:

  1. From your Intents tab, click on the Train button at the upper right corner of your screen.

  1. A window pops up. Select English as the language that you want to train.

  2. 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.

Test your bot

It’s time now to test the bot with our yeah sure again.

Your bot should recognize it, therefore answer with the right block!

[Optional: Test your knowledge]

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:

Step 6: Edit your Not Understood block

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:

  1. From your canvas, double click on the Not Understood block to open it.

  2. 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.

  3. Save your changes.

It should look like so on your canvas:

Lesson 2 recap

In this lesson, you’ve learned how to:

Coming next

In the next lesson, we will see how your bot can keep user input in memory to re-use it later.

page3. Collect and display user input

💬 Feedback

Your feedback on the tutorial means the world to us! Please, let us know what you think through this short form.

Last updated