...
...
...
...
...
...
...
...
...
...
confirmation and denying
closing
Visuals
closing page at the end of program
Code Block |
---|
%%% Thank you page at the end.
page(c43, _, Html) :-
% Condition for when to show this page: there is no agenda or session anymore.
currentTopLevel(c43),
% Create the HTML page
html("<center><h1>Thank you for the interaction!</center>", Html). |
Prolog and Patterns
a50 recipe confirmation patterns in patterns.pl
Code Block |
---|
% Pattern a50recipeCheck: present recipe ingredients and instructions for final check before committing to recipe choice.
pattern([a50recipeConfirm, [agent, recipeCheck], [user, confirmation]]).
pattern([a50recipeConfirm, [agent, recipeCheck], [user, appreciation]]).
% % If user does not like recipe, we go back to the recipe selection stage (a50recipeSelect).
pattern([a50recipeConfirm, [agent, recipeCheck], [user, no],
[agent, insert(a50recipeSelect)]]). |
c43 the farewell pattern
...
Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Dialogflow
When a user has added their preferences and chosen a recipe, they land on the recipe confirmation page. On that page, a user can check the recipe details (see Capability 6: Filter by Number of Ingredients & Recipe Steps) and decide whether they would like to cook that recipe or not. You should now enable the user to also indicate their decision to the conversational agent. To make that happen, your Dialogflow agent should be able to recognize whether the user confirms, or disconfirms the choice of recipe. For this, add the following intents, using the intent names as specified below:
confirmation: should be matched when a user expresses agreement, or says “yes” one way or another.
disconfirmation: should be matched when a user expresses disagreement, or simply says “no” in one form or another.
Finally, the agent will close the conversation when a user confirms their choice by saying goodbye. The agent should also allow a user to say farewell. For that, add the following intent:
farewell: should be matched when a user says goodbye in one form or another.
For all of these intents, make sure you try to cover as many ways a user can express confirmation, disconfirmation, or saying goodbye.
Prolog and Patterns
Confirming choice of recipe
After the user selects a recipe, the agent should allow the user to confirm their choice. We foresee two ways this part of the conversation can proceed:
A: Can you confirm ___* is the recipe you would like to cook?
U: Yes. (Alternatively: No.)
A: Great. (Alternatively: That is unfortunate. [Move back to the recipe selection stage])
* insert name of recipe here
After the agent performs a recipeCheck to ask whether the user can confirmthat they would want to cook the recipe shown, a user can do either one of two things: they could provide a confirmation, or a disconfirmation. As appreciation (an intent we added earlier) is very close to confirmation, we also want to take that as a yes (i.e., if a user expresses appreciation in the conversational context of the recipe confirmation pattern a50recipeConfirm
, we also want the agent to proceed as if the user has expressed their confirmation). You should add these three different variants of the a50recipeConfirm
pattern to the patterns.pl
file. One thing to consider here is what should happen when this pattern is completed. After completing, when the user confirms, the conversation should move on to a closing (see below). However, when the user says they do not like the recipe, we do not want that! Instead, we want the conversation to go back to the conversational context of the a50recipeSelect
pattern. Think about how you can make that work!
Finally, don’t forget to add agent response to the responses.pl
file for the recipeCheck
intent!
Saying farewell
Add a pattern that models the following conversational closing pattern. In Moore and Arar’s taxonomy, this is a C4.3: Closing Farewell (Agent)
% Examplepattern. In its most basic form, it goes like this:%
A: goodbye.
...
U: bye.
% Instruction:
% 1. Introduce an intent 'farewell' Introduce a farewell intent for saying goodbye by adding this intent to your Dialogflow
% agent (for user recognition) and the textagent, and also add this intent to the responses.pl file ( for generating an agent text generation).
% 2. Add a pattern here where the agent initiates (i.e. starts) saying goodbye and then the user is
% allowed to say goodbye.
% 3. Add a rule in the dialog generation module in the right place to update the session by adding
% the c43 pattern you introduced in step 2.
pattern([c43, [agent, farewell], [user, farewell]]).
responses.pl add
% Intent: recipeCheck
text(recipeCheck, "Can you check the recipe and let me know if you want to cook this?").
% Intent: farewell
text(farewell, "bye").
Extend
last topic check, restart
%%% C4 Patterns: Closing
% Pattern C4.0: Last Topic Check (Agent)
% Example 1:
% A: is there anything else I can help you with?
% U: bye
% A: goodbye
% Example 2:
% A: is there anything else I can help you with?
% U: yes
% A: okay!
% Example 3:
% A: is there anything else I can help you with?
% U: i don't think so
% A: have a good day!
% U: goodbye
% A: bye
% Instruction:
% 1. Introduce intents for 'lastTopicCheck', 'acknowledgement', and a 'wellWish' for the agent (i.e.
% add these to the text.pl file) and the intents 'confirmation' and 'disconfirmation' for the
% user (i.e. add these to your Dialogflow agent). Re-use the 'farewell' intent.
% 2. Add three variants of the last topic check pattern, each with the same c40 pattern id, that
% match the three examples above. For the second variant, use the special agent management
% instruction 'restart' as an intent the agent should perform at the end of the pattern
% variant. You do not need to do anything else than use this intent as it has already been
% implemented for you (see the dialog generation module).
% 3. Add a rule in the dialog generation module in the right place to update the session by adding
% the c40 pattern you introduced in step 2.
% pattern variant 1 (farewell):
pattern([c40, [agent, sessionCloser], [agent, farewell]]).
% pattern variant 2 (confirmation):
% use of special instruction 'restart' to reset agenda to initial agenda at start of session.
%pattern([c40, [agent, lastTopicCheck], [user, confirmation], [agent, acknowledgement],
% [agent, restart]]).
% pattern variant 3 (disconfirmation):
%pattern([c40, [agent, lastTopicCheck], [user, disconfirmation], [agent, wellWish],
% [user, farewell], [agent, farewell]]).
Test it Out
add c43 to agent agenda in dialog_init file
run agent all the way thru from greeting to closing
Return to response. Again, there are many different ways of saying goodbye, and many places where you can find inspiration for how you want your agent to say goodbye, e.g. here, or ask ChatGPT for help to shape your agent’s farewell message. Also, add a c43
pattern to the patterns.pl
file.
Finally, add a last topic check to your farewell pattern to see if the user wants anything else or wishes to find another recipe. If they indicate they want that, restart the entire conversation. You can do this by using the special action restart
. Check out how this action is processed in the dialog_update.mod2g
file to better understand what it does. Add [agent, restart]
to the pattern when a user confirms they want to restart; this resets the agent's agenda to the initial agenda it started with at the start of conversation.
Visuals
You should create one more page to match the top level intent c43
. Add a closing page at the end of the program to bid farewell and thank the user in the html.pl
file.
Code Block |
---|
%%% Thank you page at the end.
page(c43, _, Html) :- |
The main requirement for this page is that it should make clear to the user that they can continue finding recipes they like, if they want.
Test it Out
Before you start testing, add the c43
to the agent’s agenda in the dialog_init,mod2g
file. Why do we not need to add the a50recipeConfirm
pattern to the agenda?
Now you should be able to Run your Conversational Agent and talk your way through from an initial greeting to the closing part of a recipe recommendation conversation.
Info |
---|
All done? Proceed with https://socialrobotics.atlassian.net/wiki/spaces/PM2/pages/2216001572/ |