[Solved] Hierarchy to requested slots in FormAction

rasa-core

(Lauraperge) #1

Hey guys,

My problem briefly: I want to change the user’s email on request. I look up the user by user id. So, before performing the change I have two slots that are required to be filled:

  • user id
  • user’s email.

For this, I use FormAction but before changing, I also want a confirmation if the entered user id and user email address are caught by the bot (“Are you sure you want to change the email address of USERID to EMAILADDRESS?”). Thus, my question is whether I can create a FormAction in which I propose a hierarchy to the required slots, i.e.:

  • I want the action to be done only if I have user id, user email AND confirmation.
  • But I only want the bot to ask for confirmation IF I already have the user id and email.

Also, if I cannot create this hierarchy of requested slots, should I do nested actions or what would be the equivalent of this?

Thanks a lot in advance!


(Lauraperge) #2

Okay, so for anyone interested:

The stuff I was looking for is called conditional slot logic:

Slot Filling

Here’s what I did (hope it’s not gonna crash at some random point):

def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""
        if (tracker.get_slot('email')!= None) & (tracker.get_slot('userid')!= None):
            return ["email", "userid", "isconfirmed"] 
        else:
           return ["email", "userid"]