To restrict when a state is used based on particular rules (mandatory/forbidden words, opening hours, previously visited states) use Necessary Conditions to make sure the chatbot only answers this way when you want it answered this way.
Necessary conditions help the chatbot AI to determine if a certain state should be used in an answer or not.
Let's say somebody is having a conversation with your chatbot about your store and they ask you if your store is open. You could have two states to answer this question:
- We are currently open until 17:00 today. Feel free to drop by!
- We're closed at the moment. Our opening hours are Mon-Fri, 08:00-17:00.
For the AI, these two states might trigger very similar probability matches based on the language used by your customer. A Necessary Condition state will allow the AI to pick one right answer with certainty.
The Math: How State Matching Works
When the chatbot AI examines your customer question with all the example questions or keywords across states, it assigns a match score to each and picks the highest score, provided it is above a certain number.
The above two states in the example would have match scores between 90-100% when the customer asks the question "When are you open?".
A necessary condition will differentiate which answer to use for the customer. It works like a multiplier.
If the customer asks the question during the day; while both questions get a 90% match score, only the first one should be used to answer the customer.
- The first state is multiplied by 1 during opening hours (90 x 1 = 90)
- The second state is multiplied by 0 during opening hours (90 x 0 = 0)
You can put a Necessary Condition on the first state to say it should only be used during Opening Hours, and the second, only when outside of Opening Hours.