Hi everyone.
I have come across to this problem when I can’t return SlotSet in the form action and continue having the form on its own.
Suppose I have 2 slots, “A
”, and “B
”.
-
I have to call an api and set the slot “
A
” with the response value. -
Check the value of slot “
A
”. -
-
If “
A
” is None: No need of the form. Nothing should be executed. -
If “
A
” is not None: I need to run a form action asking slot “B
”, which should ask smth like"I have counted {"A"} for you. If you don't agree with it, type your suggestion below"
.
-
If “
-
Then I extract slot “
B
” from user answer and set my slot “B
”. (If applicable)
So the question is how to do SlotSet inside form class? Without using separate Action for the slot filling step (step 1.) outside the form.
I have tried all of the following:
- Defined a
run(self, dispatcher, tracker, domain)
method in my form class, where I called the api and returnedSlotSet
(imported from rasa_sdk.events) in that method. In therequired_slots(tracker)
method I checked the value of the slot “A
” withtracker.get_slot("A")
and returned “B
” only if the slot “A
” was filled. Eventually,SlotSet
succeeded, but my form finished running after that (Action Server logs were likeDEBUG rasa_sdk.executor - Finished running 'my_form'
- The same as above, just changed the name
run
into something else. EvenSlotSet
didn’t work in this case. Not surprising. I didn’t call it anywhere and it wasn’t supposed to be run automatically. I didn’t call it in the required slots because the arguments are different in base class and the methods can’t be overwritten if arguments don’t match. - I tried the above mentioned case without giving dispatcher and domain as arguments. And called that method in
required_slots
method. I really hoped this would work, but it didn’t. - Instead of using the
SlotSet
fromrasa_sdk.events
I usedSlotSet
fromrasa.core.events
in a seperate method where I called the api and returned this SlotSet. Then called this method in required_slots. Didn’t work either.
So here are my inferences. SlotSet is only applicable in the methods named run and having run method in FormAction prevents the form of executing properly :(
I hope there is still a way. Looking forward to your suggestions.
P.S. Please don’t suggest to have a separate action for that and write good stories to always predict that action before the form. That is what I’m doing now