Dialogflow
fallback intent stuff
capability check
thank you apprreciation
Visuals
-
Prolog and Patterns
in patterns.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Sequence Management Patterns (Moore Ch6) %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% B1 Patterns: Repair (Agent)
% Pattern B1.2: Paraphrase Request (Agent)
% Example:
% U: chicken soup
% A: what do you mean?
% Instruction:
% 1. Introduce a 'paraphraseRequest' intent for the agent.
% 2. Add a b12 pattern using the defaultFallback and paraphraseRequest intent.
pattern([b12, [user, defaultFallback], [agent, paraphraseRequest]]).
% Pattern B1.3: Out of context dialog move
% For handling intents that are recognized but not expected nor first intent of a pattern.
% Example:
% A: what recipe would you like to cook?
% U: next step
% A: not sure what that means in this context.
% Instruction:
% 1. Add a b13 pattern using the Prolog don't care symbol (_) for the user intent and the given
% contextMismatch agent intent to respond to the user intent. Make sure to give this pattern
% the pattern id b13!!
% 2. Note that by using the don't care symbol any intent recognised will match with the first intent
% in this pattern. This requires careful handling of this pattern by the dialog engine! The
% dialog engine has already been prepared to handle this special case for you.
pattern([b13, [user, _], [agent, contextMismatch]]).
% Looks like user has repeated themselves.
pattern([b14, [user, _], [agent, repeatedUserIntent]]).
%%% B4: Sequence Closers
% Pattern B4.2: Sequence Closer Appreciation (helped)
% Example:
% U: thanks
% A: you're welcome.
pattern([b42, [user, appreciation], [agent, appreciationReceipt]]).
Code Block |
---|
%%% C3 Patterns: Capabilities
% Pattern C3.0: General Capability Check
% Example:
% U: what can you do?
% A: At the moment I can converse with you about nothing in particular. I do know how to make
% a tasty pasta, risotto, <recipe2shorthand>, <recipe3shorthand>, however, if you are
% interested.
% Instruction:
% 1. Introduce the intents 'checkCapability' (for the user) and 'describeCapability' (for the
% agent). Introduce some Prolog code to concatenate the shorthand names for all the recipes
% that you introduced (retrieve these using the recipes/1 predicate, see cooking.pl) and add
% this code to the text.pl file to specify the correct capability description for your agent.
% 2. Add a pattern here where the user initiates the pattern by checking for the agent's capability
% with the agent then responding to the request by describing its capabilities.
pattern([c30, [user, checkCapability], [agent, describeCapability]]).
|
responses.pl
text(contextMismatch, "I wasn't able to understand that.").
% Intent: paraphrase request
text(c11, paraphraseRequest, "Ok."). % we don't care exactly what user said. we got some response.
text(a50recipeSelect, paraphraseRequest, "I did not understand anything I could make sense of.") :-
recipesFiltered(Recipes), length(Recipes, L), L>0.
text(a50recipeSelect, paraphraseRequest, "I didn't get that.") :-
recipesFiltered(Recipes), length(Recipes, L), L=0.
text(a50recipeConfirm, paraphraseRequest, "I didn't understand that.").
text(c43, paraphraseRequest, "Ok.").
text(c10, paraphraseRequest, "Ok.").
text(instruction1, paraphraseRequest, "Ok").
text(instruction2, paraphraseRequest, "Ok").
text(instruction3, paraphraseRequest, "Ok").
text(ownInstruction, paraphraseRequest, "Ok").
text(start, paraphraseRequest, "Ok").
text(a50performanceRating, paraphraseRequest, "I didn't understand anything I could make sense of.").
% repeatedUserIntent
text(repeatedUserIntent, "Yes I got that.").
% Intent: appreciation receipt
text(appreciationReceipt, "You're welcome.").
% Intent: describeCapability
text(describeCapability, "I can help you find a recipe to your liking, as I can filter my recipe database based on your specific preferences.").
Extend
Test it Out
Say random stuff Add the following intents, following the same procedure as you did for the ‘greeting’ intent. Use the intent names as specified below:
appreciation
If a user expresses appreciation or gratitude, for example, ‘thanks’.
checkCapability
the intent that represents a user querying what your agent can do. An example phrase would be “What can you do?”.
Fallback Intent
The Default Fallback Intent is one of the more important intents. It is already available when you create your Dialogflow agent. A fallback intent is triggered if a user's input is not matched by any of the other intents known by the agent, or if it matches the training phrases you input for this intent.
It is not necessary to add phrases that are completely unrelated to the topic of our recipe recommendation agent, as these would come back as an unknown intent. Thus, what you should do is think of related phrases that would be close to an intent but should not match with it. For example, “I do not like mushrooms” is food related and refers to an ingredient entity ‘mushroom’. Yet, you might argue that it should not be matched to any of the intents you specify because you do not want users to discuss their likes and dislikes with your agent. Alternatively, you could also argue to include ‘I like’ and ‘I dislike’ as training phrases for filtering by something. But that is a design decision for you to make! The Fallback Intent should be updated as you add more intents throughout the project.
Visuals
No updates.
Prolog and Patterns
B Patterns for Repair and Conversation Enrichment
A good handling of repair is vital to making your agent robust to misunderstanding. There are a few common ways in which misunderstanding occurs, that need to be addressed by proper repair patterns.
b12 The agent does not understand the user's’s utterance
Example:
U: chicken soup
A: what do you mean?
Your user has just said something odd or does not match the current situation and so your Dialogflow cannot identify the user's intention and goes to a default fallback intent. In this pattern, your agent can try to come to an understanding by asking for a rephrasing with ‘paraphraseRequest’. Add a b12 pattern using the defaultFallback intent and paraphraseRequest response.
In responses.pl: paraphrase requests are determined depending on the context of the conversation (the pattern that is currently active). Under the paraphrase request section in responses.pl, you should create ‘text/3’, which specifies the active pattern, the agent response name, and what the agent should say. Fill all these in.
Code Block |
---|
% Intent: paraphrase request
text(c10, paraphraseRequest, ""). % we don't care exactly what user said.
we got some response.
text(a50recipeSelect, paraphraseRequest, " ") :- % this should be used
if the number of filtered recipes is greater than 0
text(a50recipeSelect, paraphraseRequest, " ") :- % this should be used
if the number of filtered recipes is 0
text(a50recipeConfirm, paraphraseRequest, "").
text(c43, paraphraseRequest, ""). |
b13 Out of Context.
The user said something that Dialogflow can identify with the user’s intent, but your agent is not at a stage where that intent is appropriate.
Example:
A: what recipe would you like to cook?
U: goodbye
A: not sure what that means in this context.
Think about what feature in Prolog you could use to symbolize that there is some intent identified, regardless of what particular intent it is. The agent should respond with a ‘contextMismatch’ response.
Make a contextMismatch response in response.pl.
b42 Appreciation
Example:
U: Thanks
A: You're welcome.
Your user says thank you and shows some ‘appreciation’ and your agent should respond appropriately with an ‘appreciationReceipt’.
In patterns.pl specify the B42 pattern. Furthermore, go into responses.pl and create a corresponding text fact.
C pattern for Checking Capabilities
c30 General Capability Check
Your user wants to know what your agent does. Create a pattern for this.
Example:
U: what can you do?
A: At the moment I can ….
You should use the intents/predicates 'checkCapability' (for the user) and 'describeCapability' (for the agent).
In responses.pl find text(describeCapability, ""). and fill in the atom with an appropriate response.
Test it Out
Say random stuff like “the sky is blue” in all steps and see how your agent responds and if it freezes before it or if you are allowed to continue.
Before the repairs, the agent froze if it did not understand and could not proceed now . Now you should be able to say something random, it says it does not understand and you could then continue the pattern.