Slot List Rasa

  1. Class rasa.core.trackers.DialogueStateTracker (senderid, slots, maxeventhistory = None, sendersource = None) ¶. Maintains the state of a conversation. The field maxeventhistory will only give you these last events, it can be set in the trackerstore.
  2. Hi, were having a hard time to map an entity to a slot, when it doesnt have the same name and we dont explicitly ask for that slot. Looking into the rasa code, we find this line and were wondering if theres a reason why this condition has to be fullfilled. We already got a few solutions but all feel like akward workarounds. So, why are only equally named entities allowed and not the ones the.

I have the value set in tracker.slots'templatename', but don't have access to that value from this function. I am able to access tracker in requiredslots but not slotmappings Rather than hard coding templatename = 'example' I'd like to use the slot value for templatename. In this video you will learn what are slots and how they are useful in creating the Rasa chatbot. Also you will learn what are the different types of slots and how to define them in Rasa chatbot.

Slot

The tracker stores and maintains the state of the dialogue with a single user.It is stored in a tracker store, retrieved when incoming messages for theconversation are received and updated after actions have been executed

Here we go:

Slot List Rasa
class rasa_core.trackers.DialogueStateTracker(sender_id, slots, max_event_history=None)[source]

Bases: object

Maintains the state of a conversation.

The field max_event_history will only give you these last events,it can be set in the tracker_store

applied_events() → List[rasa_core.events.Event][source]
Slot list rasa example

Returns all actions that should be applied - w/o reverted events.

as_dialogue()[source]

Return a Dialogue object containing all of the turns.

This can be serialised and later used to recover the stateof this tracker exactly.

change_form_to(form_name: str) → None[source]

Activate or deactivate a form

clear_followup_action()[source]
Slot list rasa tv

Clears follow up action when it was executed.

copy()[source]

Creates a duplicate of this tracker

current_slot_values()[source]

Return the currently set values of the slots

Slot List Rasa Movie

current_state(event_verbosity: rasa_core.trackers.EventVerbosity = <EventVerbosity.NONE: 1>) → Dict[str, Any][source]

Return the current tracker state as an object.

events_after_latest_restart()[source]

Return a list of events after the most recent restart.

export_stories(e2e=False) → str[source]

Dump the tracker as a story in the Rasa Core story format.

Returns the dumped tracker as a string.

export_stories_to_file(export_path: str = 'debug.md') → None[source]

Dump the tracker as a story to a file.

classmethod from_dict(sender_id: str, events_as_dict: List[Dict[str, Any]], slots: List[rasa_core.slots.Slot], max_event_history: Optional[int] = None) → rasa_core.trackers.DialogueStateTracker[source]

Create a tracker from dump.

The dump should be an array of dumped events. When restoringthe tracker, these events will be replayed to recreate the state.

classmethod from_events(sender_id: str, evts: List[rasa_core.events.Event], slots: List[rasa_core.slots.Slot], max_event_history: Optional[int] = None)[source]
generate_all_prior_trackers()[source]

Returns a generator of the previous trackers of this tracker.

The resulting array is representingthe trackers before each action.

get_last_event_for(event_type: Type[rasa_core.events.Event], action_names_to_exclude: List[str] = None, skip: int = 0) → Optional[rasa_core.events.Event][source]

Gets the last event of a given type which was actually applied.

Args:

event_type: The type of event you want to find.action_names_to_exclude: Events of type ActionExecuted which

should be excluded from the results. Can be used to skipaction_listen events.

skip: Skips n possible results before return an event.

Returns:
event which matched the query or None if no event matched.
get_latest_entity_values(entity_type: str) → Iterator[str][source]

Get entity values found for the passed entity name in latest msg.

If you are only interested in the first entity of a given type usenext(tracker.get_latest_entity_values(“my_entity_name”), None).If no entity is found None is the default result.

get_latest_input_channel() → Optional[str][source]

Get the name of the input_channel of the latest UserUttered event

get_slot(key: str) → Optional[Any][source]

Retrieves the value of a slot.

idx_after_latest_restart()[source]

Slot List Rasa Video

Return the idx of the most recent restart in the list of events.

If the conversation has not been restarted, 0 is returned.

init_copy()[source]

Creates a new state tracker with the same initial values.

is_paused() → bool[source]

State whether the tracker is currently paused.

last_executed_action_has(name: str, skip=0) → bool[source]

Returns whether last ActionExecuted event had a specific name.

Args:
name: Name of the event which should be matched.skip: Skips n possible results in between.
Returns:
True if last executed action had name name, otherwise False.
past_states(domain: Domain) → collections.deque[source]

Generate the past states of this tracker based on the history.

recreate_from_dialogue(dialogue: rasa_core.conversation.Dialogue) → None[source]

Use a serialised Dialogue to update the trackers state.

This uses the state as is persisted in a TrackerStore. If thetracker is blank before calling this method, the final state will beidentical to the tracker from which the dialogue was created.

reject_action(action_name: str) → None[source]
Slot

Notify active form that it was rejected

replay_events()[source]

Update the tracker based on a list of events.

set_form_validation(validate: bool) → None[source]

Toggle form validation

set_latest_action_name(action_name: str) → None[source]

Slot List Rasa Example

Set latest action nameand reset form validation and rejection parameters

travel_back_in_time(target_time: float) → rasa_core.trackers.DialogueStateTracker[source]

Creates a new tracker with a state at a specific timestamp.

A new tracker will be created and all events previous to thepassed time stamp will be replayed. Events that occur exactlyat the target time will be included.

trigger_followup_action(action: str) → None[source]

Triggers another action following the execution of the current.

update(event: rasa_core.events.Event) → None[source]

Modify the state of the tracker according to an Event.

class rasa_core.trackers.EventVerbosity[source]

Bases: enum.Enum

Filter on which events to include in tracker dumps.

AFTER_RESTART = 3
ALL = 4
APPLIED = 2
NONE = 1

Warning: This document is for an old version of Rasa Core.

Here is the full list of slot types defined by Rasa Core.

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 slot. There arealso boolean, 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.

How Rasa Uses Slots¶

The rasa_core.policies.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!

How Slots Get Set¶

You can provide an initial value for a slot in your domain file:

There are multiple ways that slots are set during a conversation:

Slot List Rasa Tv

Slots Set from NLU¶

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.

Slots Set By Clicking Buttons¶

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 Domain Format)

Slots Set by Actions¶

The second option is to set slots by returning events in 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_premuim 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 rather than writing them.

Custom Slot Types¶

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.

Slot List Rasa Youtube

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.

(0,0)not yet set
(1,0)between 1 and 6
(0,1)more than 6

Now we also need some training stories, so that Rasa Corecan learn from these how to handle the different situations:

Have questions or feedback?¶

We have a very active support community on Rasa Community Forumthat is happy to help you with your questions. If you have any feedback for us or a specificsuggestion for improving the docs, feel free to share it by creating an issue on Rasa CoreGitHub repository.