Reset Slot (FormAction)

Hey there!

I’m using FormAction to fill a bunch of slots. For all my 12 slots I’m using 3 FormActions. I’m asking myself if it’s possible to “reask” some slots which were already set by a FormAction when an user want so?

For example: during the conversation the Slot userName got filled and the user sees a typo in it. He wants to correct it by stating “Wait a second, I want to correct my username!” It would be perfect if the bot now resets the appropiate slot(s) and reasks them via the FormAction.

1 Like

my first intuition would be to create an extra intent let’s say change_slot and two additional slots, which contain the name of the slot you want to change changing_slot_name and the value changing_slot_value. Then you add a custom actions which is triggered when your intent is recognized and tries to set the slot with changing_slot_name to changing_slot_value.
Your stories would then look something like this (taken from the example stories in the docs):

* request_restaurant
     - action_restaurant_form
     - slot{"requested_slot": "people"}
* inform{"number": 3}
     - action_restaurant_form
     - slot{"people": 3}
     - slot{"requested_slot": "cuisine"}
* change_slot{"changing_slot_name": "people", "chaning_slot_value": 5}
    - action_change_slot
   - slot{"people": 5}

I’m by no means an expert, so this might not be helpful at all.
Also I don’t think there is a build-in function for “re-asking” for FormActions, the only thing you could do is use the validate() function of FormFields to atleast catch “false” entries.


@momo Can you help me to this. Is it possible to set slot values for utter_actions?

@raghavendrav1210 I’m not sure if I completly understand what you want to achieve. Do you want to set a slot when an utter_action is called?
If that in fact is what you want to do, I don’t think it’s possible, but it is also pretty simple to achieve that with a custom action, which would look something like thiat:

import ...

class ActionUtterAndSetSlot(Action:
    def name(self):
        return "action_utter_and_set_slot"

    def run(self, dispatcher, tracker, domain):
        your_slot_value = some_kind_of_request()
        dispatcher.utter_message("Your example Utterance")
        return [SlotSet("your_slot_name", your_slot_value)]

Hope this helps, feel free to ask again, if that’s not what you meant. :slight_smile:

thanks for the idea @momo! Yes, I also thinked about this in a pretty similiar way. The only thing I’m struggenling with is the fact that I’m having ~20 Slots and I need a good way to distinguish between them when the Intent change_slot is recognized.

Maybe any idea from your side?

Thanks @momo it solves part of my problem. I have another question not related to this but can you help me to understand this. I’m always getting next_action as action_listen. Do you have any idea why?

Maybe I can help as well: it seems that this is a known problem as you can see on the GitHub isse I link below.

I also had this behaviour and was able to solve this with (a lot) more training stories. But there are still cases where I get this false behaviour

Thanks @mjoellnier

@mjoellnier Yeah I was actually thinking about that when writing up my answer and don’t really have a solution.

But do you really have the need to distinguish them? Wouldn’t it be enough for the action to check if the the slot_name is in tracker.slots and if it is just set the slot to the aquired slot_value?