Skip to content

Custom action class for validating slots with one custom action #6819

Closed
RasaHQ/rasa-sdk
#288
@wochinge

Description

This is actually an SDK issue but I added it here so we can add it to the milestone.

Description of Problem:
Docs specify that all slot validations for a given form is happening as a single function, which is confusing because validation is always unique for each slot. Users will still have to define separate validation functions, but they'll also have to write the logic inside run() for calling each validate method.

Also see the long discussions here

Overview of the Solution:
Some magic class ala

class AbstractFormValidatorAction(Action):

  def run(...):
    slots_to_validate = tracker.form_slots_to_validate()
    for slot_name, value in slots_to_validate.items():
       function_name = f"validate_{slot_name}"
       fn = getattr(self, function_name)
       fn(value, tracker, bla)

Definition of Done:

  • Implementation
  • Updated Rasa Open Source docs

Metadata

Assignees

Labels

area:rasa-sdk 🧑‍💻Everything that touches our python Rasa SDKtype:enhancement ✨Additions of new features or changes to existing ones, should be doable in a single PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions