I am trying to build conditional logic in my form where based on the response to the first question, different questions will be asked. I am trying to add decision tree like logic in my form. Is there any way to achieve this?
Yes, the required_slots-method let’s you decide which slots you ask for. You can use conditional logic there.
There’s even a section in the docs
I want to go one step further than just basic conditional logic so can I change the following example:
@staticmethod def required_slots(tracker) -> List[Text]: """A list of required slots that the form has to fill""" if tracker.get_slot('cuisine') == 'greek': return ["cuisine", "num_people", "outdoor_seating", "preferences", "feedback"] else: return ["cuisine", "num_people", "preferences", "feedback"]
so that it asks for cuisine as a slot during the form action and then decides to include outdoor seating or not - all during a form.
It does. The method is called every turn
ok awesome then thanks
Hi, is there a way to handle conditional logic either in Form or custom Action? I have in mind a scenario such as :
Prompt user relevant required slots based on slot values
- required fields are A & B
- If either of the two fields are not filled, lead them to fill up the slots by a form
- If both of the fields are filled, trigger another custom action which eventually will ask user whether to edit and will reactivate the forms again with slots all being reset, if user decides to modify.
Any advise on how to tackle such scenario?
I don’t understand your scenario completely.
User enters slots A & B. Now you want to ask him, what to edit?
Sorry, let me give you a little bit more background on this.
So for the first time, user will need to enter slot A & B. But keep in mind that i allow user to detour at any point. For the next visit, user will then either required to fill up whichever slot that is yet to be filled, OR redirect to another action whereby i ask user whether they wanted to edit the two slot values that they provided previously.
Does this make any sense?
A little better, yes.
Why are you stuck with that?