...
3. Request a Random Recipe Recommendation
Summary Description
The second capability will enable the agent to recommend a recipe when a user does not care (to refine) what kind of recipe they are looking for (see the example conversational pattern below). A new pattern will be introduced to this purpose for selecting a recipe, and a new intent should be added to your Dialogflow agent to enable understanding user requests for recommending “just some recipe”. Quite some work will need to be done for introducing the first code needed for retrieving recipes from the recipe database. The first versions of two new pages will also need to be created. One page for making clear to the user that they should inform the agent about features of recipes that help refine the selection of recipes and clarify what the user is looking for. Another page for asking a user to (dis)confirm that the recipe that the agent has selected and recommends to the user is what the user is looking for.
Panel | ||
---|---|---|
| ||
A: What recipe would you like to cook? U: Please, just recommend me something. A: What about ___*?
|
Implementation Tasks Overview
Panel |
---|
panelIconId1f4a1panelIcon:bulb:panelIconText💡bgColor#E6FCFF |
Implement a first recipe recommendation pattern and related text responses. |
Panel |
---|
panelIconId1f440panelIcon:eyes:panelIconText👀bgColor#E3FCEF |
Make a page that is displayed while recipe recommendation is ongoing and a page that is shown when the user needs to confirm it likes a recipe that is recommended by the agent. |
Instructions
Select Recipes by Name
Summary Description
Instead of leaving it up to the agent to suggest a recipe and choose one out of all remaining recipes, a user also can mention a specific recipe themselves and ask the agent to present that. This means that the Dialogflow agent should have knowledge of all of the recipes that are in the database too. We will make this available to that agent by adding a recipe entity (type). That will also enable the agent to recognize these recipes in user expressions.
A: What recipe would you like to cook?
U: I'd like to make ____ *.
A: ____* is a great choice!
insert name of a recipe from the recipe database here, such as “artichoke and pine nut pasta”
Implementation Tasks Overview
Panel |
---|
panelIconId1f4a1panelIcon:bulb:panelIconText💡bgColor#E6FCFF |
Implement a second recipe recommendation pattern. |
Panel |
---|
panelIconId1f440panelIcon:eyes:panelIconText👀bgColor#E3FCEF |
- |
Instructions
Tasks Focused on Dialogue Patterns
Implement Recipe Selection Pattern
Define the
a50recipeSelect
pattern inpatterns.pl
with these moves:[agent, specifyGoal]
: Agent asks the user what recipe they want.[user, requestRecommendation]
: User requests a random recipe.[agent, recommend]
: Agent suggests a recipe.
Add
[agent, insert(a50recipeConfirm)]
to direct the agent to the recipe confirmation pattern.
Implement Recipe Confirmation Pattern
Define the
a50recipeConfirm
pattern inpatterns.pl
to allow users to confirm or disconfirm a recipe.
Specify Agent Responses
Add responses in
responses.pl
:text(specifyGoal, "...")
: Agent asks about recipe preferences.text(recommend, "...")
: Agent suggests a random recipe.
...
Tasks Focused on Recipe Filtering
Add Recipes to the Database
Each team member adds one favorite recipe to
recipe_database.pl
, ensuring unique recipe IDs and consistent ingredient names.
Implement Recipe Selection Logic
Add rules in
recipe_selection.pl
:currentRecipe(RecipeID)
: Retrieves the selected recipe from memory.recipeIDs(RecipeIDs)
: Collects all recipe IDs from the database.recipesFiltered(RecipeIDs)
: Filters recipes based on user preferences or constraints.
Update Conversational Memory
Add a rule in
dialog_update.mod2g
to update the memory with the randomly selected recipe when a user requests a recommendation.
...
Tasks Focused on Visual Support
Design Recipe Recommendation Page
Define
page(a50recipeSelect, _, Html)
inhtml.pl
to display:A simple heading asking for user preferences.
A microphone button for user input.
Design Recipe Confirmation Page
Define
page(a50recipeConfirm, _, Html)
inhtml.pl
to display:The recommended recipe name and image.
A microphone button for user confirmation.
...
Tasks Focused on Debugging and Testing
Test Recipe Recommendation
Add
a50recipeSelect
to the agenda indialog_init.mod2g
and verify the agent's ability to:Ask for recipe preferences.
Respond with a random recipe recommendation.
Test Recipe Confirmation
Ensure the agent correctly displays the recommended recipe and allows user confirmation.
Instructions
4. Select Recipes by Name
Summary Description
Instead of leaving it up to the agent to suggest a recipe and choose one out of all remaining recipes, a user also can mention a specific recipe themselves and ask the agent to present that. This means that the Dialogflow agent should have knowledge of all of the recipes that are in the database too. We will make this available to that agent by adding a recipe entity (type). That will also enable the agent to recognize these recipes in user expressions.
Implementation Tasks Overview
Tasks Focused on Dialogue Patterns
Add a New Recipe Request Pattern
Define a variant of the
a50recipeSelect
pattern inpatterns.pl
with these moves:[agent, specifyGoal]
: Agent asks what recipe the user wants to cook.[user, recipeRequest]
: User requests a specific recipe by name.[agent, recipeChoiceReceipt]
: Agent acknowledges the selected recipe.[agent, insert(a50recipeConfirm)]
: Move to the confirmation phase.
Specify the Agent’s Recipe Acknowledgment Response
In
responses.pl
, define a rule fortext(recipeChoiceReceipt, Txt)
to construct the response dynamically.Retrieve the recipe name from memory using
currentRecipe/1
and construct the acknowledgment (e.g., "Artichoke and pine nut pasta is a great choice!") usingstring_concat/3
.
...
Tasks Focused on Visual Support
Update Visuals for Recipe Request
Adjust the recipe recommendation page (
page(a50recipeSelect, _, Html)
) inhtml.pl
to clearly guide users toward selecting a recipe by name.Ensure the page is engaging and displays useful instructions or examples for specifying a recipe.
Support Alternate Input Methods
Uncomment the chatbox code in the
footer/1
predicate inhtml.pl
to allow users to type their recipe request as an alternative to voice input.
...
Tasks Focused on Debugging and Testing
Test Recipe Request Handling
Add the new pattern to the agent’s agenda in
dialog_init.mod2g
after thec10
pattern.Test the interaction flow:
Agent asks for a recipe.
User requests a specific recipe.
Agent acknowledges the recipe choice and moves to the confirmation phase.
Verify Intent Recognition
Check the Dialogflow Training Tool to confirm the
recipeRequest
intent is recognized.Verify the SIC server logs show the correct intent and transcript.
Handle ASR Failures
Use the chatbox feature to avoid ASR failures and ensure the agent can handle specific recipe requests reliably.
Instructions
5. Filter Recipes by Ingredients, Cuisines and Meal Types
Implementing this capability will involve implementing some of the conversational and reasoning competences that a conversational recipe recommendation agent should have. It will enable users to request recipes which use specific ingredient (types) or ask for recipes from a specific cuisine. This one of the capabilities that requires quite a big amount of work. Some of the bigger challenges will be to make Dialogflow understand ingredients (at least those that are in our database; and cuisines, for that matter, but those are fewer), to implement the logic to filter the recipe database with the feature requests of a user, and to present those in a nice way to the user on a webpage.
...