Slot List Rasa
Rasa NLU — This is the area, where rasa tries to know User messages to detect Intent and Entity in your message. Rasa NLU is a tool for intent classification, response retrieval and entity extraction in chatbots,most of which have some additional dependencies. There are three important things you should consider when defining the domain for an assistant with slot filling: In Rasa, different slot types have a different influence on the predictions of the next action. When using FormAction to fill the slots, you are enforcing strict rules which tell your assistant what information it should ask for next.
Slots are your bot’s memory. They act as a key-value storewhich can be used to store information the user provided (e.g their home city)as well as information gathered about the outside world (e.g. the result of adatabase query).
Most of the time, you want slots to influence how the dialogue progresses.There are different slot types for different behaviors.
For example, if your user has provided their home city, you mighthave a text
slot called home_city
. If the user asks for theweather, and you don’t know their home city, you will have to askthem for it. A text
slot only tells Rasa Core whether the slothas a value. The specific value of a text
slot (e.g. Bangaloreor New York or Hong Kong) doesn’t make any difference.
If the value itself is important, use a categorical
or a bool
slot.There are also float
, and list
slots.If you just want to store some data, but don’t want it to affect the flowof the conversation, use an unfeaturized
slot.
The Policy
doesn’t have access to thevalue of your slots. It receives a featurized representation.As mentioned above, for a text
slot the value is irrelevant.The policy just sees a 1
or 0
depending on whether it is set.
You should choose your slot types carefully!
Slot List Rasa Tv
You can provide an initial value for a slot in your domain file:
You can get the value of a slot using .get_slot()
inside actions.py
for example:
There are multiple ways that slots are set during a conversation:
If your NLU model picks up an entity, and your domain contains aslot with the same name, the slot will be set automatically. For example:

In this case, you don’t have to include the -slot{}
part in thestory, because it is automatically picked up.
To disable this behavior for a particular slot, you can set theauto_fill
attribute to False
in the domain file:
You can use buttons as a shortcut.Rasa Core will send messages starting with a /
to theRegexInterpreter
, which expects NLU input in the same formatas in story files, e.g. /intent{entities}
. For example, if you letusers choose a color by clicking a button, the button payloads mightbe /choose{'color':'blue'}
and /choose{'color':'red'}
.
You can specify this in your domain file like this:(see details in Domains)
The second option is to set slots by returning events in custom actions.In this case, your stories need to include the slots.For example, you have a custom action to fetch a user’s profile, andyou have a categorical
slot called account_type
.When the fetch_profile
action is run, it returns arasa.core.events.SlotSet
event:
In this case you do have to include the -slot{}
part in your stories.Rasa Core will learn to use this information to decide on the correct action totake (in this case, utter_welcome_premium
or utter_welcome_basic
).
Note
It is very easy to forget about slots if you are writingstories by hand. We strongly recommend that you build up thesestories using Interactive Learning with Forms rather than writing them.
text
¶User preferences where you only care whether or not they’vebeen specified.
Results in the feature of the slot being set to 1
if any value is set.Otherwise the feature will be set to 0
(no value is set).
bool
¶True or False
Checks if slot is set and if True
categorical
¶
Slots which can take one of N values
Creates a one-hot encoding describing which of the values
matched.A default value __other__
is automatically added to the user-definedvalues. All values encountered which are not explicitly defined in thedomain are mapped to __other__
for featurization. The value__other__
should not be used as a user-defined value; if it is, itwill still behave as the default to which all unseen values are mapped.
float
¶Continuous values
max_value=1.0
, min_value=0.0
All values below min_value
will be treated as min_value
, the samehappens for values above max_value
. Hence, if max_value
is set to1
, there is no difference between the slot values 2
and 3.5
interms of featurization (e.g. both values will influence the dialogue inthe same way and the model can not learn to differentiate between them).
list
¶Slot List Rasa Movie
Lists of values
The feature of this slot is set to 1
if a value with a list is set,where the list is not empty. If no value is set, or the empty list is theset value, the feature will be 0
. The length of the list stored inthe slot does not influence the dialogue.
unfeaturized
¶Slot List Rasa Example
Data you want to store which shouldn’t influence the dialogue flow
There will not be any featurization of this slot, hence its value doesnot influence the dialogue flow and is ignored when predicting the nextaction the bot should run.
Maybe your restaurant booking system can only handle bookingsfor up to 6 people. In this case you want the value of theslot to influence the next selected action (and not just whetherit’s been specified). You can do this by defining a custom slot class.
In the code below, we define a slot class called NumberOfPeopleSlot
.The featurization defines how the value of this slot gets converted to a vectorto our machine learning model can deal with.Our slot has three possible “values”, which we can represent witha vector of length 2
.
| not yet set |
| between 1 and 6 |
| more than 6 |
Slot List Rasa Video
Now we also need some training stories, so that Rasa Corecan learn from these how to handle the different situations: