notice
This is documentation for Rasa Open Source Documentation v2.2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (2.3.x).
rasa.core.actions.forms
FormAction Objects
Action which implements and executes the form logic.
__init__
Creates a FormAction
.
Arguments:
form_name
- Name of the form.action_endpoint
- Endpoint to execute custom actions.
required_slots
A list of required slots that the form has to fill.
Returns:
A list of slot names.
from_entity
A dictionary for slot mapping to extract slot value.
From:
- an extracted entity
- conditioned on
- intent if it is not None
- not_intent if it is not None, meaning user intent should not be this intent
- role if it is not None
- group if it is not None
get_mappings_for_slot
Get mappings for requested slot.
If None, map requested slot to an entity with the same name
intent_is_desired
Check whether user intent matches intent conditions
entity_is_desired
Check whether slot should be filled by an entity in the input or not.
Arguments:
slot_mapping
- Slot mapping.slot
- The slot to be filled.entity_type_of_slot_to_fill
- Entity type of slot to fill.tracker
- The tracker.domain
- The domain.
Returns:
True, if slot should be filled, false otherwise.
get_entity_value
Extract entities for given name and optional role and group.
Arguments:
name
- entity type (name) of interesttracker
- the trackerrole
- optional entity role of interestgroup
- optional entity group of interest
Returns:
Value of entity.
extract_other_slots
Extract the values of the other slots
if they are set by corresponding entities from the user input
else return None
.
extract_requested_slot
Extract the value of requested slot from a user input
else return None
.
validate_slots
Validate the extracted slots.
If a custom action is available for validating the slots, we call it to validate them. Otherwise there is no validation.
Arguments:
slot_candidates
- Extracted slots which are candidates to fill the slots required by the form.tracker
- The current conversation tracker.domain
- The current model domain.output_channel
- The output channel which can be used to send messages to the user.nlg
-NaturalLanguageGenerator
to use for response generation.
Returns:
The validation events including potential bot messages and SlotSet
events
for the validated slots.
validate
Extract and validate value of requested slot.
If nothing was extracted reject execution of the form action. Subclass this method to add custom validation and rejection logic
request_next_slot
Request the next slot and utter template if needed, else return None
.
activate
Activate form if the form is called for the first time.
If activating, validate any required slots that were filled before
form activation and return Form
event with the name of the form, as well
as any SlotSet
events from validation of pre-filled slots.
Arguments:
output_channel
- The output channel which can be used to send messages to the user.nlg
-NaturalLanguageGenerator
to use for response generation.tracker
- Current conversation tracker of the user.domain
- Current model domain.
Returns:
Events from the activation.