How to collect user input in Dialogflow CX

(Autogenerated transcript)

 Alright, so in this video I'm going to show you how you can save user input in Dialogflow CX. Now what we are going to do here is we are going to take the combination of the Quickstart template that you see here, how to collect user input without follow-up intents and how to use session variables to save user input and we are going to combine them into a single agent in Dialogflow CX. And of course the big advantage of using Dialogflow CX is that it makes tasks like these very simple much easier than how it is in Dialogflow ES. So in the case of ES what you had to do is you had to create an output context called session bars with a very large context lifespan and then you had to collect the information from the user and you can see that I have this intent called user provides name, user provides email, user provides URL and once they provide all this information you are going to use the session bars context and then you are going to echo the information

 back to the user. So here we are showing the user that we got all the information by using the session bars and to create the same bot in Dialogflow CX is actually much easier. I would say it's actually trivial. So here I have an empty bot in Dialogflow CX. What I'm going to do is I'm going to add a new intent and here the user is just going to say they want to add a website chat bot and the training phrase will be add a website chat bot, add a chat bot to my website and let's go ahead and save that and here as soon as they do that you notice that it's going to ask them for their name. So let's do that over here. I have your name please and let's add it and then we are going to transition it over to a new page called await user name.

 So let's go ahead and do that and if you're not able to follow this yet I would also recommend you go and look at the other videos in this course where I go through something very similar in the beginning of the course. So it's not something new if you're already a course student. So I'm going to go through this fairly quickly and in the await user name you're going to add a route so and it could be something like araven which is my name. You see that it's already annotated it and the parameter name is person the entity type is sys.person they might say my name is araven. So all these are getting annotated with the name appropriately as you can see. So provides name is the intent and in that case after they give their name it's going

 to ask them for their email address. So let's do that what is your email address add it and here it's going to be the page name it's going to be await email address save it. Now let's go to the await email address do the same thing really add a new intent address and they'll say something like it is araven at that's not my email address obviously araven at you can see that it got annotated in the same way and then it's going to ask them for their URL of the website. So then it's going to be what is your website URL and let's go ahead and add that so you

 can have a new page await website URL save it and you know that that's going to create a new page and here we're going to say add an intent URL and I'm just going to type in you can see that it's getting annotated as a URL correctly let's go ahead and save it. Let me just add one more it is and now I'm going to save it and so what you're going to do here is you know that you can use the session params you can go and check out the series on the series of videos where I talk about session variables and dialogue

 plus CX. So here you know that you can do this to echo all the information back you can say your input you can do shift and enter to go to the next line and you should say something like name taller session dot params dot person email will be taller session dot params dot email URL will be taller session dot params dot URL so let's go ahead and add that and let's go ahead and save it you don't have to do any transition here let's go ahead and test the agent add website chatbot and say rn rn at you can see that

 it's echoing back all the information your input name is rn the email is URL is https colon dot slash slash bot flow dot com so that's pretty much all you have to do in the case of the Dialogflow CX bot so let's also go ahead and test it out in the messenger integration it's going to be the same thing of course so let's go ahead and try it now and add website chatbot it is rn rn at gps colon let me just change it to google dot com so you can see that this is the information that it's echoing your input which is name email and URL so what happened here if you are noticing is that

 Dialogflow CX is built in such a way that it makes user input collecting user input really easy and this is the overall flow diagram so you can see that all you did was as soon as the user said they want to add a website chatbot you will create this intent transition route and the intent transition route will use the ad website chatbot as the intent provide something as a response and then it will transition to the await username page and you can do the same thing for the other two inputs and this is all the same thing that we built in Dialogflow ES the difference of course is that in the case of Dialogflow ES it's not natively provided this in this feature the session params feature so you had to create it yourself now you might say well it doesn't look like it's much harder to do in ES but the problem with ES is that if the

 user does something which is not expected as they are providing the input you will find that it's much much harder to control the conversation flow in ES because ES is not built to provide the state machine as the underlying you know framework for your for building the conversation it's it's just all all intents and contexts and that's pretty much it on the other hand CX is built with the state machine as the fundamental primitive that's what powers Dialogflow CX you can check it out if you go and look at the API methods that CX supports you can see that it's built from the ground up to be to support this conversation as a state machine you know so in other words we are able to roll all these different things together into Dialogflow CX much more easily and we were able to build this bot which collects user input in Dialogflow CS

 very quickly.