pizza bot with dialogflow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay guys so welcome to this practical so here we're going to learn a little bit more about intense entities and contacts contexts and we're going to apply this in a scenario of building a pizza but a pizza or during service so we're going to learn a little bit about how to manage conversation flow with context as well as how to use all these entities and also more about intense okay so we'll build upon what we have learned in the previous practical okay so here we're going to start off by creating the entity and the entity were going to be creating here is called pizza type with the following elements okay so an entity are those important pieces of information that should be found in a particular intent so in this case the user is ordering here we want to know what is the user a flavor or user type of pizza okay and so based on this flavor based on this flavor we want to pick out from the intent what kind of flavor does he want this is one Hawaiian pepperoni barbecue or veggie so to be able to do that we have to define an entity now this is what you call a custom entity so for custom entities you may define synonyms if there are certain words which are similar or can be substituted for then you can define synonyms here right so let's just begin this process so in dialogue flow I'm going to be using by the way the same but as the previous exercise so that we can test this in all the platforms because this is already connected to our messenger and telegram and so because we don't want we want to avoid redoing that entire process we're going to use the same but but feel free to try to create a new one if you prefer [Music] so first I'm going to go to entities here and I'm gonna call this okay okay I'm just gonna delete some of these things where I shouldn't did this already okay so let's just begin from the beginning so assuming you don't have any entity yet alright so we'll just create the entity and then we're just gonna call this thing pizza type right let's just match that okay and let's just place them so these are the items that you want to identify all right that would be part of a particular intent so how I am pepperoni BBQ and veggie okay so there we have it - so once you're done with that there you have it so you have this intense here sorry you have these entities here and so you can just add more rows if you want but right now I'm just gonna save this okay and there we have it so that's the pizza type now we're going to do the same thing for pizza size so once you've saved this we can just quickly add another intent and we'll call this pizza sighs okay so this will be personal regular large and extra large okay then save that and then we shall have a pizza crust and toss thin and cheese let's just do that again pizza crust and tossed thin and cheese okay that's that so next we're going to add the intense now okay so there so obviously these entities have no use unless they are part of an intent okay so we are we are already forecasting that we need all of these elements when we you know set up our intense so let let's do the first one here so the first one is called pizza start okay so pizza start okay so pizza start will be the intent which triggers the entire ordering process okay so typically you have something which will trigger the ordering process it's the same way as when you say hey Siri or hey Google right there is to be something which will trigger it or else it might get confused No so let's some create now a new intent okay so make sure you save it then click new intent here and then just do pizza pizza just don't shake okay so pizza start okay and then we're gonna add here a context okay we'll call this context pizza start as well so context is allows you to sort of manage the conversation flow so what you're doing here is once this intent is triggered we are going to activate this context so that other intents will know that this intent has been has been triggered but sometimes you want to know whether a previous intent has been triggered before another intent can be triggered and so in that situation the subsequent intent would look through its input intent right and intent the previous intent should output what you call an output context sorry let me repeat that let me repeat that so you use a context in order to manage conversation flow so in this situation I'm using an output context to signify to the subsequent intent that this intent has been triggered so subsequent intents will look to them it will check whether a particular context has been set okay so if a particular intent sees this context then maybe it will trigger it then it will trigger so you can choose to do it in this way because you don't want the intent to trigger unless a previous intent has been triggered okay that's one important use of context so I've setting now this context you can give it any variable that you want any variable name that you want but in this case I'm just giving the same name for that okay now let's add in the training phrase okay so let's just have a few training phrases here which might trigger this intent I'm hungry I want a pizza I want I want to order and so you will have some free so let's have these three phrases first and then let us have a response which will prompt the user to trigger another intent okay so what is this response now what size would you want so you see you're giving this type of response so that the user will be guided to respond which will trigger another intent okay so let's just go ahead and add this so I'm gonna prompt it okay Pizza large or extra-large okay so you give it some sort of some guide here okay okay so with that let's just say that now you can have some alternative message alternative response so that it'll be a bit more variety I might leave you I'll give it time to do that but for my case in the interest of time I'm going to just use this one hey but you can add more possible responses if you want which will prompt the user to choose the size okay so that's the pizza start okay so now let's move on to the next intent so this one is gonna prompt you for the pizza size right so that's where we're gonna do this now and let us now add here a new intent in this case this is pizza - get sighs okay so we can place here now the training phrase so they'll say probably something like give me regular right now you wanna do it what you want to do now is you want to annotate the in the entity the important thing so you're training it to figure out which one here is the entity and what type of entity it is so here I'm just gonna put it here and now it doesn't know at this point so I'm going to guide it and say that this is the pizza sighs right okay do I have pizza sighs here you can just do a search here Pizza or there's your pizza sighs like so okay so that's how you annotate it press Enter let's add a few more expressions so you might say regular on there and it you can see that as you press ENTER it it guessed correctly so as it as you keep on training it will actually guess for you and usually that people get it correct okay so what does it say here I want the size to be large and I want the size to be large and it's guessing correctly already it's guiding you I want personal okay so there so that's how you train it to recognize the training for the intent as well as how to pick out a perky the entity in that intent and so the next thing you want to do here is you want to think about do I want pizza start to be triggered first before this or will or another way of putting it is do I want this intent to trigger only if bits start has been triggered right so if that is the case then you want to put an input context to control when this will trigger okay so I'm just gonna put here the context as the same one which was it's a start right so that's the input context and now I'm going to put an output context here because I think that I want the subsequent statement to actually trigger only if this thing has been triggered so I'm going to change this and I'm just going to call the same thing pizza - get sighs okay all right so I'm just gonna save that so you know this class that this one has a number which is five so this means that for the lifespan is how many [Music] conversations or how many herbs back and forth statements will occur before this context expires so this is saying five statements and then it will expire okay because you don't want this context to be live forever right so in this case I'll just keep the defaults because it's not that critical that it that it expires so soon or or not okay and so same thing here we want to go to the next level here okay so can I get the flavor that you want pepperoni Hawaiian cheese and barbecue okay so let's just do that in the response can I get the flavor that you want so what are the options here pepperoni Hawaiian cheese I'm a barbeque okay okay that looks fine and so I think that after that we can use the quick replies now so one thing class which you can do with this with this intent is you can actually target it to a particular platform okay so in this case I'm going to use Facebook messengers quick replies right because I think this is a nice way to make the user choose okay so I'm just gonna click Save here go Facebook Messenger and add responses so I'm just gonna say quick replies so the first the first entry here will be the title of this quick reply so in this case enter your flavor then you can put in now your choices so I'll just follow whatever they have here so it'll be a Peroni Hawaiian cheese and barbecue okay that's it so that's an alternative to letting the user type can use quick replies if the client supports so I'm just going to do that so that's for facebook messenger default because I'm just gonna save all of this okay so next thing we're going to do is we will move to the next one okay so if you notice for this practical get flavor is actually not completed so I leave it to you to do this portion give it a try and do it yourself if you don't know how to do it the next part of this video will show you how to put in get flavor it's more or less the same so let me just do that now so it'll be pizza - get flavor right so you're gonna place your I want Hawaiian oh sorry what is flavor just double-check okay so okay maybe we should test it out first okay let's stop let's test it out so I am hungry okay so okay I think I I already created pizza Type O okay pizza crust I should have pizza crust already okay I already did Pizza Pizza type okay so the next one is pizza okay the first Pizza type then pizza sighs then pizza pizza crust okay so wait that's so let's just go to the intent first okay so I will start pizza get sighs okay we already got this in fact so we should get the crust now right so can I get a crust that you want okay this is pizza crust right yeah no this get side so we want the crust now so it should be what are the options for the crust and toss thin and cheese okay so you can do this yourself I'll do it right now but you can try it yourself first so and toss thin and cheese like so all right so I'm gonna fix oh I fixed that up okay so now that I've prompted the user for a crust we can now create our intent for the crust right so we can also do a facebook messenger here but this one is not correct now so let's fix this so it should be and toss thin and cheese okay okay yeah and so this one is still correct okay so this still follows right let's save that okay next let's add the intent now for our pizza crust okay so pizza get crust so I'll say I won so the context here we have to be we have to input first so this one should be pizza get size right it's a good size okay and then the output will be pizza does get crust correct yeah I think that looks correct all right now let's put there I want thin okay by one thing I want and tossed okay I have to undertake this okay so this should be pizza crust all right and then just press ENTER to that this one a surgeon also be annotated so just highlight it you just highlight it and then it should be caress yeah okay geez let's see if we can do that it's across this - pizza crust okay so that's fine and now we will prompt it so you can see when you create this you actually are creating a parameter as well so every time you set an entity up right or you annotate an entity the parameter will appear here in the parameters table here okay so the parameters table this is useful like this name is useful when you do coding and submit this to fulfillment you actually need to know the name right but it's just useful to know that this exists once you annotate it will be done for you okay and then finally in case we did the get size already then we did quick replies already actually this should be get sighs okay so let me clarify that this is should be I'm sorry get crust this should we get crust okay so please fix that up okay and then finally we will get the particulars right because it's making an order we want to know what what were the items okay so this one is incorrectly this should be pizza - get crust okay if you want to do cuz pizza type already gets the flavor so please correct this okay so let's just do that let's finish this up first then we'll test it okay so this one will be pizza - get crust okay so now let's give a response now we're going to be asking him for his particulars all right so what we can do is we can ask him for approval not to get these particulars thank you thank you now we will get your particulars press okay I mean type okay to continue okay - you can do something like that right to start off guide him through this process okay now for Facebook Messenger they already play stuff here okay it's a facebook Messenger okay you can also do a quick replace here right so ad response here and then a quick replace is enter your crust or choose your crust choose your crust so it will be and tossed thin and cheese okay yeah so that looks fine so let's say that first so let's go ahead and try it out okay so I am hungry okay says here yes what size would you want please choose pizza sighs okay this one is not so well done let me fix this up so if you look at the size this okay let me just go into the sizes let's go to the entities the sizes are personal regular large extra-large okay let me just fix that up so in pizza start it is just tuned personal satellite service sighs it's personal regular okay regular okay so we go P to start personal regular large extra-large okay lease everybody can say her please choices this is put here choices are okay so I can do it like that okay how can you want to guide this person as much as possible let's save that first and then in facebook Messenger let's add this responses as well okay so again quick replies for this enter your size personal regular large extra-large okay so let's save that okay that looks better so we're gonna test this in facebook later let's do this the default one first say I am hungry okay there you go yes what site would you want choices are personal regular large extra-large okay now since we have connected this with facebook messenger you can actually see the sample here if you don't have test and facebook messenger but you know you have been integrated with Facebook Messenger you can actually test it here see that how it would look but of course it doesn't match Facebook messengers client know so normally you wanna really test it on a facebook messenger spine right but again this is a quick and easy way to do that okay so we're gonna reply now here say one regular by the way you can see that the contacts pizza start a speed trigger so regular here is supposed to match the next intent which is pizza size right get pizza size pizza get size right and so pizza get size will only trigger if the input context is triggered right which is this one correct so this should trigger now pizza - get size so let's see now so it triggered so you always want to observe was it triggered yes that's good so then I get the crust you want and toss them in cheese okay so let's try cheese uh-huh I see good it got it no the only thing you see the problem with this cheese is there's also a flavor pizza type this cheese and then there's also a crust which is cheese so you have to pay attention if this will conflict no because both of this context could be active and it could get confused we have to observe this very carefully no especially if the response could be the same right four different questions so the context is the one that sort of distinguishes it but sometimes if the context has a value of five right the number five then it might be still be active they could conflict with each other right in this case it did not so it was good so anyway the context so now you can see the three context is actually active we see so if one of these contexts one of the intents which has also cheese as a response and also has an input context active they can conflict as I'm trying to say so you want to manage that so that's where you want to reduce the account of the you know the lifetime of the context okay so the next thing is user particulars okay type okay now you see there's nothing so now it's our job to create the user particulars all right so again let's go ahead and do that so here is pizza user particulars okay and then let's so what are we going to place here so let's look at this so we're going to place some input parameters through a tree first name last name phone number and postal code okay so there's many ways to retrieve all of this right you can do it one at a time all right so what's your first name what's your last name what's your phone number what's your postal code however you could also do it in one go like this right in this case you are creating the parameters and it will define prompts okay automatically so the thing is if the parameters are missing it'll keep on prompting you until all of these have been filled up okay let me explain that so let's just create the parameters first okay you can ignore this action it's not important now but these particulars so let's just put this one in so we'll place the parameter name as first name okay hey we'll say it's required right it's required first mean yeah so it's a little bit sure its list always keep black defined prompts you can customize this okay so this one here the entity is the type of this parameter name okay so in this case we're going to use what you call a system entity and see so there's a bunch of options here right so we can just put ad sis so but which one right which one will it be okay so the best one for this case because a name is very variable right it could be a lot of things what you can do is you can just place any here let's just try any okay this isn't that any as this and so let's add in a few more of this let's have a new parameter so last name add sis any as well okay press Enter it is required as well then add new parameter what else do you want it wants phone number and postal code okay let's just use sister any for all of this phone number sis that in and then postal code okay so the the training phrase here will be okay right press okay then it's fine the contact should be pizza get crust right Pizza get crust so this way now this will be the end of this flow is this dialogue but if you want to add more than maybe you also want to have another context so we're just gonna we're just going to leave this blank Hey okay so we're gonna say thank you for your order let's just try it and see if it works okay now when you run this it's always good to reset the context we didn't get rid of it so you see if there's nothing right okay I reset it yeah okay so let's say I am hungry okay so let's say regular this is good so you're checking that it's regular here then it's triggering getsize like yeah and then there's a crust let's have an toss okay so I'll just press okay ah so now it is asking you alright so let us just place here just in okay so nine zero one zero six two zero and three nine eight zero two eight there you go so that's the flow now obviously this information should be input into some database right with fulfillment which will be our next topic but right now I'm just showing you this is how typically you would get all of this information right through intent and context now we there are some things that we can do with this okay with this response now as we said this response thank you for your order will normally come from a database okay but I just want to show you one way to make your static response is more dynamic okay so the static responders are very limited obviously but normally as I say if you're fulfilment you can make changes to this response based on some logic on your server okay but now we do not have that but you even as a static response you can make it dynamic only by using these parameters so for example you want to echo out what he said right so you might say something like thank you for your order dollar dollar first name see that got our first name and this will refer the dollar sign will refer to the first name then you could refer as well to previous context now what are the contexts which are active at this point you have here pizza get crust and pizza getsize right so let me save this first so let's look at this all right so for that intense here let's look at the intention so we have here pizza get get size okay okay so here you can see from the parameters you could actually refer to the pizza sighs okay so you can actually retrieve this because pizza gets size let's go back to that okay so here you could actually refer to that because pizza get size is actually active and pizza get crust is active you can actually get information from that so you can say something like thank you for our order thank you for your order you have chosen what then you can put there the hash and then the context names right in the case of our contact is the same as our intent name right so we'll say pizza - get crust dot it's a get crust what is the name of that okay here it's called pizza crust you can change its name by the way all right it's okay you can change this we're calling it pizza crust now and then the other one was pizza pizza crust other one is pizza size right so it give a it gives the parameter name okay so let's just go here Pizza get crushed little piece of pizza get crust and okay let's just do that Pizza let's do a hash here Pete's - what's the name of the context get size right get size and then we can put here so this should be pizza that get for us that pizza because this is the name of the parameter pizza crust that it's size we will deliver it to dollar so what is this one this is the postal code - postal code dollar so we just refer to this if you refer to a parameter just refer to this one okay so if it's the current one you can just retrieve the parameter deliberate the postal code postal code in 30 minutes or you get your money back up so good service okay so let us now save this okay so let's now try it okay I am hungry right so what sighs let's just say extra-large see if we can get it I'm gonna get the cross cheese now we will get your particulars yes okay what is the first name okay so just in one l90 165 to 0 and the postal code is three nine eight zero to eight do that directly that she said thank you for your order you have chosen cheese and extra large we will deliver it to postal code three nine eight zero eight and thirty minutes okay yeah so that shows you the flow of this pizza but now I have to say I fir I made a mistake in the sense where I did not put I believe the flavor okay so if you look at the top here I'm asking for the size but I did not put the flavor so please do go ahead and do that okay put the flavor because I stopped at the crust I should have put the flavor here as well so please do that and see if you can get that working also it gives you a bit of practice okay now uh okay so I'll let you do that now before we before I let you do that as well you might let's test this on some other platform okay so let's test this in facebook messenger first because we implemented the quick replies in facebook Messenger please also in to try to implement it as well in telegram you couldn't see what's available and see how it works okay so for facebook messenger let me open up Facebook messenger now okay so again we go into your page so should be pages or click on pages okay so we want to go into I believe this one this is the page we created last week okay so to send a message would you click the test button here okay and then we shall try it out so we were trying this out the other day right so I say I am hungry can you make this a bit bigger no nevermind I am hungry they are you see see that you can do it like that it just make sense so when you click on personal it's like your type personal see that enter flavor hand-tossed then oh it didn't get thin also we need to train this yeah let's try hand toss hmm okay that's interesting in this case it is actually not going to the that's interesting why is it not going okay so it's important to test it in the platform it seems to be okay in the simulator right it seemed to be okay in the simulator why don't we test this in web integration now so maybe we can go into integrations let's just test it and see okay let's go to the very interesting behavior said I am hungry personal regular large or extra-large is that regular can I have the crust that you want thin you see this one work but for Facebook somehow it didn't work thank you now we will get your particulars type okay to continue so cook okay just we [Music] getting my spelling was wrong for this so we have to fix this up sorry about that so we have to okay so we have to go in to our intense it's my fault and then this place here first name thank you first name okay so that should fix the problem okay yeah so that you let's save that okay so it's interesting okay I'm not sure why this Facebook Messenger was not working for going to use your particulars we did use pizza get crust okay we didn't use it okay let me let me just try it without the quick replies right let's try it out the quick replies so maybe in intense mmm okay so maybe I'm going to remove this first I just want to see what it's like okay I'm just going to see what it's like let's remove this okay save that okay so I'm going to let's try that again I am hungry personals okay oh okay and I'm putting her enter your flavor it should be enter your crust in the typed in and now this one work okay so it's a little bit strange by the way they should be enter your crust hmm so okay then it works for their just in we are 3-0 okay so there you got it okay now there's that weird behavior there I'll have to check on why that is so okay but you can see that in all the other platforms that seem to work and when we typed it in it did work so I'm not sure whether there was some sort of issue in facebook Messenger or what okay but nevertheless I'll end it for this video and please just make sure you understood the concepts in this practical and we will proceed the fulfillment for the next one thank you for watching this video till the next video bye
Info
Channel: justin m
Views: 5,967
Rating: 4.9012346 out of 5
Keywords:
Id: DifAemVDAis
Channel Id: undefined
Length: 53min 14sec (3194 seconds)
Published: Wed May 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.