You can do custom extraction and validation of slot values by writing custom actions in three different ways.
You can use the
action_validate_slot_mappings action to define custom extraction and / or validation of slots that
can be set or updated outside of a form context.
This action is called automatically at the end of the default action
so the name must not be changed. If you are using Rasa SDK, you should extend the Rasa SDK
If you are using a different action server, you will need to implement an action class with equivalent functionality to
the Rasa SDK class. Please see the action server docs for details.
With this option, you do not need to specify the
action key in the custom slot mapping,
since the default action
automatically if present in the
actions section of the domain.
Custom actions named
validate_<form name> will run automatically if the form it specifies in its name is activated.
If you are using Rasa SDK, the custom action should inherit from the Rasa SDK
If you are not using Rasa SDK, you will need to implement an action or action class with equivalent functionality to the
FormValidationClass in your custom action server. Please see the action server docs for details.
Regular Custom Action
You can use a regular custom action custom action that returns
events for custom slot extraction. Use this option if neither
validate_<form name> meet your needs.
For example, if you want to reuse the same custom action explicitly in a story or rule, you should use a regular custom
action for custom slot extraction.
A slot validation action should only return
Any other event type will be filtered out by the default action
The name of the custom action must be specified in the
action key of the relevant custom slot mapping
in the domain.
Note that the action name must be listed in the domain
actions section too.
Using different actions for extraction and validation
You can use both a regular custom action and
action_validate_slot_mappings together to extract and validate a slot. For example, you can specify a regular custom action as the
action for a
custom slot mapping, and also add validation logic for the same slot to
action_validate_slot_mappings. The custom action specified in the custom slot mapping will be called first, and
action_validate_slot_mappings will be called afterwards.