Hi Rasa Rockers,
please help me, are migrating the code from 1.x to 2.x. where i am facing a challenge to convert the form action into formvalidation. I have pasted my class code here ,
my code stops working on utter_dispacher, I have slots for this form and here i have some business logic for each slot, so going forward ,Will post my submit classes, if it is required. why uttr_dispacher is not working for “text” not sure. someone help me on it.
"(Pdb) n
c:\users\edukondalu_konakanch\documents\vip2\vipactions\pcf_deployment\actions.py(736)next_requested_slot() → dispatcher.utter_message(text=“Please select the vendor and type query again.”) (Pdb) n c:\users\edukondalu_konakanch\documents\vip2\vipactions\pcf_deployment\actions.py(737)next_requested_slot() → return [AllSlotsReset()] (Pdb) n"
class PoInvoiceAction(FormValidationAction):
-
def name(self) → Text:*
-
"""Unique identifier of the form"""*
-
return "validate_po_invoice_form"*
-
def next_requested_slot(*
-
self,*
-
dispatcher: "CollectingDispatcher",*
-
tracker: "Tracker",*
-
domain: "DomainDict",*
-
) → Optional[EventType]:*
-
"""Request the next slot and utter template if needed,*
-
else return None"""*
-
# First check whether the vendor is selected or not*
-
pdb.set_trace()*
-
access_data = get_access_data(tracker)*
-
print("---access_data---",access_data)*
-
vendor_id = access_data["vendor_id"] if "vendor_id" in access_data.keys() else ""*
-
if vendor_id is None or vendor_id == "":*
-
dispatcher.utter_message(text="Please select the vendor and type query again.")*
-
return [AllSlotsReset()]*
-
for slot in self.required_slots(tracker):*
-
if self._should_request_slot(tracker, slot):*
-
logger.debug(f"Request next slot '{slot}'")*
-
if slot == "inv_po_number":*
-
msg = 'Please provide invoice/po number'*
-
info_type = tracker.get_slot('info_type').lower() if tracker.get_slot('info_type') else ''*
-
if info_type in ["po_details", "po_create_date", "po_expire_date", "po_update_date"]:*
-
msg = "Please enter the purchase order(PO) number"*
-
elif info_type in ["inv_reason_hold", "invoice_line_details", "inv_payment_details"]:*
-
msg = "Please enter the invoice number"*
-
dispatcher.utter_message(text=msg)*
-
else:*
-
dispatcher.utter_message(template=f"utter_ask_{slot}", **tracker.slots)*
-
return [SlotSet(REQUESTED_SLOT, slot)]*
-
# no more required slots to fill*
-
return None*
-
@staticmethod*
-
def info_types() → List[Text]:*
-
"""List of supported info types"""*
-
return ["po_details", "po_create_date", "po_expire_date", "po_update_date", "inv_reason_hold",*
-
"invoice_line_details", "inv_payment_details"]*
-
def validate_info_type(*
-
self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker,*
-
domain: Dict[Text, Any]) -> Dict[Text, Any]:*
-
"""Validate info type value"""*
-
print("info_type",value)*
-
if value and isinstance(value, str) and value.lower() in self.info_types():*
-
return {"info_type": value.lower()}*
-
else:*
-
return {"info_type": None}*
-
def validate_inv_po_number(*
-
self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker,*
-
domain: Dict[Text, Any]) -> Dict[Text, Any]:*
-
print("--inside-- po_number")*
-
"""Validate invoice/PO number value"""*
-
val = {"inv_po_number": None}*
-
print("inv_po_num",val)*
-
if value:*
-
val = {"inv_po_number": value}*
-
else:*
-
dispatcher.utter_message(template=f"utter_ask_inv_po_number")*
-
return val*