I have followed rasa documentation on custom slot mapping but I still get my rasa form unable to extract slot. I have a form with six input of which only one is connected to an entity. Below is my actions.py file:
class ActionFormInfo(FormAction): def name(self) -> Text: """Unique identifier of the form""" return "form_filling" @staticmethod def required_slots(tracker: Tracker) -> List[Text]: """A list of required slots that the form has to fill""" service = tracker.get_slot('SERVICE') if tracker.get_slot('PICKUP') == 'YES': return ["KG", "FULLNAME", "PHONE", "PICKUP", "ADDRESS"] else: return ["KG", "FULLNAME", "PHONE", "PICKUP"] ################################# form validation section ############################## ####################################################################################### ###################################################################################### ########################## validate input for cylinder kg ############################## @staticmethod def kg_db() -> List[Text]: return [ 1,2,3,5,6,10, 12.5,15, 20, 50 ] def validate_KG( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Dict[Text, Any]: """Validate cylinder Kg value.""" text_strip = value.strip() text_to_num = int(text_strip) if text_to_num in self.kg_db(): return {"KG": value} else: print(value) dispatcher.utter_message(template="utter_wrong_kg_value") return {"KG": None} ########################## validate input for phone number ############################## def validate_PHONE( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Dict[Text, Any]: """Validate Phone number value.""" digit_count = len(value) digit_strip = value.strip() digit_to_num_check = int(digit_strip) if digit_count == 11 and digit_to_num_check: return {"PHONE": value} else: print(value) dispatcher.utter_message(template="utter_wrong_phone_value") return {"PHONE": None} ########################## validate input of pickup form field ############################## @staticmethod def pickup_db() -> List[Text]: """Database of supported pickup response""" return [ "YES", "NO" ] def validate_PICKUP( self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> Dict[Text, Any]: value_stripe = value.strip() value_upper = value_stripe.upper() if value_upper in self.pickup_db(): return {"PICKUP": value_upper} else: dispatcher.utter_message(template="utter_wrong_pickup_value") return {"PICKUP": None} ################################# Slot mapping section ################################# ####################################################################################### ###################################################################################### def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: return { "service": [self.from_entity(entity="SERVICE"), self.from_text()], } ################################# form submit section ################################# ####################################################################################### ###################################################################################### def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: ########## get record from SERVICE slot ########## service = tracker.get_slot('SERVICE') distance = 0 if tracker.get_slot("PICKUP") == "YES": ########## get the the pickup address ########## pickup_address = tracker.get_slot('ADDRESS') ########## call function to calculate km ########## distance = calculate_km('pickup_address') ########## save cal KM to slot ########## SlotSet("KILOMETER", distance) ########## calculate delivery fee section ########## #################################################### ########## remove trailing space from cal km if any ########## distance = distance.strip() transport_fee = float(distance) * (50*2) ########## get service fee from api ########## product_fee =3000 total = int(transport_fee ) + product_fee ########## save fee to slot depending on the PICKUP ########## if tracker.get_slot('PICKUP') == "Yes": SlotSet('FEE', total) else: SlotSet('FEE', product_fee) ########## display submit button based on PICKUP ########## Guage = tracker.get_slot('KG') if tracker.get_slot('PICKUP') == 'YES': dispatcher.utter_message( template="utter_submit", kg=Guage, fullname=tracker.get_slot('FULLNAME'), phonenumber=tracker.get_slot('PHONE'), staffpick=tracker.get_slot('PICKUP'), pickupaddress=tracker.get_slot('ADDRESS'), total=tracker.get_slot('FEE'), service = tracker.get_slot('SERVICE') ) else: dispatcher.utter_message( template="utter_submit_reponse_no", kg=Guage, fullname=tracker.get_slot('FULLNAME'), phonenumber=tracker.get_slot('PHONE'), staffpick=tracker.get_slot('PICKUP'), total=tracker.get_slot('FEE'), service = tracker.get_slot('SERVICE') ) return []
Any help will be appreciated. Thanks in advance