I am trying to Validate slots using DB and according to docs if slot’s value is not matched, none is returned. My goal is when the value of the slot is None(i.e. not present in the database) ask the question again to the user with some modifications. How to achieve this. If my question is missing information, feel free to ask it.
P.S.: I am new to this field and this is my first time asking a question.
My form-action looks like this
class ActionSearchRestaurants(FormAction): RANDOMIZE = False
@staticmethod def required_fields(): return [ FreeTextFormField("appliance"), FreeTextFormField("issue"), FreeTextFormField("modelnumber"), FreeTextFormField("serialnumber"), FreeTextFormField("name"), FreeTextFormField("email"), FreeTextFormField("address"), FreeTextFormField("pincode"), FreeTextFormField("date"), FreeTextFormField("timeslots"), BooleanFormField("confirmcomplain", "affirm", "deny") ] def name(self): return 'action_get_complaint_detail' def submit(self, dispatcher, tracker, domain): dispatcher.utter_message("Your complaint has been logged successfully !!!!.") return []
My custom form field looks like this
class CustomFormField(FormField): # noinspection PyMethodMayBeStatic def validate(self, entity, value): """Check if extracted value for a requested slot is valid. Users should override this to implement custom validation logic, returning None indicates a negative validation result, and the slot will not be set. """ df = pd.read_excel('SampleModelSerialGEA.xlsx') print(value) if entity == 'appliance': ###IMP :: can reduce appliance value to one allowed here if not any(df.loc[:, 'Product Line'] == value): value = None if entity == 'modelnumber': if not any(df.loc[:, 'Model Number'] == value): value = None if entity == 'serialnumber': if not any(df.loc[:, 'Serial Number'] == value): value = None return value