Categorical Slot Issues

(Rasa v2.6) I am trying to build a hotel reservation bot. The bot will check the arrival and departure date, as well as the type of bed requested for the hotel room (ie. single or double). I want to find a way to fill the room_type slot with either single or double, but no other value should be allowed. I tried to define categorical slots in the domain, but that wasn’t enough to get the job done.

slots:
  arrival_date:
    type: text
    influence_conversation: false
  departure_date:
    type: text
    influence_conversation: false
  room_type:
    type: categorical
    values:
      - single
      - double
forms:
  hotel_reservation_from:
    arrival_date:
    - type: from_entity
      entity: "time"
    departure_date:
    - type: from_entity
      entity: "time"
    room_type:
    - type: from_entity
      entity: room_type

And I had a form to fill in the slots:

- rule: activate hotel reservation form
  steps:
  - intent: hotel_reservation
  - action: hotel_reservation_from
  - active_loop: hotel_reservation_from

- rule: submit form for making a hotel reservation
  condition:
  - active_loop: hotel_reservation_from
  steps:
  - action: hotel_reservation_from
  - active_loop: null
  - action: utter_completed_hotel_reservation
  - action: utter_goodbye

When I type in, “I would like a king size bed”, the bot recognises this entity and fills the room_type slot to “king size bed”. Without writing any custom actions, can I make the slots stick to single/ double only?

I agree that this behavior of categorical slots is a bit annoying at times. We usually want only one of the defined values or nothing.

  1. Can you share the NLU examples? The bot shouldn’t recognize “king size” as an entity if it is not tagged as the room_type entity in the intent examples.

  2. You can still tag, for example, “king size” as an entity example in your NLU but mention it as a synonym for “double”: I would like a [king size]{"entity": "room_type", "value": "double"} bed.

  3. Another thing you can do is control the users’ choice by using two buttons (Single, Double) that will force the user to choose one of these two only.

  4. You said you don’t want that, but I’m gonna write it anyway in case a future reader comes across this. You can use Custom Actions and Form Validation Actions to set the slot if its value is only either single or double.

1 Like

For your first point - I originally did not have “king size” as an entity in he NLU data, just single or double. And that indeed made to bot work, by recognising the single or double only. But I wanted to test and see whether the categorical slots do actually limit the inputs themselves, and I guess I found out it doesn’t quite do that.

Thank you for your different suggestions. I will have a look into some as well, and see what will work best. Cheers.

1 Like

Happy to help :slight_smile: I just want to clarify your below question.

From the docs:

A default value __other__ is automatically added to the user-defined values. All values encountered which are not explicitly defined in the slot’s values are mapped to __other__ .

Usually, the slot won’t be filled with __other__ unless either:

  1. the entity values for the slot have different values that those mentioned for the slot
  2. or the slot was forcefully set from a custom action

I don’t know if there are other ways for the slot to be filled with __other__.

1 Like