Hi I am having an issue when validating a slot in form action. Here I am using the validate function to check whether the income is more than the expected level or not. Here is my code lines for validate function in form.
def validate_income(self, value, dispatcher, tracker, domain):
if any(tracker.get_latest_entity_values("income")):
loan_validate_details = yaml_loader("loan_description.yml")
if int(value) < loan_validate_details.get("income_range_to_validate_loan"):
dispatcher.utter_message("Oh Sorry ! Your net income should be higher than Rs.50,000 to eligible for the loan")
logging.debug("deactivate the form")
return (self.deactivate())
else:
return {"income": value}
else:
dispatcher.utter_message("Your given income is not clear")
return {"income": None}
If the income is lower than expected value It gives the following message. Again ask about the next slot loan_amount.
> Oh Sorry ! Your net income should be higher than Rs.50,000 to eligible for the loan
> Okay. What is the loan amount you need?
This is my log file.
2019-10-07 10:24:40,912:INFO:Registered function for 'action_chitchat'.
2019-10-07 10:24:40,912:INFO:Registered function for 'loan_apply_form'.
2019-10-07 10:24:40,912:INFO:Registered function for 'loan_details_form'.
2019-10-07 10:24:40,912:INFO:Registered function for 'loan_rates_form'.
2019-10-07 10:24:40,919:INFO:Action endpoint is up and running. on ('0.0.0.0', 5055)
2019-10-07 10:24:55,272:DEBUG:Received request to run 'loan_apply_form'
2019-10-07 10:24:55,272:DEBUG:There is no active form
2019-10-07 10:24:55,272:DEBUG:Activated the form 'loan_apply_form'
2019-10-07 10:24:55,272:DEBUG:No pre-filled required slots to validate.
2019-10-07 10:24:55,272:DEBUG:Validating user input '{'intent': {'name': 'apply_loan', 'confidence': 0.9982815980911255}, 'entities': [], 'intent_ranking': [{'name': 'apply_loan', 'confidence': 0.9982815980911255}, {'name': 'set_loan_apply_details', 'confidence': 0.0005528468755073845}, {'name': 'help', 'confidence': 0.00029360552434809506}, {'name': 'deny', 'confidence': 0.00019739186973311007}, {'name': 'affirm', 'confidence': 0.00018312766042072326}, {'name': 'ask_loan_rates', 'confidence': 0.00012093983968952671}, {'name': 'goodbye', 'confidence': 7.872865535318851e-05}, {'name': 'out_of_scope', 'confidence': 7.8113007475622e-05}, {'name': 'bot_challenge', 'confidence': 7.422369526466355e-05}, {'name': 'ask_loan_details', 'confidence': 7.2400041972287e-05}], 'text': 'i need loan'}'
2019-10-07 10:24:55,272:DEBUG:Validating extracted slots: {}
2019-10-07 10:24:55,273:DEBUG:Request next slot 'loan_type'
2019-10-07 10:24:55,273:DEBUG:Finished running 'loan_apply_form'
2019-10-07 10:25:05,186:DEBUG:Received request to run 'loan_apply_form'
2019-10-07 10:25:05,187:DEBUG:The form '{'name': 'loan_apply_form', 'validate': True, 'rejected': False, 'trigger_message': {'intent': {'name': 'apply_loan', 'confidence': 0.9982815980911255}, 'entities': [], 'intent_ranking': [{'name': 'apply_loan', 'confidence': 0.9982815980911255}, {'name': 'set_loan_apply_details', 'confidence': 0.0005528468755073845}, {'name': 'help', 'confidence': 0.00029360552434809506}, {'name': 'deny', 'confidence': 0.00019739186973311007}, {'name': 'affirm', 'confidence': 0.00018312766042072326}, {'name': 'ask_loan_rates', 'confidence': 0.00012093983968952671}, {'name': 'goodbye', 'confidence': 7.872865535318851e-05}, {'name': 'out_of_scope', 'confidence': 7.8113007475622e-05}, {'name': 'bot_challenge', 'confidence': 7.422369526466355e-05}, {'name': 'ask_loan_details', 'confidence': 7.2400041972287e-05}], 'text': 'i need loan'}}' is active
2019-10-07 10:25:05,187:DEBUG:Validating user input '{'text': '/set_loan_apply_details{"loan_type": "personal loan"}', 'intent': {'name': 'set_loan_apply_details', 'confidence': 1.0}, 'intent_ranking': [{'name': 'set_loan_apply_details', 'confidence': 1.0}], 'entities': [{'entity': 'loan_type', 'start': 23, 'end': 53, 'value': 'personal loan'}]}'
2019-10-07 10:25:05,187:DEBUG:Trying to extract requested slot 'loan_type' ...
2019-10-07 10:25:05,187:DEBUG:Got mapping '{'type': 'from_entity', 'entity': 'loan_type', 'intent': [], 'not_intent': []}'
2019-10-07 10:25:05,187:DEBUG:Successfully extracted 'personal loan' for requested slot 'loan_type'
2019-10-07 10:25:05,188:DEBUG:Validating extracted slots: {'loan_type': 'personal loan'}
2019-10-07 10:25:05,188:DEBUG:Request next slot 'occupation'
2019-10-07 10:25:05,188:DEBUG:Finished running 'loan_apply_form'
2019-10-07 10:25:06,309:DEBUG:Received request to run 'loan_apply_form'
2019-10-07 10:25:06,310:DEBUG:The form '{'name': 'loan_apply_form', 'validate': True, 'rejected': False, 'trigger_message': {'intent': {'name': 'apply_loan', 'confidence': 0.9982815980911255}, 'entities': [], 'intent_ranking': [{'name': 'apply_loan', 'confidence': 0.9982815980911255}, {'name': 'set_loan_apply_details', 'confidence': 0.0005528468755073845}, {'name': 'help', 'confidence': 0.00029360552434809506}, {'name': 'deny', 'confidence': 0.00019739186973311007}, {'name': 'affirm', 'confidence': 0.00018312766042072326}, {'name': 'ask_loan_rates', 'confidence': 0.00012093983968952671}, {'name': 'goodbye', 'confidence': 7.872865535318851e-05}, {'name': 'out_of_scope', 'confidence': 7.8113007475622e-05}, {'name': 'bot_challenge', 'confidence': 7.422369526466355e-05}, {'name': 'ask_loan_details', 'confidence': 7.2400041972287e-05}], 'text': 'i need loan'}}' is active
2019-10-07 10:25:06,310:DEBUG:Validating user input '{'text': '/set_loan_apply_details{"occupation": "Salaried Employee"}', 'intent': {'name': 'set_loan_apply_details', 'confidence': 1.0}, 'intent_ranking': [{'name': 'set_loan_apply_details', 'confidence': 1.0}], 'entities': [{'entity': 'occupation', 'start': 23, 'end': 58, 'value': 'Salaried Employee'}]}'
2019-10-07 10:25:06,310:DEBUG:Trying to extract requested slot 'occupation' ...
2019-10-07 10:25:06,310:DEBUG:Got mapping '{'type': 'from_entity', 'entity': 'occupation', 'intent': [], 'not_intent': []}'
2019-10-07 10:25:06,310:DEBUG:Successfully extracted 'Salaried Employee' for requested slot 'occupation'
2019-10-07 10:25:06,310:DEBUG:Validating extracted slots: {'occupation': 'Salaried Employee'}
2019-10-07 10:25:06,311:DEBUG:Request next slot 'workplace'
2019-10-07 10:25:06,311:DEBUG:Finished running 'loan_apply_form'
2019-10-07 10:25:25,502:DEBUG:Received request to run 'loan_apply_form'
2019-10-07 10:25:25,502:DEBUG:The form '{'name': 'loan_apply_form', 'validate': True, 'rejected': False, 'trigger_message': {'intent': {'name': 'apply_loan', 'confidence': 0.9982815980911255}, 'entities': [], 'intent_ranking': [{'name': 'apply_loan', 'confidence': 0.9982815980911255}, {'name': 'set_loan_apply_details', 'confidence': 0.0005528468755073845}, {'name': 'help', 'confidence': 0.00029360552434809506}, {'name': 'deny', 'confidence': 0.00019739186973311007}, {'name': 'affirm', 'confidence': 0.00018312766042072326}, {'name': 'ask_loan_rates', 'confidence': 0.00012093983968952671}, {'name': 'goodbye', 'confidence': 7.872865535318851e-05}, {'name': 'out_of_scope', 'confidence': 7.8113007475622e-05}, {'name': 'bot_challenge', 'confidence': 7.422369526466355e-05}, {'name': 'ask_loan_details', 'confidence': 7.2400041972287e-05}], 'text': 'i need loan'}}' is active
2019-10-07 10:25:25,502:DEBUG:Validating user input '{'intent': {'name': 'set_loan_apply_details', 'confidence': 0.9996780157089233}, 'entities': [{'start': 0, 'end': 6, 'value': 'nestle', 'entity': 'workplace', 'confidence': 0.8786339887590385, 'extractor': 'CRFEntityExtractor'}], 'intent_ranking': [{'name': 'set_loan_apply_details', 'confidence': 0.9996780157089233}, {'name': 'bot_challenge', 'confidence': 6.346194277284667e-05}, {'name': 'mood_unhappy', 'confidence': 5.4231888498179615e-05}, {'name': 'greet', 'confidence': 4.334035111241974e-05}, {'name': 'apply_loan', 'confidence': 4.2658004531404004e-05}, {'name': 'affirm', 'confidence': 3.226281114621088e-05}, {'name': 'out_of_scope', 'confidence': 2.823286376951728e-05}, {'name': 'ask_loan_details', 'confidence': 2.1159174139029346e-05}, {'name': 'ask_loan_rates', 'confidence': 1.2601687558344565e-05}, {'name': 'goodbye', 'confidence': 8.597752639616374e-06}], 'text': 'nestle'}'
2019-10-07 10:25:25,502:DEBUG:Trying to extract requested slot 'workplace' ...
2019-10-07 10:25:25,503:DEBUG:Got mapping '{'type': 'from_entity', 'entity': 'workplace', 'intent': [], 'not_intent': []}'
2019-10-07 10:25:25,503:DEBUG:Successfully extracted 'nestle' for requested slot 'workplace'
2019-10-07 10:25:25,503:DEBUG:Validating extracted slots: {'workplace': 'nestle'}
2019-10-07 10:25:25,504:DEBUG:Request next slot 'income'
2019-10-07 10:25:25,504:DEBUG:Finished running 'loan_apply_form'
2019-10-07 10:25:28,967:DEBUG:Received request to run 'loan_apply_form'
2019-10-07 10:25:28,967:DEBUG:The form '{'name': 'loan_apply_form', 'validate': True, 'rejected': False, 'trigger_message': {'intent': {'name': 'apply_loan', 'confidence': 0.9982815980911255}, 'entities': [], 'intent_ranking': [{'name': 'apply_loan', 'confidence': 0.9982815980911255}, {'name': 'set_loan_apply_details', 'confidence': 0.0005528468755073845}, {'name': 'help', 'confidence': 0.00029360552434809506}, {'name': 'deny', 'confidence': 0.00019739186973311007}, {'name': 'affirm', 'confidence': 0.00018312766042072326}, {'name': 'ask_loan_rates', 'confidence': 0.00012093983968952671}, {'name': 'goodbye', 'confidence': 7.872865535318851e-05}, {'name': 'out_of_scope', 'confidence': 7.8113007475622e-05}, {'name': 'bot_challenge', 'confidence': 7.422369526466355e-05}, {'name': 'ask_loan_details', 'confidence': 7.2400041972287e-05}], 'text': 'i need loan'}}' is active
2019-10-07 10:25:28,968:DEBUG:Validating user input '{'intent': {'name': 'set_loan_apply_details', 'confidence': 0.9999376535415649}, 'entities': [{'start': 0, 'end': 5, 'value': '15000', 'entity': 'income', 'confidence': 0.9383069338666249, 'extractor': 'CRFEntityExtractor'}], 'intent_ranking': [{'name': 'set_loan_apply_details', 'confidence': 0.9999376535415649}, {'name': 'goodbye', 'confidence': 1.6766663975431584e-05}, {'name': 'bot_challenge', 'confidence': 1.0748044587671757e-05}, {'name': 'greet', 'confidence': 9.300335477746557e-06}, {'name': 'mood_unhappy', 'confidence': 9.079870324057993e-06}, {'name': 'help', 'confidence': 8.823596544971224e-06}, {'name': 'apply_loan', 'confidence': 2.3936636353028007e-06}, {'name': 'affirm', 'confidence': 2.37354379351018e-06}, {'name': 'out_of_scope', 'confidence': 1.2871890930910013e-06}, {'name': 'ask_loan_rates', 'confidence': 7.206044756458141e-07}], 'text': '15000'}'
2019-10-07 10:25:28,968:DEBUG:Trying to extract requested slot 'income' ...
2019-10-07 10:25:28,968:DEBUG:Got mapping '{'type': 'from_entity', 'entity': 'income', 'intent': [], 'not_intent': []}'
2019-10-07 10:25:28,968:DEBUG:Successfully extracted '15000' for requested slot 'income'
2019-10-07 10:25:28,968:DEBUG:Validating extracted slots: {'income': '15000'}
2019-10-07 10:25:28,977:DEBUG:deactivate the form
2019-10-07 10:25:28,977:DEBUG:Deactivating the form 'loan_apply_form'
2019-10-07 10:25:28,977:WARNING:Returning values in helper validation methods is deprecated. Your `validate_income()` method should return a dict of {'slot_name': value} instead.
2019-10-07 10:25:28,979:DEBUG:Request next slot 'loan_amount'
2019-10-07 10:25:28,979:DEBUG:Finished running 'loan_apply_form'
I don’t know whether I am doing anything wrong here. Any help would be appreciated. Rasa version - 1.3.3 Please ask if you need anything else.