10 Changing Dialogflow CX conversation topic

Lesson: CCAI Vaccine Bot Demo

CCAI Vaccine Bot Demo

[00:00] So in this chapter, we are going to take a look at how to handle conversation topic changes in Dialogflow CX. And for this, I’m going to take an example of a YouTube video demo, which has been posted by the Google Cloud Tech channel, where they provide a demo for the contact center AI vaccine hotline bot. And it’s actually supposed to be a demo for the contact center AI technology, which is not exactly the same thing that we are using in Dialogflow. It’s a little different, but it’s actually a good illustration of a case where the user changes the topic.

So let’s take a look at the interaction. You can go and just search for the phrase CCAI vaccine hotline, and I think you should be able to pull up that video. If not, I’ll leave a link below this video also. And this is how the conversation goes. So the user first asks, is the vaccine free? And the bot is going to respond with an answer, yes, it’s free.

[01:00] Then they ask, do vaccine contain animal-based ingredients? And the bot says no. And then the third question is, am I eligible for the COVID vaccine? Now unlike the previous two questions, the third one requires that the bot answers. It’s not like a single conversation turn answer, because the bot has to collect some information from the user. It’s like a decision tree chat bot. So the bot first asks, are you a healthcare worker in the ICU, et cetera, et cetera.

And the user says no. And then it asks, are you a first responder? The user says no. Then it asks, are you either over 65 years old or under 65 with comorbidities? And then the user says no. And then it asks, we are down to the final question, it asks, are you an essential worker of any kind? And when the user says no for that, the bot is going to say, OK, you can take the vaccine in phase five. Now the user says, where can I get the vaccine? Again, they have changed the conversation topic one more time.

[02:02] And this time, the bot has to get a different kind of information from the user. It needs to get input from them about their zip code, the five-digit zip code. Once the user provides that five-digit zip code, then it’s going to say, based on this information, your closest vaccination location is Pharmacy A, and so on. And when this happens, usually there’s going to be a database lookup, which means that it’s usually going to call the webhook of some kind.

And then the user says, is there some other place or location? And the bot says, yeah, the next location where you can get a vaccine would be Pharmacy B. And when the user says, actually, I prefer a hospital, the bot says the nearest hospital where you can get the vaccine is so-and-so. Finally, the user says, I want to talk to a representative. And then the bot is going to say, OK, hold on while I transfer you. One thing that I want to notice here, or rather I want you to notice here, is that after that, whatever comes in the demo, in the demo video, is all pure contact center AI technology.

[03:08] And that’s not of interest to us for this particular course. So what I’m going to do is just stop with this conversation over here. And you can go and take a look at the full video to get the complete picture if you want. And there is a couple of things that I want to mention as we start this chapter. The first is that I will have a copy of this video.

I’m sorry, I’ll have a copy of this agent blob file, which is associated with this. And you can download it before you watch the other videos in this chapter. And the second thing is that these are the way I construct the agent, the pages and the transitions and all that. That’s not the only way that you can do it. You can, there are some other ways to implement the same ideas.

[04:01] And what I would say is that once you get a good understanding of the basics, which you should be able to by if you have gone through all the previous chapters, you should feel free to modify the flow that I have to make it work in the way that you want. I think that there’s no hard and fast rules about how to design these conversation flows. And because Dialogflow CX does provide you with a lot of options in terms of handling pages and states and transition routes and all that, there is more than one way in which we can build this particular part.

So in the next few lessons, I’m going to show you how I have built this part.

Lesson: Start Page Routes

Start Page Routes

[00:00] So we are in the agent, in the Dialogflow CX console for the agent and what I have here is the start page and you can see that it has six routes in total, I am sorry six intent routes in total and these are the six. The first two are, the first one is the Default Welcome Intent and the second one or the second and third ones are the questions where the user is going to ask is the vaccine free and is the, are there any animal based ingredients in this and the fourth question is where the user asks about eligibility, the fifth one is where can I get the vaccine and then the final one is where the user says I would like to talk to a representative.

Now one thing you want to note is that for the Default Welcome Intent and the vaccine is the question free, the two questions at the top, you notice that there are no transitions happening, right, when the user asks about eligibility though we have to do a transition because we need to ask them a set of questions and in the same way when the user asks where can I get the vaccine, you should be able to get their zip code before you can provide an answer, so that also can be done by doing a transition to a different page.

[01:12] Finally for the representative, it is just going to do a transfer to the agent and there is no need to do any state transition for that. So these are the routes that we are going to be looking at as we go through the next set of lessons.

Lesson: Simple FAQ Routes

Simple FAQ Routes

[00:00] So let’s quickly go over the simple FAQ type answers. When the user asks, is the vaccine free? So I’m going to click on that intent route and if you go and edit the intent to see the training phrase, you can see that there’s just this phrase, is the vaccine free? And the bot is going to respond with the COVID vaccine will be available at no cost and then what that’s going to help you with and then it doesn’t do any page transitions. Then the next question is, are there any animal based ingredients in the vaccine? And you can see that that’s the training phrase and then you can see that the bot says no and then what else can I help you with?

No page transition over here and then if the user wants to talk to a representative, then the bot is going to simply say, please hold while it transfer and then it’s going to show this, not do any page transitions for that also. So these are the three simple FAQ questions and you notice that for these, the intent routes are just going to handle the specific training phrases, give a response, the bot is going to give a response, but not do any page transition.

[01:09] But for the other two questions that the user can ask, we do have to do page transitions because those are going to be multi-turn conversation flows.

Lesson: Eligibility Flow

Eligibility Flow

[00:00] So now let’s take a look at the flow which handles the user’s question about whether they are eligible. So I’ve clicked on this user asked about eligibility transition route. And if you were to go and take a look at the intent training phrase, it just says, am I eligible for the COVID vaccine? Now, when the user asks this question, the bot is going to say, in order to determine your eligibility, I need to ask you a few questions. The first question is, are you a healthcare worker? Now notice that I don’t ask the entire question that the bot is asking in the video, but you can still get an idea, which is the bot is kind of going down the list in terms of priority or importance or something like that.

And then the bot is going to transition in this case to this get healthcare worker page, all right. So let’s take a look at what’s in the get healthcare worker page. Over here, you see that there are two routes. So the user can say yes, or they can say no, that’s what the bot is expecting at this point.

[01:02] Now, what we know about Dialogflow CX is that you can just create a single intent called user says yes. And if you were to go into the intent, you’ll see that I don’t have anything other than the word yes. And in that case, of course we can reuse the intent, that’s what I was trying to say. So if you use the route where the intent is user says yes, what you have to do is the bot has to say yes, you’re already eligible or something like that.

And then say, is there anything else I can help you with? And notice that it’s then going to do a page transition to this page called anything else. Now, I will come back to this later. It’s actually kind of important, but for now, let’s just ignore this and just go to this other transition route where the user says no. And as you will expect, all you have inside that intent is just the training phrase, no, then the bot has to move on to the next question.

[02:02] It asks, are you a first responder, teacher or school staff? And then it transitions to another page and that one is going to be called get first responder. And in fact, the sequence continues like that because if in the get first responder, if the user says yes, it has to say they are eligible. If, and then go to this page called anything else. On the other hand, if they say no, then it has to ask the next question and then go to the next page, which is get health status.

And in get health status, again, you have yes being, if the answer is yes, it will say yes, you’re eligible and then transition to anything else. The user says no, it is going to ask them the next question and it is going to actually go to this question, get essential worker. Now, I have not actually added this dialog here.

[03:02] Let’s go ahead and save that. And it’s going to go to this page called get essential worker. And in this get essential worker, if the user says yes, then it says you’re eligible. And then again, go to anything else page. If this user says no, it will just say, at this point, there’s no more questions to ask. So it will just say you will be eligible for the COVID vaccine in phase five. And once again, when they, it’s going to say, is there anything else I can help you with?

And goes to this page called anything else. Now, in the page called anything else, again, I just have yes and no. I just want to give you an explanation of what is going on here. So if you notice in the video, as soon as the bot says anything else, the user actually asks the next question right away. But you will find that there are some situations where the user will first say yes, and then the bot will have to ask what, and then the user will ask their actual question.

[04:05] Okay, so that’s what this is designed to handle. And that’s also why I said, you know, there are many ways to build this and you should build it in the way that is most suitable for your bot based on looking at your chat logs, okay? So if the user says yes, then the agent simply asks, okay, what would you like to know? But notice that it transitions over to the start page. We are kind of, at that point, we are kind of assuming that the user is going to ask the actual question in the next step, okay?

On the other hand, if the user says no, it’s just going to say, okay, have a nice day and also transition over to the start page. So I think that you got an idea of what is going on with that flow. So let’s just quickly test this agent. So I’m going to say, am I eligible for the vaccine? And it asks, are you a healthcare worker?

[05:01] I’m going to say no. Are you a first responder? No. Are you over 65? No. Are you an essential worker? No. Then it says you will be eligible for the COVID vaccine in phase five. Now, let’s say that when the bot’s asking, is there anything else I can help you with? The user simply says yes. Then it says, what would you like to know? At that point, I might ask, is the vaccine free?

Okay, notice that it says yes, the COVID vaccine is available at no cost. Now let’s start the flow again. I’m going to show you something. I’m eligible for the vaccine. And I’ll say no, no, no, no. So when this asks, is there anything else I can help you with? At this point, if I ask, is the vaccine free?

[06:00] You can see that it is still able to handle this question. It says, yes, the vaccine will be available at no cost. And the reason for that is when you came all the way to this flow and said, get essential worker, you say no, and then it’s moved on to this page called anything else, you have to remember that even though this is the currently active page, the start page of a given flow, we have a single flow only in this particular bot, okay?

The start page of a given flow is always active. So whatever questions are there in the start page are always going to be, the way I put it is, it’s always possible to trigger one of these intent routes at every point in the conversation flow, wherever you are. Okay, that’s a good thing. And it’s also a bad thing. I’ll tell you why it’s a bad thing in the next video. But for now, I’ll just point out that when you are in this anything else state, whether the user says, when the bot asks, do you need, is there anything I can help you with?

[07:04] Whether the user first says yes, and then ask the question, or whether the user directly asks the question, the bot is still able to handle it. That’s exactly what we saw in this video. And I’m going to make a small change in next video. And I’ll show you why that this anything else page is even necessary.

Lesson: Eligibility Flow Conflict Part 1

Eligibility Flow Conflict Part 1

[00:00] So in this video I am going to show you a behavior in Dialogflow CX which I think is a little strange and it could be a good thing or a bad thing but it is, I think it depends on the situation. So what I am going to do is I am going to add another intent route into the start page and I am going to call it yes user says yes there is and this is intended to be a response where when the bot asks is there anything else that I can help you with, the user might say yes there is okay.

So what I will do is I will add the phrase yes there is but then it is also possible the user might simply say yes. So I will add both these phrases, I will save the route and the agent is going to say okay what else would you like to know and notice that there is no need to change the page because we are in the start page and if the user asks a different question it could be selected from one of these intent routes right.

[01:12] So that is the way I have handled it. Now the point of this is of course if the, let us go to this user asks about eligibility and the first thing that it is going to ask is get healthcare worker and if the user says yes it is going to answer that and then says is there anything else I can help you with and if the user first says yes there is and then they want to ask the question then that is just a way to handle that particular transition.

So I am sort of pointing out here in another way is that not only is the get healthcare worker page active but the start page is also active and if we were to put this user says yes there is intent route as soon as the bot is coming back with this particular question and the question I am talking about is after they say yes over here right.

[02:07] If the bot gives this answer yes you are eligible and then it asks is there anything else I can help you with. If the user were to say yes there is then we want to go to the next sort of give an answer appropriate to that whatever the user said and then make sure that we are in this particular page right. So let us go and test the agent and see what happens now.

Am I eligible for the vaccine? So the user says yes at this point. So notice what happened instead of going to the next page that is if you if according to what we design what we expect to happen is that when the user let us make sure I get the whole thing right. So we are in this page get healthcare worker we already saw that and the bot is asking a question if there are healthcare worker in the previous page and when the user says yes we expected that the intent which will fire is the one which says here yes you are already eligible and then it is asking is there anything else I can help you with.

[03:19] But because we added another intent route into the start page where we have we tried to handle this case where the user says yes there is but remember that in that particular intent route we put both the training phrases yes and yes there is.

Now what this does effectively at least this is my understanding of what is going on right. What this does is if the user says the word yes then there are two places that is the start page is active the get healthcare worker page is active. So there are two transition routes which could fire one of the two it could either be this one which is contained in the start page where the user says there is or it could also be this other transition route called I am sorry the intent route called user says yes in the get healthcare worker page okay instead of choosing this one which is more current like this is the active page dialogue for CX seems to prefer the one in the start page.

[04:32]

Now this has some implications okay the first one is that to me it looks like whatever is in the start page it seems to have some kind of higher priority over better answers in the following pages or in the active pages after all when you think about it we have this get healthcare worker page which is the currently active page there is this transition there is this intent route called user says yes and the only phrase it has is just the word yes so we would expect that this should be the intent route which actually fires unfortunately that is not how dialogue for CX is designed at this point instead it chooses to fire this other intent route that we create this one over here so this is the point I am trying to make and this is why it was useful to have this you know anything else page to do this extra

[05:32]

bit of handling so that whatever is provided in the start page doesn’t end up conflicting with one of these following active pages in that flow because the start page intent routes seem to have somewhat higher priority over similar intent routes in the following conversation flow pages so that’s the takeaway from this video so what I am going to do of course is at this point I’m going to delete it because it’s not necessary and I think I’ve made my point you have to think about this as you are designing your bot and I’m not going to tell you what is the right way or the wrong way as I said there are many ways to handle this kind of situations but you have to take this into account this fact that the intent routes which you which you declare in the start page are generally going to be preferred over the intent routes which are occurring in the following pages okay and this seems to be especially bad when you have the

[06:32]

single word type of responses and you know I think that this will be less likely if you have entire sentences because there are more things that Dialogflow CX can use to do its pattern matching right so this is the point of the you know sort of the exercise of showing you what is going on and why we need this anything else page over here but just something for you to think about as you are designing your Dialogflow CX bot.

Lesson: Eligibility Flow Conflict Part 2

Eligibility Flow Conflict Part 2

[00:00] So in the previous video, I explained why you needed this anything else page, which is supposed to handle the case where the user says yes, after they answer a question. Now, you might be wondering, so what I did wasn’t exactly the best way to go about it. After all, there is one more thing I could have done, right? What if I had simply added the same route instead of going after like a new one, if I simply say yes, user says yes. And then the agent says, okay, what else can I, what else would you like to know?

And of course, there’s no page transition, you just leave it like that. Now, you might be wondering, okay, what will happen in this situation? So let’s quickly test it. The user says, am I eligible for the vaccine? And the bot is set, if the user says yes. You can see that this is correct, that is the bot is behaving as expected.

[01:02] Then if the bot says, is there anything else I can help you with? And the user says yes, then it says, okay, what would you like to know? Notice that in this case, the intent which fired is from the Default Start Flow, it did not go to the anything else page, that is the intent which was selected was from the Default Start Flow start page. But it’s fine because, you know, it would amount to the exact same behavior, right? So the point I’m making here is that if you were to reuse the same intent route, that is if the intent route has the exact same word or words or multiple phrases, then the priority does seem to be given to the currently active page.

The issue we ran into was specifically because I created a new intent route, where I added additional training phrases into the new intent route. Remember that the one I added was called user says yes, there is.

[02:02] And remember that there were two phrases, two training phrases in that particular intent, which was just the word yes, and then the phrase yes, there is. And I think that actually assigns like additional weight to the term yes, or something, right? Like there’s something going on under the hood, which makes it more likely that that particular intent route will be selected wrongly as we go through the conversation, okay? So the takeaway from this is that now, so here’s the thing, you could say that now if as long as we have the same intent route, and the bot behaves like this, we are fine.

And you might be tempted to just say that, okay, you know what, I just put this user says yes route into the start page also. And then I that way, I know that I don’t need to have that additional anything else page, right? But what I’m saying is, there will be some scenarios where you’ll find that you would be adding a different route into the start page, which will conflict with different route, different intent route in the following pages.

[03:11] So while this example was trivial, where the word we used was just the word yes, I am pointing out that there could be some occasions where you will have. So that is, there will be some occasions where you will not be able to just copy the same intent route into both the start page and the following active page, you will have to, you know, just to exactly handle your, you know, whatever conversation you’re building, you will have no option but to create two different intent routes, which will have a lot of overlap.

And by putting one of those intent routes into the start page and the other into the active pages which follow, you will be in a situation where there’s a good chance of a conflict between the two happening.

[04:00] And if that conflict does happen, usually the start page intent route gets prioritized. So the example I chose may have been a little trivial, and maybe it may not even have been very well suited for this particular bot that we are building. But the overall point I’m making is still valid. If you have an intent route in the start page, which is not the same, that is you’re not reusing the same intent route in the following page. But the two different intent routes do have some phrases in common or, you know, they have some kind of conflict between them, like in the sense that the bot could choose between the two, then what happens is usually the intent route in the start page is much more highly prioritized over the intent route in the non-start page.

So that’s the takeaway from this. And as long as you keep that in mind and design your bot, I think that you should be fine.

Lesson: Vaccine Location Flow

Vaccine Location Flow

[00:00] So now let us go to the last conversation flow that we are going to handle, so which is where can I get the vaccine. And the user asks where can I get the vaccine, I just have this training phase, where can I get the vaccine. Then the bot is going to transition to this page called get zip code. Now if you come to this get zip code page, you will notice that it is expecting this parameter called zip code, okay. So the name of the parameter is just zip code all lowercase, I select sys.zipcode, the system entity and then I make it a required parameter.

And then also notice that I have two handlers, so if the first time the user gives an answer, they do not give the correct answer, it will say you must enter a five digit zip code, so I can look up this information and then there is no transition. And if they do a second try and it still does not work, it will say sorry there was a problem, please try again later, it will set the zip code to null, okay and then it will transition over to this page to the start page, okay.

[01:05] And the other thing is that, okay let us do this, there is a route in this page and this one is a conditional route, okay, notice that there is no intent which is triggering it, but it actually matches this at least one where it checks to see if the value of the zip code is not equal to null, so if the user provided an answer, it is going to come over here and then it is going to say the nearest vaccination center is at center and then it just echoes whatever the user provided, so I am not actually doing any look up or calling a webhook or something, I am just going to acknowledge the specific value that they had input and then it asks what else can I help you with.

And notice that this time I do not go into the anything else page, instead I transition to the vaccine locations page because there are other things that the user could ask and these are the following, right, where else can I get the vaccine, okay, so if I were to look at the training phase, it says where else can I get vaccinated, where else can I get the vaccine and in this case the bot will say you can also get the vaccine at backup center and then you can just use $session.params.zipcode which is, you know, it is going to pull the value of the zip code from the session parameters and then it is just going to echo that information back and again there is no page transition after that.

[02:28] On the other hand, this other intent, well, that is called vaccine hospital, that is the user is asking is there a hospital I can get it, I would actually prefer a hospital or something like that, then the user, the bot is going to say the nearest hospital you can get the vaccine is hospital for $session.params.zipcode, so once again I am not actually calling a webhook, but I am acknowledging that I got the right input from the user as I do this, okay, so let us quickly check this out.

Lesson: Vaccine Location Flow – Testing the agent

Vaccine Location Flow - Testing the agent

[00:00] So let us test the behavior of this agent now, where can I get the vaccine. So it is first going to ask for the five digit zip code and I am going to say, I do not know. So you can see that it actually asks you must enter a five digit zip code. So if I say again, I do not know, it is just going to say sorry, there was a problem, please try again later.

So let us start again, where can I get the vaccine. This time I am going to provide an actual answer, 90001. You can see that it says the nearest vaccination center is center 90001, where else can I get it. You can also get the vaccine at backup center 90001, then I say I would prefer hospital, then you can see that it says the nearest hospital you can get the vaccine is hospital for 90001 and then it asks is there anything else I can help you with.

[01:17] So you can see that this is working as expected by, you know, once we collected the zip code, if we go to this page called vaccine locations, it is going to handle other things that the user might ask.

So that is what we are trying to do, we are trying to move the conversation over to this different page, where the user could ask questions, which are in context with respect to the fact that the fact that they already provided their location. So that is the basic idea. Now, as I said, you know, there are other ways to build this bot, you can also think of getting the zip code and starting an entirely new flow, where you have the bot handle questions based on the vaccine location.

[02:07] Now, when you do that, you have to remember that at that point, the other questions in the start page, which is in the default flow will not be able to, you cannot fire them because you move to a different flow at that point. So whether or not that is the right thing for the bot you are building is sort of something you have to decide. But I am just pointing it out that, you know, there are other ways to do the same job.


About this website

I created this website to provide training and tools for non-programmers who are building Dialogflow chatbots.

I have now changed my focus to Vertex AI Search, which I think is a natural evolution from chatbots.

Note

BotFlo was previously called MiningBusinessData. That is why you see that watermark in many of my previous videos.

Leave a Reply