Slot Example Rasa
Pro tip: requiredslots function is a great place to introduce some custom slot logic. For example, it might make sense to include the outdoors seating option only for the restaurants of a. Slots which influence the conversation need to be added to your stories or rules. This also applies for the case if the slot was set by a custom action. For example, you can use a boolean slot set by a custom action to control the dialogue flow based on its value using the following stories. Here you can find the full list of slot types defined by Rasa Core, along with syntax for including them in your domain file. Actions are the things your bot can actually do. For example, an action could: respond to a user, make an external API call, query a database,. Just about anything! One of these items happens to be the Tabula E-Rasa. I’d have to say that this is one of the most expensive items in Cyberpunk 2077, and one of the most highly sought-after as well since it.
- Slot Example Rasa Al
- Slot Example Rasa Song
- Slot Example Rasa Video
- Slot Example Rasa Mp3
- Slot List Rasa Example
In this post, you will learn how to fill the slots and to use them further using the Forms. Now you must be the thing that if we are going to fill the slots only then why are we using the Forms for that. So the reason is we want to build an effective and reliable chatbot with lesser efforts than before. So, what is forms and form action and how it builds an effective and reliable chatbot with fewer efforts?
Whatare Forms?
Oneof the most common conversation patterns is to collect few pieces ofinformation from a user in order to do something (likebookinga restaurant, callingan API, searchingthedatabase, etc.). This is also called slot filling.If you want to collect multiple pieces of information in arow, we recommended that you to create a FormAction.This FormAction is the single action which have the logic to loopover the required slots and ask the user for the information untilall the slots are filled. So, this is the most important and therequired logic in the chatbot to save many lines of code and also tosave efforts for the same process.
So,how do we do it to with rasa chatbot to make it effective, reliablewith less efforts. Forthe form action we need to make the updation in the project files,which are, config.yml, actions.py, stories.md and domain.yml.
Let’sstart one by one and understand the basic functionality of each ofthem:
SetupConfiguration
Firstly, we need to include theFormPolicy in to the configuration file to make the whole processfunction properly. In this way,
Slot Example Rasa Al
The FormPolicy
is extremely simple and just always predicts the form action. This comes into action when the form action is called for the first time.
You can also check this video for more clarification,
Addingthe stories
Slot Example Rasa Song
To add the stories as per theforms in the most important step to call the FormAction and torepeatedly ask the user for the information until all the slots arefilled. Now lets understand it more briefly with the example problemthat we are going to cover in this post. Like we will add the belowstory or let’s say the happy path,
So,above is the happy path for calling the FormAction. In this story“network_issue” is the userintent to which the bot will redirect to the FormAction which is“form_info”. Here,“form{“name”:“form_info”}” isused to activate the form and “form{“name”:null}” is used to deactivate theform again. Once the FormAction is activated, the boty can executeany kind of action outside the form. The above “happy path” meansthat once the FormAction is active it can fo outside of the form andperform any action until all requested slots are filled withoutinterruption. For example, if the user starts the conversation andsays “My name is Ashish and I am using One Plus mobile.” Then theslots “NAME” and “BRAND” are automatically filled so, the botwill not ask you the question related to these slots.
To make your story work in such a way your first step is to set your slots as unfeaturized. But if the slots are not of the type unfeaturized or let’s say it’s featurized, then in that case you have to include slot{} events to show these slots being set. Not it seems to be confusing like when to use the form and when to use slot, So, to make it easier it’s not compulsory that you have to add the stories manually, you can also add them using the Interactive learning.
So this was all about adding the stories as per the FormAction. Similarly, you can add more stories according to the chatbot architecture.
Updating the actions file
In the above story, you have seen we have added the happy path as per the form action. Now we will learn what actually is happening when the form action is called. To do this you first need to define three methods:
name
:the name of this action (form_info in our case)required_slots
:a list of slots that need to be filled for thesubmit
method to work.submit
:what to do at the end of the form, when all the slots have beenfilled.
Here,what happens is firstly when the FormAction is called for the firsttime, then form gets activated and FormPolicy jumps in. TheFormPolicy
is extremely simple and just always predicts the form action. Toidentify which form has been called the first method is to be addedto the to the actions.py file, i.e.,
When the bot identifies which FormAction is to be called then it moves to the next static method which is requested_slots where all the slots are set in the order to be called when requested and here with respect to these requested slot names an utter_ask_{slot_name} is called from the domain.yml file where all the bot response are set. The static method that is to be added to the action file is :
Here you can see we are returning the list for the static method and this list specifies the order of the slots to be requested to fill values for each of them. So, it simply means firstly utter_ask_NAME will be called and vice versa.
Once all the slots are filled, submit() method is called where we can use the collected information in whatever way we want use it. For example, asking for booking confirmation with your details. This method will be added in actions.py file,
Slot Mapping
If you do not define slot mappings in the actions file, slots will be only filled by the entities with the same name as the slot that is picked up from the user input. Slots can be picked with the single entity but FormAction supports inputs like yes/no questions and free-text input. The slot_mappings
method defines how to extract slot values from user responses. Add the below method to your action file to extract the required information from the user response.
Thepredefined functions work as follows:
self.from_entity(entity=entity_name,intent=intent_name)
will look for an entity calledentity_name
to fill a slotslot_name
regardless of user intent ifintent_name
isNone
else only if the users intent isintent_name
.self.from_intent(intent=intent_name,value=value)
will fill slotslot_name
withvalue
if user intent isintent_name
.Note: Slot will not be filled with user intent of message triggeringthe form action. Useself.from_trigger_intent
below.self.from_trigger_intent(intent=intent_name,value=value)
will fill slotslot_name
withvalue
if form was triggered with user intentintent_name
.self.from_text(intent=intent_name)
will use the next user utterance to fill the text slotslot_name
regardless of user intent ifintent_name
isNone
else only if user intent isintent_name
.- If you want to allow acombination of these, provide them as a list as in the example above
Slot Example Rasa Video
Once you understand this just add the above methods inside a class as shown below:
Updating Domain file
Slot Example Rasa Mp3
Now to link the core and nlu to the action file add the following line of code to your existing chatbot in domain.yml file
Execution
When you are done with the above steps and have understood all the things clearly then train your model and test it
You will see the output something like this in the debug mode.
Slot List Rasa Example
After this execution, you will really feel that you have reduced the number of lines of code and have built an effective and reliable chatbot with different features added to it.
This is it for this post, I hope you have understood all the things very clearly but still if you have any queries related to the topic then feel free to leave a comment below in the comment section.
Stay tuned and Enjoy learning. 🙂