notice
This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
rasa.core.actions.action
default_actions
List default actions.
action_for_index
Get an action based on its index in the list of available actions.
Arguments:
index
- The index of the action. This is usually used byPolicy
s as they predict the action index instead of the name.domain
- TheDomain
of the current model. The domain contains the actions provided by the user + the default actions.action_endpoint
- Can be used to runcustom_actions
(e.g. using therasa-sdk
).
Returns:
The instantiated Action
or None
if no Action
was found for the given
index.
is_retrieval_action
Check if an action name is a retrieval action.
The name for a retrieval action has an extra utter_
prefix added to
the corresponding retrieval intent name.
Arguments:
action_name
- Name of the action.retrieval_intents
- List of retrieval intents defined in the NLU training data.
Returns:
True
if the resolved intent name is present in the list of retrieval
intents, False
otherwise.
action_for_name_or_text
Retrieves an action by its name or by its text in case it's an end-to-end action.
Arguments:
action_name_or_text
- The name of the action.domain
- The current model domain.action_endpoint
- The endpoint to execute custom actions.
Raises:
ActionNotFoundException
- If action not in current domain.
Returns:
The instantiated action.
create_bot_utterance
Create BotUttered event from message.
Action Objects
Next action to be taken in response to a dialogue state.
name
Unique identifier of this simple action.
run
Execute the side effects of this action.
Arguments:
nlg
- whichnlg
to use for response generationoutput_channel
-output_channel
to which to send the resulting message.tracker
DialogueStateTracker - the state tracker for the current user. You can access slot values usingtracker.get_slot(slot_name)
and the most recent user message istracker.latest_message.text
.domain
Domain - the bot's domain
Returns:
A list of :class:rasa.core.events.Event
instances
__str__
Returns text representation of form.
event_for_successful_execution
Event which should be logged for the successful execution of this action.
Arguments:
prediction
- Prediction which led to the execution of this event.
Returns:
Event which should be logged onto the tracker.
ActionBotResponse Objects
An action which only effect is to utter a response when it is run.
__init__
Creates action.
Arguments:
name
- Name of the action.silent_fail
-True
if the action should fail silently in case no response was defined for this action.
run
Simple run implementation uttering a (hopefully defined) response.
name
Returns action name.
ActionEndToEndResponse Objects
Action to utter end-to-end responses to the user.
__init__
Creates action.
Arguments:
action_text
- Text of end-to-end bot response.
name
Returns action name.
run
Runs action (see parent class for full docstring).
event_for_successful_execution
Event which should be logged for the successful execution of this action.
Arguments:
prediction
- Prediction which led to the execution of this event.
Returns:
Event which should be logged onto the tracker.
ActionRetrieveResponse Objects
An action which queries the Response Selector for the appropriate response.
__init__
Creates action. See docstring of parent class.
intent_name_from_action
Resolve the name of the intent from the action name.
run
Query the appropriate response and create a bot utterance with that.
name
Returns action name.
ActionBack Objects
Revert the tracker state by two user utterances.
name
Returns action back name.
__init__
Initializes action back.
run
Runs action. Please see parent class for the full docstring.
ActionListen Objects
The first action in any turn - bot waits for a user message.
The bot should stop taking further actions and wait for the user to say something.
run
Runs action. Please see parent class for the full docstring.
ActionRestart Objects
Resets the tracker to its initial state.
Utters the restart response if available.
name
Returns action restart name.
__init__
Initializes action restart.
run
Runs action. Please see parent class for the full docstring.
ActionSessionStart Objects
Applies a conversation session start.
Takes all SlotSet
events from the previous session and applies them to the new
session.
run
Runs action. Please see parent class for the full docstring.
ActionDefaultFallback Objects
Executes the fallback action and goes back to the prev state of the dialogue.
name
Returns action default fallback name.
__init__
Initializes action default fallback.
run
Runs action. Please see parent class for the full docstring.
ActionDeactivateLoop Objects
Deactivates an active loop.
run
Runs action. Please see parent class for the full docstring.
RemoteAction Objects
action_response_format_spec
Expected response schema for an Action endpoint.
Used for validation of the response returned from the Action endpoint.
run
Runs action. Please see parent class for the full docstring.
ActionExecutionRejection Objects
Raising this exception will allow other policies to predict a different action
ActionRevertFallbackEvents Objects
Reverts events which were done during the TwoStageFallbackPolicy
.
This reverts user messages and bot utterances done during a fallback
of the TwoStageFallbackPolicy
. By doing so it is not necessary to
write custom stories for the different paths, but only of the happy
path. This is deprecated and can be removed once the
TwoStageFallbackPolicy
is removed.
run
Runs action. Please see parent class for the full docstring.
ActionUnlikelyIntent Objects
An action that indicates that the intent predicted by NLU is unexpected.
This action can be predicted by UnexpecTEDIntentPolicy
.
name
Returns the name of the action.
run
Runs action. Please see parent class for the full docstring.
has_user_affirmed
Indicates if the last executed action is action_default_ask_affirmation
.
ActionDefaultAskAffirmation Objects
Default implementation which asks the user to affirm his intent.
It is suggested to overwrite this default action with a custom action to have more meaningful prompts for the affirmations. E.g. have a description of the intent instead of its identifier name.
run
Runs action. Please see parent class for the full docstring.
ActionDefaultAskRephrase Objects
Default implementation which asks the user to rephrase his intent.
name
Returns action default ask rephrase name.
__init__
Initializes action default ask rephrase.