rasa.core.actions.action

You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest documentation here.

default_actions

def default_actions(
    action_endpoint: Optional[EndpointConfig] = None) -> List["Action"]

List default actions.

action_for_index

def action_for_index(index: int, domain: Domain,
                       action_endpoint: Optional[EndpointConfig]) -> "Action"

Get an action based on its index in the list of available actions.

Arguments:

Returns: The instantiated Action or None if no Action was found for the given index.

is_retrieval_action

def is_retrieval_action(action_name: Text,
                       retrieval_intents: List[Text]) -> bool

Check if an action name is a retrieval action.

Arguments:

Returns: True if the resolved intent name is present in the list of retrieval intents, False otherwise.

action_for_name_or_text

def action_for_name_or_text(
    action_name_or_text: Text,
    domain: Domain,
    action_endpoint: Optional[EndpointConfig]) -> "Action"

Retrieves an action by its name or by its text in case it's an end-to-end action.

Arguments:

Raises:

Returns: The instantiated action.

create_bot_utterance

def create_bot_utterance(message: Dict[Text, Any]) -> BotUttered

Create BotUttered event from message.

Action Objects

class Action():

Next action to be taken in response to a dialogue state.

name

def name() -> Text

Unique identifier of this simple action.

run

async def run(output_channel: "OutputChannel",
                nlg: "NaturalLanguageGenerator",
                tracker: "DialogueStateTracker",
                domain: "Domain") -> List[Event]

Execute the side effects of this action.

Arguments:

Returns: A list of instances

str

def __str__() -> Text

Returns text representation of form.

event_for_successful_execution

def event_for_successful_execution(prediction: PolicyPrediction) -> ActionExecuted

Event which should be logged for the successful execution of this action.

Arguments:

Returns: Event which should be logged onto the tracker.

ActionBotResponse Objects

class ActionBotResponse(Action):

An action which only effect is to utter a response when it is run.

init

def __init__(name: Text, silent_fail: Optional[bool] = False) -> None

Creates action.

Arguments:

run

async def run(output_channel: "OutputChannel",
                nlg: "NaturalLanguageGenerator",
                tracker: "DialogueStateTracker",
                domain: "Domain") -> List[Event]

Simple run implementation uttering a (hopefully defined) response.

name

def name() -> Text

Returns action name.

ActionEndToEndResponse Objects

class ActionEndToEndResponse(Action):

Action to utter end-to-end responses to the user.

init

def __init__(action_text: Text) -> None

Creates action.

Arguments:

name

def name() -> Text

Returns action name.

run

async def run(output_channel: "OutputChannel",
                nlg: "NaturalLanguageGenerator",
                tracker: "DialogueStateTracker",
                domain: "Domain") -> List[Event]

Runs action (see parent class for full docstring).

event_for_successful_execution

Arguments:

Returns: Event which should be logged onto the tracker.

ActionRetrieveResponse Objects

class ActionRetrieveResponse(ActionBotResponse):

An action which queries the Response Selector for the appropriate response.

init

def __init__(name: Text, silent_fail: Optional[bool] = False) -> None

Creates action. See docstring of parent class.

intent_name_from_action

@staticmethod
def intent_name_from_action(action_name: Text) -> Text

Resolve the name of the intent from the action name.

get_full_retrieval_name

def get_full_retrieval_name(tracker: "DialogueStateTracker") -> Optional[Text]

Returns full retrieval name for the action.

Arguments:

Returns: Full retrieval name of the action if the last user utterance contains a response selector output, None otherwise.

run

async def run(output_channel: "OutputChannel",
                nlg: "NaturalLanguageGenerator",
                tracker: "DialogueStateTracker",
                domain: "Domain") -> List[Event]

Query the appropriate response and create a bot utterance with that.

name

def name() -> Text

Returns action name.