Contextual entities

Contextual entities are detected in the context of a specific expression.

Contextual entities tab.

Detect contextualized information

Contextual are recognized inside of expressions. The NLP understands the entity by learning which type of word it is, where it's located in the sentence, and what the specific context around it is.

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 is the price of apples?

  • How much does an apple cost?

  • What is the price of the apples?

Of course, these expressions could be asked for not just apples, but also pears, bananas, and pineapples. 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

In this case, we recommend to turn on fuzzy matching so that the bot will also recognise 'apples' and the plural of the other fruits. More info on fuzzy matching in the next section.

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

  • How much is the price of @fruit?

  • 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!

Example of an intent that uses the @bike_model contextual entity.

Contextual entities are the only type of entities that can (and should be) added to an expression itself, for example: I want to book a train ticket from @origin to @destination.

Note that match entities are context-independent, meaning that they can be detected at any place in the conversation. Therefore, they are very different from contextual entities which are context-dependent and can be detected only at certain places inside the conversation.

Add contextual entities

There are 2 ways to add contextual entities to your bot:

To add a contextual entity:

  1. From the Entities tab, click on Add contextual entity.

  2. Give it a Name and a series of Entity values.

  3. You can give Synonyms to those valuesif you want to.

Synonyms for contextual entities

For each value, you can add a synonym that will be detected as the original value. Synonyms allow you to add alternatives to entities that are assigned to the same value.

For example:

I want to go to Brussels

I want to go to Bruxelles

The meaning of the two expressions above is exactly the same, but you want to convert Bruxelles to Brussels so your bot can work with one and the same value.

Note that entities are case insensitive, so there's no need to add capitalized synonyms.

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.

  1. You can toggle on the Fuzzy matching if you want to.

Fuzzy matching for contextual entities

Fuzzy matching allows you to recognise a slight variation of an entity value (or its synonym) as the original value. For example "Brusselt" will be automatically corrected to "Brussels" if fuzzy matching is enabled.

Fuzzy matching is quite strict. Less than 20% of the characters are allowed to be different in order to link it to another entity. This is to avoid that the value is linked to another entity which also has overlap.

Add a contextual entity.

Last updated