Dialogflow
deleteFilterValue
‘deleteFilterValue’ is useful to deal with a scenario where the user requests to remove a filter that they have added beforehand. For example, “I wish to remove the onion filter”, “Forget about excluding broccoli”, and “Can you delete the Chinese cuisine”. Add some training phrases for all the different filters that user could want to delete.
It is important that you include all filter-related entities in your training phrases, and that these entities are also given specific values and parameter names in the Action and Parameters tables. These entities are given new parameters and value names in order to identify them as a filter to be deleted. Specifically, you tag the entity in your training phrases as normal (e.g. “ingredient”) and then you change the parameter name and value name to “entitynameDel”. Your entity table under Action and Parameters should look like this when you are done.
The noMoreFilters intent is used when the user does not want to add any other filters to their recipes list and wishes to see the available recipes.
Prolog and Patterns
User does not want to specify more recipe constraints
Example:
A: “What other filters would you like to add?”
U: “I do not want more filters.“
A: “Ok. Here is a list of recipes.” / “Sorry the list is still too long to show.”
a21noMoreFilters pattern handles a user request to not add more feature requests, preferences, or requirements. When filtering the recipes, the user is not shown the list of filtered recipes until there are only 15 (or fewer) recipes. It could be, though, that the user does not wish to filter recipes further. The user would then use the NoMoreFilters intent. The agent can then allow the user to see the list with the pictureGranted
response, or deny with pictureNotGranted
. If the agent grants the user's request, the pattern should end with the agent updating its memory using '[agent, update(['show'='true'])]'. This triggers the showing of recipes by updating the agent's memory.
In responses.pl
we have to make two rules, for 'grantPicture' and 'pictureNotGranted'. An agent can allow the list of recipe pictures to be shown if the list is less than 100 recipes long. An agent cannot grant the recipes if the list is over 99 recipes long. The recipesFiltered/1
predicate provides a list of the filtered recipes. Fill in the two rules with the corresponding conditions.
Implement the a21noMoreFilters
pattern in the patterns.pl
file.
Add this predicate to the responses.pl
file in the indicated spot.
% used in a21removeKeyFromMemory for handling deleteParameter. text(removedSpecificFilter(DelFilter), Txt) :- convert_to_string(DelFilter, Str1), string_concat("I removed the ", Str1, Str2), string_concat(Str2, " requirement.", Txt).
featureInquiry intent
Multiple text predicates take the argument feature inquiry in responses.pl
. Each feature inquiry response is different based on how many recipes there are left to filter.
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 be triggered when the length of the list of recipes is greater than 890.
Start with the
text/2
predicate, where the first argument isfeatureInquiry
.The second argument will be the response text "What kind of recipe would you like?".
Use the
recipesFiltered/1
predicate to get the list of recipes.Use the
length/2
predicate to determine the number of recipes.Set a condition that the length
L
must be greater than 890.
Second Rule for a Moderate Number of Recipes
If there's a moderate number of recipes (more than 15 but fewer than 891), we ask the user to add more preferences unless a certain memory key-value pair is set.
Repeat the initial steps of the first rule.
The response text will change to "What other preference would you like to add?".
Set the length condition to be less than 891 and greater than 15.
Include a condition using
not/1
to check that the memory does not have the key-value pair'show', 'true'
.
Third Rule for No Recipes
If there are no recipes after filtering, we want to inform the user to remove some requirements.
Use the
recipesFiltered/1
predicate again.The response text will be "There are no recipes, please remove more requirements.".
Check that the length
L
is equal to 0 usingL=0
.
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 the number.
Start with the
text/2
predicate forfeatureInquiry
.The response text will be "Here are some recipes that fit your requirements.".
Use the
recipesFiltered/1
predicate to get the filtered list.Create a condition that checks if the length
L
is less than 16 but more than 0, or if the memory key-value pair'show', 'true'
exists. This condition is composed of two parts joined by a semicolon;
, representing a logical OR.
Visuals
What you do visually for this capability is up to you.
Test it Out
Now Run your Conversational Agent again and try to remove some of the recipe constraints after you added them.