Reputation: 1420
I have 2 top level intents and each having followup intents. They are as follows:
Order tea
-- Which tea flavour
---- Amount of sugar
------ Say tea served
Order coffee
-- Which coffee flavour
--- Amount of sugar
---- Hot or cold?
------ If hot, say hot coffee, caution.
------ If cold, say cold coffee, enjoy.
Now in happy path, one after another intent gets triggered and I can achieve the flow using the followup intents. But I want to know how can we stop the below flow:
Order Tea
-- [Prompt] Which tea flavour
-- [User] Darjeeling
---- [Prompt] Amount of sugar?
---- [User] Order coffee
-- [Prompt] Which coffee flavour
In this flow, the coffee intent gets triggered. Is there any way to ensure that while the tea intent is being processed, until it is completed or cancelled, no other intent like coffee will get invoked or addressed. If user says something like order coffee
while order tea
is being processed, it would say something like, I did not get that
.
Upvotes: 0
Views: 293
Reputation: 3271
There isn't really a solution for this issue that doesn't involve a lot of extra work. Top level intents are meant to always be available for the user during the conversation, this is why you are able to trigger the Order Coffee
intent while in the Order Tea
flow.
As AlphaOne mentioned in the comments, one way to work around this is by adding fallback intents, but because Dialogflow understand the input, a standard fallback wouldn't work. If you want to prevent any Order Coffee
commands to work, you have to add all those commands to the fallback intent. Depending on the amount of steps that you have, this could become very hard to maintain if you add a fallback for each step with every phrase of the Order Coffee
intent.
The best option for this would be to add a Ordering_Tea
context as an output context of the Order Tea
intent, this will indicate that you are ordering tea. Then create a fallback intent that has Ordering_Tea
as an input context. As long as the Ordering_Tea
context is active, this fallback intent should be available. So to stop Order Coffee
commands from triggering, you need to add all phrases that trigger the Order Coffee
intent into the Ordering_Tea
fallback.
This way you have 1 fallback intent that prevents the triggering of Order Coffee
instead of 1 fallback for each step. All you have to do is add an Ordering_Tea
output context to each Order Tea
step and remove it once the user has ordered their tea.
Upvotes: 1