I have been trying to find all the possible ways to exit explicitly from a form after a certain condition is met. But no matter how many times i try i am not able to do it. I am using RASA OPEN SOURCE
def validate_item_name(
self, value: Text, dispatcher: CollectingDispatcher, tracker: Tracker, domain: DomainDict
):
if value.lower() in existing_items:
text = get_text_from_lang(
tracker,
['This item already exists in the inventory. Abandoning action, consider updating it instead.',
'यह आइटम पहले से ही इन्वेंटरी में मौजूद है। इसे अपडेट करने पर विचार करें।']
)
dispatcher.utter_message(text=text)
return {"item_name": None, "cancel_add": "true"}
return [SlotSet("item_name", value)]
- rule: Cancel add item form
condition:
- active_loop: additem_form
- slot_was_set:
- cancel_add: true
steps:
- action: action_deactivateadd_loop
- active_loop: null
class ActionDeactivateAddLoop(Action):
def name(self) -> str:
return "action_deactivateadd_loop"
def run(self,dispatcher, tracker :Tracker, domain:Dict) -> List[Dict]:
cond = tracker.get_slot("cancel_add")
if cond == "true":
return [ActiveLoop(None),AllSlotsReset()]
else:
return []
This is how tried to implement it but it sill didn’t work