Events¶
Conversations in Rasa are represented as a sequence of events. This page lists the event types defined in Rasa Core.
Note
If you are using the Rasa SDK to write custom actions in python,
you need to import the events from rasa_sdk.events
, not from
rasa.core.events
. If you are writing actions in another language,
your events should be formatted like the JSON objects on this page.
General Purpose Events¶
Set a Slot¶
Short: | Event to set a slot on a tracker |
---|---|
JSON: | evt = {"event": "slot", "name": "departure_airport", "value": "BER"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker):
tracker._set_slot(self.key, self.value)
|
Restart a conversation¶
Short: | Resets anything logged on the tracker. |
---|---|
JSON: | evt = {"event": "restart"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker):
from rasa.core.actions.action import ( # pytype: disable=pyi-error
ACTION_LISTEN_NAME,
)
tracker._reset()
tracker.trigger_followup_action(ACTION_LISTEN_NAME)
|
Reset all Slots¶
Short: | Resets all the slots of a conversation. |
---|---|
JSON: | evt = {"event": "reset_slots"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker):
tracker._reset_slots()
|
Schedule a reminder¶
Short: | Schedule an action to be executed in the future. |
---|---|
JSON: | evt={
"event": "reminder",
"action": "my_action",
"date_time": "2018-09-03T11:41:10.128172",
"name": "my_reminder",
"kill_on_user_msg": True,
}
|
Class: |
|
Effect: | When added to a tracker, core will schedule the action to be run in the future. |
Pause a conversation¶
Short: | Stops the bot from responding to messages. Action prediction will be halted until resumed. |
---|---|
JSON: | evt = {"event": "pause"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker):
tracker._paused = True
|
Resume a conversation¶
Short: | Resumes a previously paused conversation. The bot will start predicting actions again. |
---|---|
JSON: | evt = {"event": "resume"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker):
tracker._paused = False
|
Force a followup action¶
Short: | Instead of predicting the next action, force the next action to be a fixed one. |
---|---|
JSON: | evt = {"event": "followup", "name": "my_action"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker.trigger_followup_action(self.action_name)
|
Automatically tracked events¶
User sent message¶
Short: | Message a user sent to the bot. |
---|---|
JSON: | evt={
"event": "user",
"text": "Hey",
"parse_data": {
"intent": {
"name": "greet",
"confidence": 0.9
},
"entities": []
},
"metadata": {},
}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker.latest_message = self
tracker.clear_followup_action()
|
Bot responded message¶
Short: | Message a bot sent to the user. |
---|---|
JSON: | evt = {"event": "bot", "text": "Hey there!", "data": {}}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker.latest_bot_utterance = self
|
Undo a user message¶
Short: | Undoes all side effects that happened after the last user message
(including the |
---|---|
JSON: | evt = {"event": "rewind"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker._reset()
tracker.replay_events()
|
Undo an action¶
Short: | Undoes all side effects that happened after the last action
(including the |
---|---|
JSON: | evt = {"event": "undo"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker._reset()
tracker.replay_events()
|
Log an executed action¶
Short: | Logs an action the bot executed to the conversation. Events that action created are logged separately. |
---|---|
JSON: | evt = {"event": "action", "name": "my_action"}
|
Class: |
|
Effect: | When added to a tracker, this is the code used to update the tracker: def apply_to(self, tracker: "DialogueStateTracker") -> None:
tracker.set_latest_action_name(self.action_name)
tracker.clear_followup_action()
|