Create a hybrid trigger

Sometimes your class trigger may appear too generous. For example, consider the two different user inputs below, which both trigger the 'User asks about coffees we offer' flow, 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 class trigger from too generously triggering, so that the second input goes to another flow or to the safety net 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 using a hybrid trigger in addition to the class trigger. This way, we can impose hand-picked restrictions on the class trigger. For example, we can restrict it to only trigger if certain words like 'coffee' or 'drink' are present in the input. In the following, we will:

  • add a syntax trigger
  • make it a hybrid trigger
  • disable the class trigger
  • add a confidence threshold
  • assign the correct order group

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

Final flow with hybrid trigger

Add a syntax trigger

Open the 'User asks about coffees we offer' flow that we created earlier in edit mode. Then:

  1. In the top ribbon section called 'Add Flow Trigger', select 'Syntax'.
  2. Call the syntax trigger Restrict to only coffees and drinks.
  3. Copy the following examples to your clipboard and then paste them with Ctrl + V into the 'Positive' tab of the 'Examples' panel on the right:
    What kind of coffee do you have?
    Do you have brewed coffee
    Do you serve macchiato
    Do you have cappuchino
    Tell me about the coffees you have
    Tell me about your coffee
    What coffee do you serve?
    What kinds of coffees do you serve?
    What kinds of drinks do you sell
    Which coffees are offered by Longberry Baristas?
    Which drinks do you have?
    Which sorts of coffees do you have
  4. Now select the class trigger 'What kinds of coffee do you have?' and open its 'Learning Examples' panel on the right.
  5. In the 'Linked Trigger' section click on the 'Link Trigger' button and select the 'Restrict to only coffees and drinks' trigger from the drop-down menu.
  6. The triggers are now linked. In order to avoid duplicate examples, we have to delete the positive learning examples from the class trigger. Select them all and click on the little red cross to delete them.

Make it a hybrid trigger

We have so far added a syntax trigger and linked it to the class trigger. In order to make it a hybrid trigger, we will now use the class trigger's intent as part of the condition in the syntax trigger.

Explanation of hybrid trigger condition

In order to put this in place you have to:

  1. Select the condition field of the syntax trigger 'Restrict to only coffees and drinks'.
  2. Paste %$WHAT_KIND_OF_COFFEE_DO_YOU_HAVE?.TOP_INTENT &^ (%COFFEE.NN.SYN/%DRINK.NN.LEX).

Disable the class trigger

Whenever there is a syntax trigger in a flow, Teneo will first evaluate the syntax trigger. If that doesn't match it will continue evaluating other triggers and find the matching class trigger. To prevent that from happening, we need to disable the class trigger. As we have included the intent of the class trigger in the hybrid trigger, we may now disable the class trigger without any harm:

  1. Select the class trigger 'What kinds of coffee do you have?'.
  2. Open the 'Learning Examples' panel on the right.
  3. In its 'Context Restrictions' section, add the context restriction 'Disable Trigger' from the drop-down menu.

The 'Disable Trigger' context restriction comes with the Teneo Dialogue Resource template solution that you used when you created the solution.

Add a confidence threshold

We will now add a confidence threshold to the hybrid trigger in order to make sure that it is triggered only in cases where the machine learning is sure that this is the right intent to go about.

  1. Select the hybrid 'Restrict to only coffees and drinks' trigger.
  2. In the 'Examples' panel to the right, go to the 'Context Restrictions' section.
  3. Add the context 'Class Confidence Medium' from the drop-down menu.

Assign the correct order group

Finally, we have to make sure that the new hybrid trigger is in the correct order group. It shall now have a higher priority than a pure class trigger, but a lower priority as a pure syntax trigger. Luckily, there is a pre-defined order group for exactly that:

  1. Select the hybrid trigger 'Restrict to only coffees and drinks'.
  2. In its 'Examples' panel on the right, go to the 'Order group' section. By default, you can see that the 'Syntax Triggers' order group is pre-selected.
  3. Now click on the drop-down menu and select 'Hybrid Triggers'.
  4. Hit 'Save'.

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, you have succeeded!

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

Was this page helpful?