Hello everyone, I am using rasa 2.8 and trying to update the required slot according to the user’s answer. The problem is that validation for the custom action is called when I run rasa shell --debug, but I am not sure why required slots are not updated. I am also not able to see the print() in rasa run actions terminal, so I am not able to debug the code and find the problem. Below is the custom action class that I am trying to run.
class ValidateSubjectiveFinancialHealthScoreForm( FormValidationAction, FinancialHealthScoreForm ): “”“Validates slots given to Financial Health Score Form.”""
def name(self) -> Text:
"""Unique identifier of the Validation."""
return "validate_subjective_financial_health_score_form"
async def required_slots(
self,
domain_slots: List[Text],
_dispatcher: CollectingDispatcher,
_tracker: Tracker,
_domain: Dict[Text, Any],
) -> List[Text]:
updated_slots = domain_slots.copy()
if str(_tracker.get_slot("household_spending_q1")) == "/choice_1":
updated_slots.append("household_spending_q1a")
else:
updated_slots.append("household_spending_q1b")
return updated_slots
@staticmethod
def validation_helper(
slot_value: Any,
slot_name: Text,
slot_mappings: Dict[str, int],
) -> Dict[Text, Any]:
"""Unique identifier of the action."""
if slot_value.lower() in slot_mappings.keys():
return {slot_name: slot_value}
else:
# validation failed, set this slot to None so that the
# user will be asked for the slot again
return {slot_name: None}
def validate_household_net_income_q0(
self,
_slot_value: Any,
_dispatcher: CollectingDispatcher,
_tracker: Tracker,
_domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""Validate net_income value."""
entity = get_entity_details(_tracker, "number")
amount = parse_duckling_currency(entity)
net_income = amount.get("amount_of_money")
return {self._questions[0]: net_income}
def validate_household_spending_q1(
self,
slot_value: Any,
_dispatcher: CollectingDispatcher,
_tracker: Tracker,
_domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""Validate household spending value."""
return self.validation_helper(
slot_value, self._questions[1], self._q_mappings[1]
)
def validate_household_spending_q1a(
self,
slot_value: Any,
_dispatcher: CollectingDispatcher,
_tracker: Tracker,
_domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""Validate household spending value."""
return self.validation_helper(
slot_value, self._questions[2], self._q_mappings[2]
)
def validate_household_spending_q1b(
self,
slot_value: Any,
_dispatcher: CollectingDispatcher,
_tracker: Tracker,
_domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""Validate household spending value."""
return self.validation_helper(
slot_value, self._questions[3], self._q_mappings[3]
)