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.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
get_ignored_intents
Returns a list of ignored intents.
Arguments:
domain
- The current model domain.
Returns:
The value/s found in ignored_intents
parameter in the domain.yml
(under forms).
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_for_slot
Extract entities for given name and optional role and group.
Arguments:
name
- entity type (name) of interesttracker
- the trackerslot_to_be_filled
- Slot which is supposed to be filled by this entity.role
- 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
.
get_slot_to_fill
Gets the name of the slot which should be filled next.
When switching to another form, the requested slot setting is still from the previous form and must be ignored.
Returns:
The slot name or None
extract_requested_slot
Extract the value of requested slot from a user input else return None
.
Arguments:
tracker
- a DialogueStateTracker instancedomain
- the current domainslot_to_fill
- the name of the slot to fill
Returns:
a dictionary with one key being the name of the slot to fill and its value being the slot value, or an empty dictionary if no slot value was found.
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 response 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.