kunci115
(Rinoalfian)
September 30, 2019, 11:12am
1
Hi i want to activate form through custom action, anyone knows how to do that?
for example:
req_details = FeedbackForm()
req_details.run(dispatcher, tracker, domain)
FeedbackForm is inheritance from FormAction, its work but the form is not opening and closing,
i want to set activate before the feedbackform run
The reason i want to use this because i’m using mapping policy default fallback for this actions
Thankyou,
Rino Alfian
Ghostvv
(Vladimir Vlasov)
September 30, 2019, 12:11pm
2
In order for the form to open and close, you need to return the events returned by the run method of the form
kunci115
(Rinoalfian)
September 30, 2019, 1:25pm
3
any docs or example code to return the events by the run method of the form? i still didn’t get it
Ghostvv
(Vladimir Vlasov)
September 30, 2019, 1:39pm
4
each run method returns the list of events (Actions ) that are passed to rasa core, that’s how rasa core knows that a form was activated. Therefore your custom action should return these list of events
kunci115
(Rinoalfian)
October 1, 2019, 1:39pm
5
class ActionDefaultFallback(Action):
def name(self):
return "action_default_fallback"
def run(self, dispatcher, tracker, domain):
# print(tracker.current_state())
print("******************default************************")
wrong_counter = tracker.get_slot('fallback_counter')
if wrong_counter == None:
wrong_counter = 0
wrong_counter += 1
req_details = FeedbackForm()
form_name = req_details.name()
dispatcher.utter_template('utter_default_fallback',tracker)
req_details.deactivate()
dispatcher.utter_template("utter_i've_sent_details", tracker)
dispatcher.utter_template("utter_thankyou_for_feedback", tracker)
return [Form(form_name)]
thats the sample code, now the condition is the bot reply only the default fallback utterances, it won’t return the form, if i want the form to showup there, i have to type something first, its like form stucking if i didnt type something after utter_Default_fallback comes up
Ghostvv
(Vladimir Vlasov)
October 1, 2019, 2:46pm
6
I don’t understand what do you mean, why do you need a form inside fallback action? fallback action is not designed for that
I think this is what you’re looking for: https://innovationyourself.com/form-action-with-your-rasa-chat-bot/
Instead of creating
class ActionFormInfo(FormAction)
You would create:
class ActionDefaultFallback(FormAction)
And in that action you can define the details of your FeedbackForm