How to circumvent automatic slot filling in Rasa 3

Hi community,

Within my bot I have several slots that are used to decide on which path the conversation will take. Some of the slots just capture the interest in a topic “Do you want to hear about XYZ?” and can be answered with yes or no.

Since yes or no is used frequently during a conversation those intents (affirm or deny) automatically fill my slots even though they should not so I would like to prevent this.

Further I would like to prevent slot filling when the same entity that should fill a slot is mentioned but in another context.

So here are my specific questions (related though):

  1. Is there a way to disable automatic slot filling? However, that would probably imply that I need to write a custom action for every slot right?
  2. Resetting slots is not really an option or is it? Because if a user has been interest in a topic then of course I do not want to reset this slot. So always resetting slots before the slot setting should actually take place is not a real option apart there would be a way to check whether the slot was just automatically filled or actually when it was supposed to be filled. That is not really a question but I wanted just to think out loud that resetting is something I considered but which would not really solve the issue I guess…
  3. Is there a way to specifiy when a slot should be filled and when not? I assume I could define a form for every slot and activate or deactivate it every time but this would of course increase the needed code a lot

I have the feeling that I just asked the same questions in different ways. But I really struggle to find a solution to this automatic slot filling debacle. If you have any suggestions for me, I would highly appreciate it! :slight_smile:

Many thanks!

This would typically be done with forms.

Yes, you can make a form and order the slots in the order that you want them to be filled. I’m struggling a bit with this myself. I made 2 (for me) identical chatbots. In 1 its auto - filling the slots and in the other it isn’t… Can you try making forms and let me know if this worked for you? In my chatbot showing the wanted behaviour it only fill the slot the form is asking for. Then it porceeds to the next slot.

I now decided for doing is solely in a form… I think that is the safest way of assuring that the slots get only filled in that specific context. Another option would possibly be to create a very unique intent/entity that would only make sense in that context and if there is not the “danger” that the user says something similar in another context… Hope you find a solution for your use case :slight_smile:

Hi @stephens,

actually, I put every slot in a form and condition the slot that it should only be filled in that form like:

    type: bool
    influence_conversation: true
    - type: from_intent
      auto_fill: false
      intent: affirm
      value: yes
    - type: from_intent
      auto_fill: false
      intent: deny
      value: no
      - basic_form
        requested_slot: liked_topic

Now I even added auto_fill: false. But no matter what I do, if I have an affirm intent or deny intent before that form it will auto-fill the slot “liked_topic”. (I start the form with this affirm intent, as the user does not know whether the form exists so I cannot define an intent start_basic_form). I do not know how to prevent this or can I never use common intents to fill a slot? I’m absolutely clueless and it would be awesome if you or someone else could help me with this

Can you share the repo with me? Are you following the example rules for entering and submitting the form?

Hi Greg @stephens,

so this is my story. I did not use a rule because I wanted to have an action after the form.

- story: happy story
  - checkpoint: check_intent
  - intent: affirm
  - action: basic_form
  - active_loop: basic_form
  - slot_was_set:
    - requested_slot: liked_topic
  - or:
    - slot_was_set:
        - liked_topic: yes
    - slot_was_set:
        - liked_topic: no
    - slot_was_set:
        - liked_topic: __other__
  - slot_was_set:
    - requested_slot: null
  - active_loop: null
  - action: utter_conditional_response

And this is my form for the slot above:

      - liked_topic

You should follow the examples in the docs. One rule to enter the form and a second rule to submit the form. The only slot related setting the rules should show is the requested_slot: null on the submit rule, the other slot_was_set items should be removed.

Also, don’t used featurzied slots in this case. Set influence_conversation: false on all of your slots. In general, set all slots to false.

Hi stephens,

Thanks but I have some more questions:

  1. How can I write a Form Activation Rule if I do not have an intent that specifies when the slot needs to get activated? As I explained the user does not know that there will be a question to them so I cannot create an intent like “want to do the form”… Like in the example form we have request_restaurant as a very specific intent that will trigger the form. I only have affirm what is super generic and cannot be used for a form activation. I also cannot train a specific intent because for that intent I would have the same training data in the nlu as for the affirm intent like “yes” or “sure” or “okay”… Hope that becomes clear what I mean, if not, please let me know. Maybe one would ask at this point “Why are you even using a form then?” The answer is that I wanted to make sure that the slot liked_topic gets only filled when the user is asked about it and not from other affirm and deny intents in other contexts (because that happened before). But actually as we see now the form is not even helping to prevent this. The slot gets still filled by another intent. That is extremely frustrating. Therefore, I think that I may handle literally every slot in a custom action.
- rule: Activate form
  - intent: request_restaurant
  - action: restaurant_form
  - active_loop: restaurant_form
  1. How can I train a story with the form then? Because I need to make sure that the conversation goes on
  2. I tried to not use “slot_was_set” but then the story and the conditional_reponse (which uses the slot value) did not work anymore.
  3. How can I circumvent the slot filling through the intent (affirm/deny in this case) before the actual form?

Many thanks again!

Hey Linda,

I might have an idea regarding point 2 of your initial message (resetting slots before a form). (I’m not a form expert)

If you store every form response using the template utter_ask_<form_name>_<slot_name>, you could use a custom action after the form-activation intent that:

  1. uses to look for all bot utterances that started with utter_ask_<form_name>
  2. split each utterance after utter_ask_<form_name> to get the slots that were already asked for
  3. reset all slots that are not in the extracted slot results

Looking at the example:

  • intent: request_restaurant
  • action: restaurant_form

You could get the “form_name” in your custom action via:

  • latest_intent = tracker.get_intent_of_latest_message()
  • form_topic = latest_intent.split("_")[1]
  • form = form_topic + “_form”

I only thought this through in theory and not sure if this is total overkill :slight_smile:

1 Like

Sounds like an extremely interesting hack, I will check it out and try if that works. Thank you :slight_smile:

1 Like