Having only custom slot mapping in rasa 2.1.3 forms

Hi

I have been trying to implement forms in rasa 2.1.3. I am filling all the slot with custom slot mapping and according to documentation here, i should only mention slots that use pre-defined mapping in the domain.yml. so here is what my domain.yml looks like for forms.

slots:
  avdt_flag:
    type: text
    influence_conversation: true
forms:
  comparison_form
responses:
  utter_begin_comparison:
  - text: Lets compare!

But this is not working. None of my required slots are getting filled. Here is my actions.py.

class AskForSlotActionCompareWhat(Action):
    def name(self) -> Text:
        return "action_ask_compare_what"

    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        metric_candidates = ['visits', 'visitors']
        button_info = {"1": metric_candidates}
        message, buttons = button_shower(
                                            self.name(),
                                            button_info,
                                            tag="1"
                                            )
        print(message)
        print(buttons)
        dispatcher.utter_message(
                    text=message,
                    buttons=buttons)
        return []


class AskForSlotActionCompareFrom(Action):
    def name(self) -> Text:
        return "action_ask_compare_from"

    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        tscale_candidates = list(format_timescale.data.get(
                                        "comparison_timeperiods").keys())
        button_info = {"1": tscale_candidates}
        message, buttons = button_shower(
                                            self.name(),
                                            button_info,
                                            tag="1"
                                            )
        dispatcher.utter_message(
                    text="",
                    buttons=buttons)
        return []


class AskForSlotActionCompareWith(Action):
    def name(self) -> Text:
        return "action_ask_compare_with"

    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        tscale_candidates = list(format_timescale.data.get(
                                        "comparison_timeperiods").keys())
        button_info = {"1": tscale_candidates}
        message, buttons = button_shower(
                                            self.name(),
                                            button_info,
                                            tag="1"
                                            )
        dispatcher.utter_message(
                    text="",
                    buttons=buttons)
        return []


class ValidateComparisonForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_comparison_form"

    async def required_slots(
        self,
        slots_mapped_in_domain: List[Text],
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict,
    ) -> Optional[List[Text]]:
        required_slots = ["compare_what", "compare_from", "compare_with"]
        return required_slots

    async def extract_compare_what(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:

        # get the entities
        extracted_ents = CustomEntityExtractor.get_entity(
                                    tracker.latest_message['entities'])
        what_compare = extracted_ents.get('what_compare')
        return {"compare_what": what_compare}

    async def extract_compare_from(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        # get the entities
        extracted_ents = CustomEntityExtractor.get_entity(
                                    tracker.latest_message['entities'])
        from_compare = extracted_ents.get('from_compare')

        return {"compare_from": from_compare}

    async def extract_compare_with(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        # get the entities
        extracted_ents = CustomEntityExtractor.get_entity(
                                    tracker.latest_message['entities'])
        with_compare = extracted_ents.get('with_compare')

        return {"compare_with": with_compare}


class ActionSubmitComparisonForm(Action):
    def name(self) -> Text:
        return "ca_submit_comparison_form"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        dispatcher.utter_message(text="Running requested comparison")

@akelad Is there something missing as its not working. Not even the actions to ask for slots are getting executed. How to make it work? I also checked this issue on github issue but its not clear.

Hey @akelad any solution here ? I am facing the same issue. How should one use custom slot mappings if the forms slots are only using custom slot mapping. My rasa version is 2.2.8

Hi,

I have the same problem and question. I want to use only custom slot mappings but it doesn’t seem to work. My rasa version is 2.4.0. Has somebody any idea? The problem is discuessed here and as i understand also solved but it doesn’t work.

Is there any solution for this issue to have forms with only custom slot mappings?

Yes there is a solution for having only custom slot mappings (at least on rasa 2.6 it works). You need to set the required_slots key to an empty dictionary for your form, like this:

forms:
    comparison_form:
        required_slots: {}

Do add the slot to your domain “slots” key as well.