Validation doesn't work in form

def validate_<slot-name> doesn’t work in my form class.

the form class is:

class FormGongxiao(FormValidationAction, ABC):
    def name(self) -> Text:
        return "form_gongxiao"

    def required_slots(
            self,
            domain_slots: List[Text],
            dispatcher: "CollectingDispatcher",
            tracker: "Tracker",
            domain: "DomainDict",
    ) -> List[Text]:
        return ["product"]

    def run(
            self,
            dispatcher: "CollectingDispatcher",
            tracker: "Tracker",
            domain: "DomainDict",
    ) -> List[EventType]:
        products = tracker.get_slot('product')
        if isinstance(products, list):
            dispatcher.utter_message("功效xxxx")
        else:
            dispatcher.utter_message(response="utter_code_bug")
        return []

    def validate_product(self,
                         slot_value: Any,
                         dispatcher: CollectingDispatcher,
                         tracker: Tracker,
                         domain: DomainDict,
                         ) -> Dict[Text, Any]:
        print('yanzheng...{}'.format(str(slot_value)))
        print('there are smthing....')
        if slot_value is None:
            p_buttons = [
                {'title': 'shampoo', 'payload': '/gongxiao{"product":"shampoo"}'},
                {'title': 'perfume', 'payload': '/gongxiao{"product":"perfume"}'}
            ]
            msg = "what kind of product?"
            dispatcher.utter_message(text=msg, buttons=p_buttons)
            return {'product': None}
        else:
            return {'product': slot_value}

this is a part of domain:

entities:
  - product

slots:
  product:
    type: list
    mappings:
      - type: from_entity
        entity: product

actions:
  - action_rephrase
  - action_custom_fallback
  - action_goodbye
  - action_greet
  - form_gongxiao

this is rule:

- rule: ask for gongxiao
  steps:
    - intent: gongxiao
    - action: form_gongxiao
    - active_loop: form_gongxiao

- rule: ask for gongxiao cut
  condition:
    - active_loop: form_gongxiao
  steps:
    - intent: goodbye
    - action: action_goodbye
    - slot_was_set:
        - product: null
    - action: action_deactivate_loop
    - active_loop: null
  wait_for_user_input: false

, and no story.

when I send an intent of /gongxiao, nothing in terminal even I am trying to print something, validation never be called. (def run works well.) I can’t find my problem.

  • rasa version 3.5.5

Thank u very much