RASA OPEN SOURCE 2.0 | FORMS IN DETAILS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is ashish sunny from innovate yourself welcome back to my channel once again i am back with another session on rasa chatbot and this time with brasil 2.0 uh like in the last session i have already shown you that how you can use slots with rasa 2.0 so that you can store the value that you extracted from the information that the user is giving to you as an input so from there we have extracted the information and we have stored them so this is one way of collecting the information and storing now there is another way to store the information or let's say to store the information in bulk or let's say we are having multiple slots together and i want to collect all the information one after another or let's say if the user will provide me multiple information at a time i should be able to extract them simultaneously so this is all that we want and for that we are having a very good concept and a very good logic in rasa chatbot and that is forms so i will show you today that how you can use forms in rasa or let's say in rasa 2.0 in the previous versions we have already seen how you can use forms but now as we are working on rasa 2.0 so there are lot more changes in writing the forms so we have to understand them so that we can work accordingly so for that let's get started and let's see how we can use forms in glasser 2.0 all right so as you can see on your screen this is a project which we covered in the last session and there i have already shown you how you can use slots now we are not going to use slots instead we will be using like how you can use forms so to adding the forms there are options and there are changes that we have to make to the project which we are working on right now and for that let me just show you what we have done last time to understand that part first go through this story which we created in the last session where we were collecting two information or let's say we were having two slots for which we were extracting the information and we were storing them into them into the slots so this is what we are doing in there so this is first slot identity this is second slot and entity so this is one way of creating a story but now i don't want to use it in this way because here what exactly i have to do is i have to write every step i have to write all the story for each of the step as for the slots which i am having in here and also if i will provide multiple information together my slots will not be able to handle that part so that is why i require forms and that is why i have just commented this part right so that is why i have commented it now for working with forms so the first thing is that you have to make the changes to your configuration file inside your policy so inside policy you must add this rule policy right so as you can see in here it is already added so let me just uncomment all the things whichever is required in this project right you can leave this fallback policy right because we are actually not using the fallback part right now right so you can leave that and rest of the things we can uncomment so this rule policy means we are going to use the forms so this is the first step so for adding your forms you are having two options one is to add your conversation in the storage dot yml or you can add it in rules dot by ml we have already seen that how we can add the stories in stories.vml now let's understand how we can add the rules to rules.ml to make your forms work right so we will work in that way so you have to add your data over here so inside this what exactly we will do is we will add two things one is to activate the form second one is to deactivate the form so we have to add both of the things and there is a different way to write it inside the rules or environment that i will show you right now but before adding that part i must have a form i must have a form that i want to add or let's say that i want to create with my story so this is all that i have to do so for that you also have to do one more thing you have to go to endpoints.yml just because we require the action server we require this action endpoint so that we can make your rasa action server work so this is also required now go to the actions directory and inside go to this actions dot py just double click on it and in here you have to add your code so let me just tell you what is that code i will not write the complete code because it will take much time right so that is why i will just copy the code and i will just explain it right so let me just do it all right so you can see in here i have added the complete code over here and now let me explain you what i have done over here right so there are two classes one class is this and the second class is this right so the first class will ask you the question as per the priority that you will set let's say i'm having two questions because in the previous video i have explained you like i am going to ask the user for two information one is the name and the second one is number so in this way i have collected two information from the user so the same thing i have to do in here and as per that i have created two different slot one is name second one is number based on that i will be calling them one after another so for that i have just created this class which will ask you the question as per the priority that you have set and based on each of the slot whatever you are adding in here as per the priority it will ask you the question with respect to this so this is a complete code for that right so you can see in here and as for that whenever it will get some information from you it will automatically fill that part into the slots whichever you are setting in here right and one more thing as per the slot whatever you are adding in here as we have already seen in the previous version as well that inside domain.yml file whatever questions that you are having for the name for the mobile number you have to write it in a specified way and that specified way is to just mention it like utter underscore ask underscore whatever is the slot name so the first slot name is name so this is what i have written similarly do the same thing for mobile number as well so it will be utter ask underscore number so this is what i have done right name and number and there is one another way of writing it and that another way is to write like utter underscore ask underscore just after that here you have to mention the name of your form so whatever is the name of your form you have to add it here and just after that underscore and then the slot name so there are two ways of writing it so whichever you will prefer you can add it but right now i'm asked but right now i'm adding it in this way right underscore ask underscore name so this is what exactly i'm doing in here right so this is all about this part now i have added this and based on that whenever this form will be called you will see the first slot is name so question will be asked as per that similarly second is number so question will be asked as for that so this is how it is going to work when all the information will be collected from you it will automatically call this class and this class is for the submit part which means when you have all the information collected with you it will just pick the data and it will show you the answer as per that so this is all about this part now just go to the domain file and here just specify the action and the form whichever we are going to use right so to write the action the way is quite similar like we have used before let me just add it so you can see in here actions we have added this action underscore submit the second class which i have mentioned in here right and after that you have to add the form for the forms i have the form name as user underscore detail underscore form so this is the name of my form so the same thing i have written here right so this is the same name you have to write it accordingly and after that inside this form what i'm having is i'm having name and number these are the two values these are the two slots which i have to fill and those two slots will get the values based on the type that i will specify in here like in the previous version for the forms you have seen that this thing you mentioned inside the actions.py but in rasa 2.0 there are some changes and you don't have to specify them over here instead you can directly write it inside the domains dot yml and accordingly you can directly collect the value from here if in case you want to collect the information you have you want to collect the data from the entity you can write it like from underscore entity similarly if you want to collect the information from intent you can write it like from underscore intent similarly if you want to collect the complete information you can write it like from underscore text so this is the way how you can uh collect that part and accordingly right now i'm writing like i'm going to collect the information from entity and what is the name of that entity so the entity name is name itself similarly for the number as well so the entity name is number so if the entity name is something different you have to specify that name but in my case the name and number are the entity name itself so this is why and this is how i have written this part so this is the way how you can write the form inside the domain file and the last step left is to add the story inside rules dot environment or let's say we have to add the rule inside rules. so that we can activate the form and accordingly we can deactivate the form whenever the task is finished so this is all that we have to do and now let's just add that part as well so you can see in here so this is the first rule which i have added and in here what i'm doing is i'm simply writing like rule uh whatever is the name you want to specify like it is activate form so i'm going to activate it and after that you have to specify the steps so when i'm going to activate that form my form will be activated whenever i will say tell underscore name tell underscore name means so the first one will be let me show you like what is your name when i'm going to ask my what like what is your name so the bot will reply you with the name like my name is innovate yourself and accordingly it is also going to ask you like what is your name so this is how my conversation is going to start and in here i think i forgot to add one more thing and that one more thing is to add the action in favor of your bot so that is this utter underscore name so i have to add this as well right so just paste it and after that action will be like user underscore detail underscore form which means your form have to come and accordingly active underscore loop which means you are activating your form so this is how you have activated the form but this time to reactivate the form we have to create a separate rule so that it can be linked accordingly and to link them together what i'm doing in here is inside that there is a condition when you have to deactivate the form or let's say when you have to submit that form and also deactivate the form is when you already have a form activated if the form is not activated you don't have to do something or let's say in that case your form will not be deactivated right so this is all that we're doing so the first thing is that this is the condition that form is active and accordingly here are the steps to deactivate that so this is how we are just deactivating it and also we are just requesting the slot as null so this is what i'm doing right and finally action underscore submit which is the class which i'm calling from here let's say this is the function which will be called and in here what i'm doing is like i'm calling utter underscore detail underscore thanks so for that i think i haven't added this part let me also add this to the domain file right all right and you can see in here i am going to take the dynamic values for the name and number right name and mobile number and that will be coming from here so if you will find in here name is the first variable which is this mobile number is the second variable which is this and accordingly we are just sending the value from the slot which we have collected from the forms right so this is how we have started the form we have activated the form and also after collecting all the information we have deactivated the form so this is the whole process of creating a form and to further use it with rasa 2.0 right so this is all that i have done and now i am completely done with this part so the next step is to just train your model and test that whether your chatbot is actually working with forms or not so let me just train the model and test it so just train it alright so you can see the model is trained successfully now let's uh check the bot like whether it's working or not right so let's just run shell and also in the debug mode okay so your rasa shell is running so the one more thing is left and that is to run the action server just because this time we are running an action file right so we have to run action server just type rasa run actions and press enter so that your action server will also start and we can test the chat bot in a proper way right now let's start the conversation as for the rules that we have said so the conversation will start from here like tell me your name right so i'm going to ask my bot tell me your name so from here you can see the output is my name is innovate yourself and what is your name so this is how it is coming and if you will check this you will see there are two slots name and number there are two slots whose values are none by default that is okay and just after that you will see this line requested slot is named and this requested slot can only come if your form is working fine and that is activated and also you can see requested slot is requesting the name and as per that your action will be called and what is that action you can find in here i guess what is your name and based on that you can see user detail form means the form is activated and as per that your forms are coming in right so this is uh what is happening right so let's reply to this and let's say my name is ashish press enter and you can see in here like what is your mobile number and before going for the next answer let's check over here so you can see the slot name name has been filled with the value ashish which i have just mentioned over here right so you can see extracted slot name and the value is ashish so this is how it has filled the value and the next requested slot is number so based on that it is asking me for the number like what is your mobile number let's say my number is whatever it is right press enter so you can see based on that whatever number i have provided it has just stored them into the slot and that slot is number so this is how all the information has been collected and just because in the return part i have called the submit part i have called the submit action which is action underscore submit and from here you can see i've sent the values for the name and the number slot to this utter underscore detailed underscore thanks and based on that you have got this output thanks for providing the given detail name is ashish and mobile number is this whatever i have provided right so this is the first way how we can verify the forms now let me verify this in the second way because right now what i have done i have just mentioned the value step by step or let's say one by one so this is what i have done now let me just restart this part by simply typing this slash restart so that it will uh reset everything it will just set the values of all the slot as none right now what i will do is i will just send all the values at a time right but for that let me just ask the bot what is your name so that your form will get activated so you can see my name is innovate yourself what is your name now instead of only passing my name what i will do i will pass the name and number together right so let me just do it can you see this time it didn't ask me for the next question it didn't ask me for my mobile number instead it directly picked the value and it directly showed me this output thanks for providing the given details name is rahul and the mobile number is this so this is how you can create you can add the forms to your rasa chatbot and you can make your bot more intelligent to collect multiple information at a time doesn't matter whether you're going to give one information whether you are going to give multiple information but your bot will extract all the information if you have provided and you have trained your model for that so this is all about the forms i hope you have got the proper understanding for that but still if you are facing any difficulties in understanding this then feel free to leave a comment below in the comment section and also if you have liked this video do click on the like button and if you haven't subscribed to my channel yet then please click on the subscribe button so that you do not miss any videos from my side and also you can share this video if you have find it useful and you want your friends to learn this too so thanks for watching this video you
Info
Channel: Innovate Yourself
Views: 8,042
Rating: 4.8550725 out of 5
Keywords: how to extract the information from the excel sheets in rasa, how to start rasa/duckling server with docker, entity extraction without defining the entities in nlu, HOW TO DEPLOY RASA X ON THE LIVE SERVER WITHOUT USING NGROK, HOW TO CONNECT ACTION SERVER TO RASA X, RASA X AND ACTION SERVER DEPLOYMENT, how to connect socket.io to the website, link socket.io to rasa chatbot, rasa 2.0, ENTITY EXTRACTION, ENTITY EXTRACTION & SLOT FILLING, FORMS IN RASA 2.0
Id: jj4BL9o3Q7o
Channel Id: undefined
Length: 19min 11sec (1151 seconds)
Published: Mon Nov 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.