How It Works
Now that we have our template operational let's take a look at how it all works.
In this section, we go through all the main conversations and explain how they work together to provide the overall experience.
Product Choose Template
The Welcome conversation has just one scene with a number of turns.
Welcome Scene of Welcome Conversation
Let's walk through each turn so that it is clear what their job is in the overall conversation.
This is a starting turn that holds the outgoing intent from the application that welcomes the user to the scene.
Welcome Turn Intents
The message has two buttons associated with it that will activate intents that are in other turns within the same scene. We will mention these intents as we examine the other turns.
Product Chooser Welcome
This is an open turn that captures the intent
intent.core.TurnEndChat- this is an intent that is generated when the user clicks on the end chat button on webchat. It is actually what in OpenDialog we term a cascading intent in that when the intent is matched the OpenDialog conversation engine will first look for
intent.core.ConversationEndChatbefore breaking out to the top of the scenario and look for
intent.core.endChat. This cascade of intents allows us to react to the user differently in different contexts. This is an implementation of the Contextual End Chat Pattern.
The prompt question turn is supposed to be activated whenever the user says that they have a question (e.g. when they click on the "I've got a question button". The response from the application will be to invite the user to ask their question.
The Turn No Match turn is activated when interpreters fail to map the user's request to an available intent. It allows us to deal with a no match within the scene. This means that we can retain context and help the user recover more easily than breaking out of the scene and ending in the global No Match Conversation. This is an implementation of the Contextual No Match Pattern.
The FAQ Turn handles FAQ questions within the Welcome Scene. It is an implementation of the Contextual FAQ Pattern. The incoming user intent name is
intent.dialogflow.faqand that should be mapped within your Dialogflow interpreter setup to the knowledge base intent as shown in the figure below. This mapping will convert any
Knowledge.Knoweldgebase.*intent from Dialogflow intent the
intent.dialogflow.faqintent in OpenDialog.
Mapping FAQ intents
At the same time within the outgoing intent message, you will want to embed the response from the Dialogflow knowledge base using an empty custom message and adding the attribute from the user context that contains the Dialogflow message
Embedding a Dialogflow Knowledgebase response in an OpenDialog message
The end result is that you will be able to wrap question responses in a customized message based on the conversation context.
The Next Turn captures all the intents from the user that could move the conversation to the next phase. There are three possibilities. The user might click on the "Let's go" button, the user might type something that maps to the
userContinueNLUintent (e.g. "let's do it", "let's find shoes", etc) or the user might dive straight into a more specific request such as "Looking for men's shoes" that will active the
The Help Request Turn is an implementation of the Contextual Help Pattern, it allows us to capture a request for help within the welcome scene and respond appropriately for this conversational context.
Gather Experience Conversation
The Gather Experience Conversation has two scenes. The User Profile scene where we collect the necessary information from the user while also providing access to FAQ questions, etc and the Pronation Scene where we explain to the user what is Pronation. The Pronation scene is what we consider a "sidebar" scene, where we break out from the core scene (User Profile) to handle a specific piece of information before returning back to User Profile.
User Profile Scene
You'll notice that the User Profile scene has a few turns that are similar to the Welcome scene. The FAQ turn, Turn No Match turn and End Chat turn are all there to handle similar issues as before so we will not go over them. We will, instead, focus on the Welcome User, Provide Experience, Change Experience and Work out pronation turns.
Welcome User Turn
The Welcome User turn is a starting turn with just one intent from the application - welcome the user to the User Profile scene. This intent has five messages associated with it. Which message will be shown to the user depends on how much information we already have from the user about their request.
To explore the approach a bit further: our goal is to provide a natural way to hold a conversation, if the user chooses to do so. To gather details from the user, we prompt the user in an open-ended way: "Tell me how often you tend to run, pronation, size and whether you are looking for men's or women's shoes." We are thus looking for 4 pieces of information: frequency, pronation, size and men's/women's. An open-ended prompt like this sounds natural and provides the user an opportunity to reply in a natural way. However, it is quite likely that a user will not provide all the requested information in their reply. Once we receive whatever information they give us, we parse that out, and will then prompt specifically for any information that is still missing. This is the reason why we have the five different messages in this turn.
As an alternative, we could have taken the user through each question one by one, instead of providing an open-ended prompt. This would have resulted in a more stilted and flowchart-like conversation, where we'd ask: "how often do you run", followed by "what size are you looking for", followed by the other direct questions.
The screenshots below illustrate a couple of different versions of the current conversation. In the screenshot to the left, we don't have any information yet about the user as a runner. In the screenshot to the right, the user dove right in and supplied two pieces of information before we even asked them the open-ended question. The flexibility to accommodate these and other variations of the interaction makes this a more natural conversation style.
Any time we gather a piece of information from the user, we store this in the user context using attributes.
From a conversation map perspective, the Request Intent from the application is the same, but the way that intent is expressed through the question depends on how much information we have.
Request Intent with 5 associated messages
We have a total of five messages. A general one if we don't have any relevant info and another four messages, each focusing on one of the four pieces of information we want to collect. Each of those four messages has a condition that checks to verify if that piece of information exists in our user context.
After we've welcomed the user to this scene, we are now ready to collect any other information that is missing (or handle FAQ questions, etc). The turn that collects this additional information is the Provide Experience Turn.
Provide Experience Turn Intents
Request Intents: There are two requests intents that are meant to handle information coming through from the user. The first one is the one you should configure with an NLU interpreter, while the second one is the one we use for button-based responses.
Note: You can use an NLU interpreter to interpret a button response (we will send the text on the button to the NLU interpreter) but if you are setting values explicitly with buttons it can be more efficient to just use the internal OpenDialog interpreter.
Response Intents: The response intents are where we decide whether we are going to ask a follow-up question or whether we are ready to show the user some shoes. The first intent "Ready to see some shoes" has a transition to the Welcome To Recommendations Scene in the Recommendations conversation. This intent will be selected only if all the conditions return true.
If the conditions do not evaluate to true we move on to the second possible intent response which is the "Follow-up question". The "Follow-up question" intent, similarly to the intent in the welcome turn has a number of messages associated with it each one with a condition based on the attribute information that is missing.
Through the simple interaction between these two intents, we achieve what in other systems is referred to as slot filling or form filling. We will return the user to this turn and keep asking relevant questions until we have all the information we need. Once we have all the information we can transition the user on, continuing the conversation.
There is one other technique that this scene uses to keep the conversation focused on collecting any pieces of missing information. When a user asks an FAQ question, what we want to do is provide the answer to the FAQ question but then continue with the information collection that is the main objective of this conversation.
The way we achieve this is through virtual intents. When a user asks an FAQ question we expect the FAQ turn to match and the answer to be provided as usual. However, once that turn plays itself out rather than returning control to the user we fire a virtual intent by defining it on the response intent of the FAQ turn.
A virtual intent instructs the conversation engine to omit that intent (as if the user said an utterance that was then interpreted to that intent). Once an intent is omitted the normal flow takes on from there and the conversation engine will do whatever it was going to do if the user had said that intent.
In this case, the implication of the virtual intent is that the Provide Experience turn will be activated once more and the application will reply in whatever way is appropriate given the context. The message from the application will be appended to the FAQ answer and the whole series will be delivered to the user.
Virtual intents can be extremely powerful in that they can allow us to reactivate entire parts of the conversation and they mimic how human conversation develops. The application is essentially saying "I get that you asked me something different, I will reply to that but then I am also going to continue based on the reply I would have given you if you had not veered off the main objective of the conversation!" The screenshots below show you some examples of virtual intents in action. You see the answers to FAQ questions and then the follow-up coming from the Provide Experience turn.