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.

What will be built in Leadzy lesson 2.

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.

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.

Create an intent

To create an intent:

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

The Intents tab is empty.
  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.

Create a new yes intent and give it a description.
  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.

The yes intent has 0 expressions in 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

Manually add expressions to your intent.
  1. If you would like AI to generate expressions for you:

    • click the stars button next to the text field.

Generate new expressions using AI.
  • 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.

Add AI-generated expressions to your intent.

The added expressions appear now as a list underneath your intent.

The yes intent contains 6 expressions.

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.

Add the yes intent to your canvas.

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.

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:

The yes intent triggers the Yes to discount block.

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!

Test your flow if you say yes to a discount.
  1. Click on the Restart conversation icon at the top right corner of the Test window.

Restart the test conversation.
  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:

Test your bot with an expression that wasn't in your intent.

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.

Train your NLP by clicking the button on the top right corner of your Intent tab.
  1. A window pops up. Select English as the language that you want to train.

  2. Click on Update.

Select the language to train your NLP on.

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.

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!

Test your flow with an expression which isn't part of your set of expressions.

[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:

The no intent triggers the No to discount block.

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 protected].

  3. Save your changes.

It should look like so on your canvas:

When the user says something that the bot doesn't understand, the Not understood block gets triggered.

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.

3. Collect and display user input

💬 Feedback

Last updated

Was this helpful?