cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Contextual entities are used to detect entities in user expressions by using the context of the sentence of that expression.

 

For example, in the expression:

I want to book a train from Brussels to Amsterdam.

The two city names mentioned here will be recognized as either @departure or @destination because of the context of the expression they're in.

 

When to use contextual entities

Imagine you're a fruit seller who sells apples, pears, bananas and pineapples. Your chatbot can help people order fruit and ask for the price. Let's look at that pricing use case for apples. Some example expressions could be:

  • How much does an apple cost?
  • What is the price of an apple?

Of course, these expressions could be asked for not just apples, but also for other fruits. Does that mean you have to copy each expression and replace the fruit? No, you can just use contextual entities! Create a contextual entity called 'fruit' and add the following values to it:

  • apple
  • banana
  • pear
  • pineapple

Now you can simply create an expression with the contextual entity in it:

  • How much does an @fruit cost?
  • What is the price of the @fruit?

Now your bot will understand each expression, even if the fruit changes!

 

When adding contextual entity variables, there's no need to add capitalised and non-capitalised words. All text is decapitalized by the NLP before any recognition happens, so 'api' won't be recognised differently from 'API'

 

Fuzzy matching

Fuzzy matching allows you to recognise a slight variation of an contextual entity value (or its synonym) as the original value.

 

For example Brusselt will be automatically corrected to Brussels if fuzzy matching is enabled.

 

Create a contextual entity

Let's see how we can use a contextual entity to determine the type of pizza that your customer is ordering.

 

To create a contextual entity:

  1. Go to the Entities page and click on Contextual Entities.
  2. To add new entity, click Add contextual entity.
  3. Give a name to your entity. When naming your entity, please do not use spaces. Fill the entity values with pizza types and you can also add synonyms for each value so the bot can understand if your customers say it in a different way.

 

Screenshot 2023-11-25 at 11.38.04.png

4. Click Create entity.

 

Add contextuel entities to intents

To add contextual entities in intents training expressions:

  1. Add a new intent to your bot. For this example, call it ‘Order pizza’.
  2. For this example let's assume that you already created a @pizza_type contextual entity. Add expressions with this entity you just created by typing '@' and a dropdown will appear, where you can find your created entity '@pizza_type'.

 

Screenshot 2023-11-25 at 11.45.05.png

3. To improve the bot's understanding of the "order pizza" intent, you need to add or generate additional expressions using the @pizza entity. The more expressions you add, the better the bot will perform.

 

Screenshot 2023-11-25 at 11.46.46.png

 4. After adding enough expressions, do not forget to train your bot so it can learn the latest changes that you have just made.

 

Screenshot 2023-11-25 at 11.48.03.png

 

4. Connect your intent to your flow.

5. Test your bot.

Screenshot 2023-11-25 at 12.12.12.png

 

 

See also:

[New bot builder] Detect entities in expressions

[New bot builder] Recognize expressions with intents

[New bot builder] Add an intent to your bot

 

Version history
Last update:
‎01-02-2024 04:23 AM
Updated by: