Rasa Forms issues

Hello,

I have tried to do a Forms in Rasa, but it does not work, it recognizes the action of the forms but when I want to validate the slot it tells me that it does not understand.

The bot is being developed with the following versions:

  • Rasa 2.6.1
  • Rasa SDK 2.6.0

I add the rules and the action that I have.

Action

class ValidateRestaurantForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_restaurant_form"

    @staticmethod
    def cuisine_db() -> List[Text]:
        """Database of supported cuisines"""

        return ["caribbean", "chinese", "french"]

    def validate_cuisine(
        self,
        slot_value: Any,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: DomainDict,
    ) -> Dict[Text, Any]:
        """Validate cuisine value."""

        print("----------------------------------------------------------")
        if slot_value.lower() in self.cuisine_db():
            # validation succeeded, set the value of the "cuisine" slot to value
            return {"cuisine": slot_value}
        else:
            print("*********************************************************")
            # validation failed, set this slot to None so that the
            # user will be asked for the slot again
            return {"cuisine": None}

Rules

  - rule: Activate form
    steps:
    - intent: request_restaurant
    - action: restaurant_form
    - active_loop: restaurant_form

  - rule: Submit form
    condition:
    # Condition that form is active.
    - active_loop: restaurant_form
    steps:
    # Form is deactivated
    - action: restaurant_form
    - active_loop: null
    - slot_was_set:
      - requested_slot: null
    # The actions we want to run when the form is submitted.
    - action: utter_submit
    - action: utter_slots_values

Stories

- story: Stories 01
  steps:
  - intent: Intent_x
  - action: restaurant_form
  - active_loop: restaurant_form
  - slot_was_set:
    - requested_slot: cuisine

Domain

version: "2.0"

intents:
  - Intent_x
  - stop
  - affirm
  - deny
  - request_restaurant:
      use_entities: []

entities:
  - cuisine

slots:
  cuisine:
    type: text
    influence_conversation: false
    auto_fill: false

responses:
  utter_ask_cuisine:
    - text: "What cuisine?"
  utter_wrong_cuisine:
    - text: "Cuisine type is not in the database, please try again"
  utter_submit:
  - text: "All done!"
  utter_slots_values:
    - text: "I am going to run a restaurant search using the following parameters:\n
             - cuisine: {cuisine}"
  utter_ask_continue:
    - text: "Do you want to continue?"

actions:
  - validate_restaurant_form

forms:
  restaurant_form:
    required_slots:
        cuisine:
          - type: from_entity
            entity: cuisine

Greetings!

Hi @SpyrosCapetanopulos ,

Could you please add one method required_slot() before validation? For syntax you can refer document,

I hope this will help you.

Hi, thank you very much for your answer, but it didn’t work.

I have followed the Rasa Documentation examples but nothing.