notice

This is documentation for Rasa Open Source Documentation v2.0.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (2.1.x).

Version: 2.0.x

Default Actions

Default actions are actions that are built into the dialogue manager by default. Most of these are automatically predicted based on certain conversation situations. You may want to customize these to personalize your assistant.

Each of these actions have a default behavior, described in the sections below. In order to overwrite this default behavior, write a custom action whose name() method returns the same name as the default action:

class ActionRestart(Action):
def name(self) -> Text:
return "action_restart"
async def run(
self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
# custom behavior
return [...]

Add this action to the actions section of your domain file so your assistant knows to use the custom definition instead of the default one:

actions:
- action_restart

action_listen

This action is predicted to signal that the assistant should do nothing and wait for the next user input.

action_restart

This action resets the whole conversation history, including any slots that were set during it.

It can be triggered by the user in a conversation by sending a "/restart" message, if the RulePolicy is included in the model configuration. If you define an utter_restart response in your domain, this will be sent to the user as well.

action_session_start

This action starts a new conversation session, and is executed in the following situations:

  • at the beginning of each new conversation
  • after a user was inactive for a period defined by the session_expiration_time parameter in the domain's session configuration
  • when a user sends a "/session_start" message during a conversation

The action will reset the conversation tracker, but by default will not clear any slots that were set.

Customization

The default behavior of the session start action is to take all existing slots and to carry them over into the next session. Let's say you do not want to carry over all slots, but only a user's name and their phone number. To do that, you'd override the action_session_start with a custom action that might look like this:

from typing import Text, List, Dict, Any
from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, SessionStarted, ActionExecuted, EventType
from rasa_sdk.executor import CollectingDispatcher
class ActionSessionStart(Action):
def name(self) -> Text:
return "action_session_start"
@staticmethod
def fetch_slots(tracker: Tracker) -> List[EventType]:
"""Collect slots that contain the user's name and phone number."""
slots = []
for key in ("name", "phone_number"):
value = tracker.get_slot(key)
if value is not None:
slots.append(SlotSet(key=key, value=value))
return slots
async def run(
self,
output_channel: "OutputChannel",
nlg: "NaturalLanguageGenerator",
tracker: "DialogueStateTracker",
domain: "Domain",
) -> List[Event]:
# the session should begin with a `session_started` event
events = [SessionStarted(metadata=self.metadata)]
# any slots that should be carried over should come after the
# `session_started` event
events.extend(self.fetch_slots(tracker))
# an `action_listen` should be added at the end as a user message follows
events.append(ActionExecuted("action_listen"))
return events

action_default_fallback

This action undoes the last user-bot interaction and sends the utter_default response if it is defined. It is triggered by low action prediction confidence, if you have this fallback mechanism enabled.

action_deactivate_loop

This action deactivates the active loop and resets the requested slot. This is used when handling unhappy paths in forms.

action_revert_fallback_events

Deprecated!

The action_revert_fallback_events action is deprecated since the 2.0 release. The action_two_stage_fallback action now handles all two-stage fallback behavior

action_two_stage_fallback

This is a fallback loop that can be used to handle low NLU confidence. Read more about handling low NLU confidence.

action_default_ask_affirmation

This action is used by the action_two_stage_fallback loop. It asks the user to confirm the intent of their message. This action can be customized to be more personalized to your specific use case.

action_default_ask_rephrase

This action is used by the action_two_stage_fallback loop if the user denies the intent action_default_ask_affirmation displays. It asks the user to rephrase their message.

action_back

This action undoes the last user-bot interaction. It can be triggered by the user by sending a "/back" message to the assistant if the RulePolicy is configured. |