Dynamic beahavior in Rasa Forms

184 views Asked by At

Hi am experiencing trouble implementing the dynamic behavior. Here is my code

class ValidatehivNotPregForm(FormValidationAction):
    def name(self) -> Text:
        return "validate_NotPreg_form"

    async def required_slots(
        self,
        slots_mapped_in_domain: List[Text],
        dispatcher: "CollectingDispatcher",
        tracker: "Tracker",
        domain: "DomainDict",
    ) -> Optional[List[Text]]:
        additional_slots = []
        if tracker.slots.get("Meds") is True:
            additional_slots.append("howMedsStored")
            additional_slots.append("MedsEnv")
        else:
            additional_slots.append("timeMedIntake")
        return slots_mapped_in_domain + additional_slots

    async def extract_howMedsStored(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        howMedsStored = tracker.get_slot("howMedsStored")
        return {"howMedsStored":howMedsStored}

    async def extract_timeMedIntake(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        timeMedIntake = tracker.get_slot("timeMedIntake")
        return {"timeMedIntake":timeMedIntake}

     async def extract_MedsEnv(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        MedsEnv = tracker.get_slot("MedsEnv")
        return {"MedsEnv":MedsEnv}

Whenever the condition is satisfied in the if statement and the slot "howMedsStored" is filled, I would expect to proceed to another additional slot, but "howMedsStored" is still uttered to infinity. Can someone please help we solve this.

0

There are 0 answers