I was wondering if it’s possible to fill a form slot with the intent of the initial message that triggers the FormAction.
E.g. if I had something like this:
* order_drinks
- form_order
- form{"name": "form_order"}
- form{"name": null}
And I have a slot called subject
that can be ['drinks', 'food', ...]
that I want to be filled in order for the submit
method to act on it. E.g. my form has these methods:
def slot_mappings(self):
return {
"subject": [
self.from_intent(
intent='order_drinks',
value='drinks'
),
self.from_intent(
intent='order_food',
value='food'
),
]
}
def submit(self, dispatcher, tracker, domain):
subject = tracker.get_slot('subject')
if subject == 'drinks':
order_drinks()
elif ...:
order_something_else()
else:
dispatcher.utter_message("Unkown subject")
return []
Which works for a story like this:
* order
- form_order
- form{"name": "form_order"}
- form{"name": null}
Because then the bot would ask the user “What would you like to order?”, then the user could say “I want to drinks” or whatever, and then the submit action would work.
However, for the initial story from above, the user already says “I want to order drinks”, but the bot then asks “What would you like to order?” and the user has to say “Drinks” again.
So overall, the question could be summarized to "can I fill a form slot using the intent that triggered the form so that forms can be shared across different intents?"
I know I could do it like that:
* order_drinks
- form_order
- form{"name": "form_order"}
- form{"name": null}
- action_order_drinks
However, even though this probably would never be an issue, using e.g. the KerasPolicy it doesn’t guarantee that action_order_drinks
will be executed. It’s left up to the core’s policies to make that call. However, I need to guarantee execution of action_order_drinks
after form_order
has requested all other necessary slots.
The only other way I can imagine as of now is to have a separate FormAction for every initial intent.
Any solutions for this?