Need help to build a conditional logic scenario

Hi, I’m looking to build the following story but i have yet to find any useful reference from the forum. Any advise or ideas are much appreciated.

  • I have a bot that will require user to provide slot A and slot B.
  • I allow user to stop and detour at any point of time when answering slot A and slot B. (Thus, user will be redirect back to main menu, in my case)
  • Anytime when the user visit back the bot, I want to first check whether the user filled up both slot A and B.
  • If either one of the slot is not filled, i will continue to ask the user to provide the information.
  • If both slot is fill, I will then ask them whether they want to edit it

What i have tried :

  1. Created a FormAction and set the requested_slot to be A and B
  2. Created a custom Action and do a checking with tracket.get_slot("A") and tracker.get_slot("B"). If either one of A & B is a None value, set a FollowupAction(‘FormAction’)

Problem that i am facing:

  1. The flow will always stuck at the custom Action part, even if i’m still missing out any of the slot to fill.

I’m also trying to figure out is there a way this can be done with just utilizing FormAction? (eg: if requested_slot is A, continue the Form; if requested_slot is None, lead to a custom Action that user can edit the slot values)

Anyone, please enlighten me =)

Regards

I can help you, if you provide code details…

Not sure what you mean when you say “stuck at the custom action part”. Can you explain more?

Hi, so this is something that i ran into:

  • For any new visit, the custom action will trigger first (check whether slot A and B are None, if yes FollowupAction with the FormAction).
  • For some reason, i was unable to proceed to the FormAction. Rasa wil always lead me to the utter_ask_for_modify output i set for when both slot A and B are filled. This is still the case after i ran /restart and reset all slots.

Custom Action

def run(self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]
) -> List[Dict[Text, Any]]:
    if tracker.get_slot('slot_a') != 'None' and tracker.get_slot('slot_b') != 'None':
      print("slot_a: ", tracker.get_slot('slot_a'))
      print("slot_b: ", tracker.get_slot('slot_b')
      dispatcher.utter_message(template = 'utter_ask_for_modify')
      return []
    if tracker.get_slot('slot_a') or tracker.get_slot('slot_b') == 'None':
      print("slot_a: ", tracker.get_slot('slot_a'))
      print("slot_b: ", tracker.get_slot('slot_b'))
      return[FollowupAction('form_action')]

Looking for some pointers on this matter.

Thanks

Shouldn’t 'None' be None (without apostrophes)? You’re checking against the string None instead of a python null value, and it will always trigger utter_ask_for_modify.

Edit: Also… you shouldn’t use != and == with None… Use is and is not, so it would be like this:

if tracker.get_slot('slot_a') is not None and tracker.get_slot('slot_b') is not None:

Good catch and thanks for the advice, tried this and it worked.