Use Necessary Conditions to define rules for when an intent can trigger. This might include checking the customer's query for specific words, checking against opening hours, or reviewing previously visited intents.
Matching intents
When a customer types a query into the chatbot, the chatbot AI breaks the question into components, and matches them against the questions it has been trained on. Each intent is given a match score, based on how well it matches with the customer's question. The intent with the highest match score will be triggered, and the customer will see the reply for that intent.
If none of the intents reach a minimum match score threshold, the chatbot will instead use a fallback intent. See Different intent types.
The effect of necessary conditions
If you attach a necessary conditions to an intent:
- If the condition is met, the match score is generated normally.
- If the condition is not met, the match score for that intent is set to zero.
This means that if the condition is not met, that intent can never be triggered.
Necessary conditions in action
To help see how necessary conditions can help you, let's look at some examples.
Opening hours
Consider the customer query "Are you open?". You may want to use one of the following replies, depending on the day and time:
- We are open until 17:00 today. Feel free to drop by!
- We're closed at the moment. Our opening hours are Mon-Fri, 09:00-17:00.
To handle this you can create two different intents. Both would use the same query and query variants, potentially generating identical match scores.
- To the intent that replies you are open, add the necessary condition Opening Hours.
- To the intent that replies you are closed, add the necessary condition Not Opening Hours.
Now, if the customer asks this question at the weekend, when you are closed, the match score on the first intent is set to zero. and it is the second intent which triggers. The customer will receive the reply that you are closed.
If the customer asks the question at midday on a Thursday, the match score of the second intent is set to zero, and the customer will receive the reply inviting them to drop by.
For more on this example, and how to define what your opening hours are, see the article Giving different responses outside opening hours.
Visited intents
Perhaps you have an intent which prompts the customer to sign up for a newsletter. This is something you want to recommend to customers using your chatbot, but probably not more than once in any conversation.
Use the necessary condition Has Not Visited Intent to check that the customer has not already seen the intent which prompts them about the newsletter.