Combine match requirements

Sometimes our trigger may appear too generous. For example, consider the two different user inputs below, which both trigger the first flow created in our Longberry Baristas, User asks about coffees we offer, even though only the first one should:

User: Which coffees do you serve?
Bot: We offer a variety of handcrafted coffee drinks - from espressos to macchiatos to flat whites and more.

User: Which teas do you serve?
Bot: We offer a variety of handcrafted coffee drinks - from espressos to macchiatos to flat whites and more.

What we need to do is to restrict the trigger from triggering too generously, so that the second input goes to another flow or to the Safetynet fallback flow instead:

User: Which teas do you serve?
Bot: I'm sorry but I didn't get that.

We will restrict the 'User asks about coffees we offer' flow from over-triggering by combining match requirements in addition to the class match requirement in the trigger. This way, we can impose hand-picked restrictions on the Class Match Requirement. For example, we can restrict it to only trigger if certain words like 'coffee' or 'drink' are present in the input.

To accomplish this, we will need to do the following:

  • Add a Condition Match Requirement to the trigger
  • Create a condition
  • Add a confidence threshold

Once we're done, the final flow will look like this:

Final flow with hybrid trigger

Add a Condition Match Requirement

We will start off by doing the following,

  1. Open the 'User asks about coffees we offer' flow that we created earlier in edit mode.
  2. Select the Trigger 'Tell me about your coffee', which will open up the configuration panel to the right.
  3. Scroll down to the 'Match Requirements' section and press 'Add' followed up with 'Condition'.
  4. Go ahead and name the Condition to Restrict to only coffees and drinks in order to more easily keep track of what the condition does.
  5. Paste in the following condition (%COFFEE.NN.SYN/%DRINK.NN.LEX).

Add a confidence threshold

We will now add a confidence threshold to the trigger to ensure that it is only triggered when the machine learning algorithm is sufficiently confident.

  1. Select the 'Tell me about your coffee' trigger.
  2. In the 'Match Requirements' section, click on 'Add' followed up with 'Context Restrictions'. This will allow you to add Context to your trigger.
  3. Add the context 'Class Confidence Medium' from the drop-down menu.

Try it out!

Now, go to Try Out and give it a try! You should now get a similar answer as below. As long as you do not get the 'We offer a variety of handcrafted coffee drinks...' answer when asking for tea, you have succeeded!

User: Which coffees do you serve?
Bot: We offer a variety of handcrafted coffee drinks - from espressos to macchiatos to flat whites and more.

User: Which teas do you serve?
Bot: I'm sorry but I didn't get that.

What is next?

Next in line is the Localize a bot page.

Was this page helpful?