notice

This is unreleased documentation for Rasa Open Source Documentation Master/Unreleased version.
For the latest released documentation, see the latest version (2.0.x).

Version: Master/Unreleased

rasa.shared.core.events

deserialise_events

deserialise_events(serialized_events: List[Dict[Text, Any]]) -> List["Event"]

Convert a list of dictionaries to a list of corresponding events.

Example format: [{"event": "slot", "value": 5, "name": "my_slot"}]

md_format_message

md_format_message(text: Text, intent: Optional[Text], entities: Union[Text, List[Any]]) -> Text

Uses NLU parser information to generate a message with inline entity annotations.

Arguments:

  • text - text of the message
  • intent - intent of the message
  • entities - entities of the message

Returns:

Message with entities annotated inline, e.g. I am from [Berlin]{"entity": "city"}.

split_events

split_events(events: Iterable["Event"], event_type_to_split_on: Type["Event"], additional_splitting_conditions: Optional[Dict[Text, Any]] = None, include_splitting_event: bool = True) -> List[List["Event"]]

Splits events according to an event type and condition.

Examples:

Splitting events according to the event type ActionExecuted and the action_name 'action_session_start' would look as follows:

>> _events = split_events( events, ActionExecuted,

  • {"action_name" - "action_session_start"}, True )

Arguments:

  • events - Events to split.
  • event_type_to_split_on - The event type to split on.
  • additional_splitting_conditions - Additional event attributes to split on.
  • include_splitting_event - Whether the events of the type on which the split is based should be included in the returned events.

Returns:

The split events.

do_events_begin_with_session_start

do_events_begin_with_session_start(events: List["Event"]) -> bool

Determines whether events begins with a session start sequence.

A session start sequence is a sequence of two events: an executed action_session_start as well as a logged session_started.

Arguments:

  • events - The events to inspect.

Returns:

Whether or not events begins with a session start sequence.

Event Objects

class Event()

Events describe everything that occurs in a conversation and tell the :class:rasa.shared.core.trackers.DialogueStateTracker how to update its state.

resolve_by_type

| @staticmethod
| resolve_by_type(type_name: Text, default: Optional[Type["Event"]] = None) -> Optional[Type["Event"]]

Returns a slots class by its type name.

UserUttered Objects

class UserUttered(Event)

The user has said something to the bot.

As a side effect a new Turn will be created in the Tracker.

as_sub_state

| as_sub_state() -> Dict[Text, Union[None, Text, List[Optional[Text]]]]

Turns a UserUttered event into a substate containing information about entities, intent and text of the UserUttered

Returns:

a dictionary with intent name, text and entities

BotUttered Objects

class BotUttered(Event)

The bot has said something to the user.

This class is not used in the story training as it is contained in the

ActionExecuted class. An entry is made in the Tracker.

message

| message() -> Dict[Text, Any]

Return the complete message as a dictionary.

SlotSet Objects

class SlotSet(Event)

The user has specified their preference for the value of a slot.

Every slot has a name and a value. This event can be used to set a value for a slot on a conversation.

As a side effect the Tracker's slots will be updated so that tracker.slots[key]=value.

Restarted Objects

class Restarted(Event)

Conversation should start over & history wiped.

Instead of deleting all events, this event can be used to reset the trackers state (e.g. ignoring any past user messages & resetting all the slots).

UserUtteranceReverted Objects

class UserUtteranceReverted(Event)

Bot reverts everything until before the most recent user message.

The bot will revert all events after the latest UserUttered, this also means that the last event on the tracker is usually action_listen and the bot is waiting for a new user message.

AllSlotsReset Objects

class AllSlotsReset(Event)

All Slots are reset to their initial values.

If you want to keep the dialogue history and only want to reset the slots, you can use this event to set all the slots to their initial values.

ReminderScheduled Objects

class ReminderScheduled(Event)

Schedules the asynchronous triggering of a user intent (with entities if needed) at a given time.

__init__

| __init__(intent: Text, trigger_date_time: datetime, entities: Optional[List[Dict]] = None, name: Optional[Text] = None, kill_on_user_message: bool = True, timestamp: Optional[float] = None, metadata: Optional[Dict[Text, Any]] = None) -> None

Creates the reminder

Arguments:

  • intent - Name of the intent to be triggered.
  • trigger_date_time - Date at which the execution of the action should be triggered (either utc or with tz).
  • name - ID of the reminder. If there are multiple reminders with the same id only the last will be run.
  • entities - Entities that should be supplied together with the triggered intent.
  • kill_on_user_message - True means a user message before the trigger date will abort the reminder.
  • timestamp - Creation date of the event.
  • metadata - Optional event metadata.

ReminderCancelled Objects

class ReminderCancelled(Event)

Cancel certain jobs.

__init__

| __init__(name: Optional[Text] = None, intent: Optional[Text] = None, entities: Optional[List[Dict]] = None, timestamp: Optional[float] = None, metadata: Optional[Dict[Text, Any]] = None) -> None

Creates a ReminderCancelled event.

If all arguments are None, this will cancel all reminders. are to be cancelled. If no arguments are supplied, this will cancel all reminders.

Arguments:

  • name - Name of the reminder to be cancelled.
  • intent - Intent name that is to be used to identify the reminders to be cancelled.
  • entities - Entities that are to be used to identify the reminders to be cancelled.
  • timestamp - Optional timestamp.
  • metadata - Optional event metadata.

cancels_job_with_name

| cancels_job_with_name(job_name: Text, sender_id: Text) -> bool

Determines if this ReminderCancelled event should cancel the job with the given name.

Arguments:

  • job_name - Name of the job to be tested.
  • sender_id - The sender_id of the tracker.

Returns:

True, if this ReminderCancelled event should cancel the job with the given name, and False otherwise.

ActionReverted Objects

class ActionReverted(Event)

Bot undoes its last action.

The bot reverts everything until before the most recent action. This includes the action itself, as well as any events that action created, like set slot events - the bot will now predict a new action using the state before the most recent action.

StoryExported Objects

class StoryExported(Event)

Story should get dumped to a file.

FollowupAction Objects

class FollowupAction(Event)

Enqueue a followup action.

ConversationPaused Objects

class ConversationPaused(Event)

Ignore messages from the user to let a human take over.

As a side effect the Tracker's paused attribute will be set to True.

ConversationResumed Objects

class ConversationResumed(Event)

Bot takes over conversation.

Inverse of PauseConversation. As a side effect the Tracker's paused attribute will be set to False.

ActionExecuted Objects

class ActionExecuted(Event)

An operation describes an action taken + its result.

It comprises an action and a list of events. operations will be appended to the latest Turn`` in Tracker.turns`.

as_sub_state

| as_sub_state() -> Dict[Text, Text]

Turns ActionExecuted into a dictionary containing action name or action text. One action cannot have both set at the same time

Returns:

a dictionary containing action name or action text with the corresponding key

AgentUttered Objects

class AgentUttered(Event)

The agent has said something to the user.

This class is not used in the story training as it is contained in the ActionExecuted class. An entry is made in the Tracker.

ActiveLoop Objects

class ActiveLoop(Event)

If name is not None: activates a loop with name else deactivates active loop.

LegacyForm Objects

class LegacyForm(ActiveLoop)

Legacy handler of old Form events.

The ActiveLoop event used to be called Form. This class is there to handle old legacy events which were stored with the old type name form.

LoopInterrupted Objects

class LoopInterrupted(Event)

Event added by FormPolicy and RulePolicy to notify form action whether or not to validate the user input.

LegacyFormValidation Objects

class LegacyFormValidation(LoopInterrupted)

Legacy handler of old FormValidation events.

The LoopInterrupted event used to be called FormValidation. This class is there to handle old legacy events which were stored with the old type name form_validation.

ActionExecutionRejected Objects

class ActionExecutionRejected(Event)

Notify Core that the execution of the action has been rejected

SessionStarted Objects

class SessionStarted(Event)

Mark the beginning of a new conversation session.