Optional slots


I wonder what’s the best way of creating slots, that are not obligatory.

What I mean by that? Let me define a form as presented below:

    - entity: persName
      type: from_entity
      role: client
    - entity: time
      type: from_entity
    - entity: placeName
      type: from_entity
    - entity: payment
      type: from_entity
    - entity: service
      type: from_entity
    - entity: persName
      type: from_entity
      role: doctor
    - entity: specialization
      type: from_entity

Now, in order to perform an actual search in my database I need either ‘5_service’ or ‘6_specialist_name’ or ‘7_specialization’. I don’t need all 3, although if user provides them in one sentence, then that’s not a problem. I will run a DB search with 3 parameters, not 1 or 2. So how to make form take this into account? It should accept just one response with either 1,2 or 3 parameters (slots). If just one is provided, then it shouldn’t investigate other two? And if two or three are given (in one response), then that’s okey as well.

I saw this issue add possibility to define optional slots for forms · Issue #6939 · RasaHQ/rasa · GitHub, but as I understand - it’s currently on hold, so… What’s the best alternative?

There are two solutions, that I’ve thought of:

  1. Removing this 3 slots from the form and fix stories (rules) to take into account scenarios with different set of “parameters”.
  2. Custom mappings of slots, that will remove not provided ones (so if for example I recognize ‘5_service’ and ‘6_specialist_name_and_surname’ in a response, then I remove ‘7_specialization’ from required slots (so that form wouldn’t ask for it anymore)).

What I don’t like about these solutions is neither of them seems to be an elegant one.

Any suggestions?

You could write validation methods for each of the three slots which fill the other two slots if there’s enough information already. That way it will consider them all filled; they won’t be “optional”, but the user won’t be prompted for them.

Yes. This solution works pretty well :slight_smile: Thanks!