Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel2
outlinefalse
typelist
printablefalse

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.

A user does not want to specify more recipe constraints

...

A: OK. Here is a list of recipes that you can choose from. [Alternative: Sorry, there are still too many recipes left to show them all. Please add more preferences.]

...

But what would granting the user’s request mean? The idea is to somewhat lift our previous restriction of only showing pictures of the list of filtered recipes when there are no more than 15 recipes left. The agent can, for example, show the list of filtered recipes if there are a 100 recipes or fewer left when a user indicates they do not want to provide more information. It does not seem reasonable to show many more recipes, as that does not seem to align well with the ambition to develop a conversational first agent. In other words, our agent should not grant the request if the recipe list still is more than a 100 recipes long. The agent can then allow the user to see the list with the pictureGranted response, or deny with pictureNotGranted. If (The exact number, of course, is a bit arbitrary, and it is up to you if you want to argue for changing it.)

We can base the name for the agent intent on our design choice to show more recipe pictures and call the one that grants the user’s request pictureGranted, and the one that denies the request pictureNotGranted. Using these labels, you can implement two versions of the a21noMoreFilters pattern in the patterns.pl file. And don’t forget to add responses for the agent intents pictureGranted and pictureNotGranted to the responses.pl file. This will require you to define two rules each with a different condition on the number of recipes left. Recall that you can use the recipesFiltered/1 predicate to compute a list of the filtered recipes and use that to compute how many recipes are still left after filtering.

There is still one thing missing… Just by talking the agent will not change the page that is displayed. Recall that you have created two pages for the a50recipeSelect pattern for Capability 5: Filter Recipes by Ingredients and Cuisine. When the agent grants the user’s request we still need to make sure that the second recipe recommendation page showing the recipe pictures is displayed. To make that happen, we need to change the condition for showing that page. We need the store the fact that the user requested this. The idea is to use the conversational memory of the agent for that and update it with this information. Therefore, when the agent grants the user's request, the version of that pattern should end with the agent updating its memory using 'an [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'. 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.

Code Block
% 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).

...

actor-intent pair. To change the condition of the page showing in the html.pl file, we can then use the memoryKeyValue/2 predicate defined in the dialog.pl file to add a condition for showing this page.

Finishing the implementation for removing filters

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.

...

  • Start with the text/2 predicate for featureInquiry.

  • 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.

...