Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Dialogflow
Removing feature requests again
...
Recall that we used the agent intent ackFilter to implement the first move in this fragment as part of the a21featureRequest
pattern. If a user complies with the agent’s request, that would trigger another a21featureRequest
pattern. If a user does not comply but rather responds negatively, we can also view that as a disconfirmation move. We argue that we can reuse that intent to capture negative responses to the agent’s request. A user, for that matter, could also simply respond to the agent’s move by saying “No, I won’t” or something similar. We implemented this intent before, but we should extend it to now also cover the variety of user expressions a user could use to say they do not want to add anything else. So, you should add training phrases to make sure these expressions are covered too.
Prolog and Patterns
We will begin with implementing a pattern for allowing a user to express they are done, and then get back to what is still missing to implement requests to remove a filter.
...
Finishing the implementation for removing filters
Multiple text predicates take the argument feature inquiry in responses.pl
. Each feature inquiry response is Most of the work that needs to be done to remove filters again has already been done. Various patterns implementing the a21removeKeyFromMemory
have already been included in the patterns.pl
file (check them out to better understand the variants added for this pattern). The specification of the agent response featureInquiry
used in several of these variants, however, is still missing It is up to you to add these in the responses.pl
file. The idea is to define four different types of these responses. Each of these feature inquiry responses should be different based on how many recipes there are still left to filter.after applying all the filters, and will require you to define the conditions for when a response is available:
First Rule for Large Number of Recipes
We want to prompt the user for more specific preferences if there are too many recipes . The rule will left. This version of the response should be triggered when the length of the list of recipes is still large (say greater than 890.800):
Start with the
text/2
predicate, where the first argument isfeatureInquiry
.The For the second argument will be the you can use a response text such as "What kind of recipe would you like?".
Use the
recipesFiltered/1
predicate to get the list of recipes.Use , thelength/2
predicate to determine the number of recipes.Set , and add a condition that the lengthL
must be greater than 890800.
Second Rule for a Moderate Number of Recipes
If there's a moderate number of recipes left (more than 15 but fewer than 891less than or equal to 800), we ask the user to add more preferences unless a certain the memory key-value pair is set.
...
Repeat the initial steps of the first rule.
...
to show recipes has been set (see above):
Use a response text similar to e.g. "What other preference would you like to add?".
Set the length Add a condition to be less than 891 and greater than 15.Include a condition using
not/1
check that more than 15 but less than 800 recipes are left.Also include a condition to check that the memory does not have the key-value pair
'show', 'true'
.
Third Rule for No Recipes
If there are no recipes left after filtering, we want to inform the user to remove some
...
feature requests.
Use the
recipesFiltered/1
predicate again.The a response text will be similar to "There are no recipes, please remove more requirements.".Check that the length
L
is equal to 0 usingL=0
Use therecipesFiltered/1
predicate again to check that no recipes are left.
Fourth Rule for a Small Number of Recipes or a Show Command
This rule handles two scenarios: either there's a small number of recipes, or the user has explicitly asked to show the recipes despite even when the number .
...
Start with the text/2
predicate for featureInquiry
.
...
is greater than 15.
Use a response text similar to "Here are some recipes that fit your requirements.".
Use the
recipesFiltered/1
predicate to get the filtered list.Create a condition that checks if , and check that the lengthL
is less than 16 but more than 0, or if (use a semicolon;
which represents a logical OR) check that the memory key-value pair '‘show', 'true'
exists. This condition is composed of two parts joined by a semicolon;
, representing a logical OR. is stored in the agent’s conversational memory.
This completes the implementation of all the different cases for the agent’s response. The patterns for removing filters should now work!
Visuals
What you do visually for this capability is up to you.
...