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.
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:
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:
Now you can simply create an expression with the contextual entity in it:
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 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.
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:
4. Click Create entity.
To add contextual entities in intents training expressions:
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.
4. After adding enough expressions, do not forget to train your bot so it can learn the latest changes that you have just made.
4. Connect your intent to your flow.
5. Test your bot.
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