My categorical slots are not working - Rasa 3.0

I tried to “translate” a hotel reservation bot I created in Rasa 2.6 to Rasa 3.0, and my categorical slots aren’t working. I cannot quite figure out why.

Here is most of my nlu.yml:

version: "3.0"

nlu:
- intent: hotel_reservation
  examples: |
    - [single](room_type) room
    - [single](room_type) room please
    - [single](room_type) bed
    - [single](room_type) bedroom please
    - do you have a [single](room_type) room?
    - i want a [single](room_type) room
    - [double](room_type) room
    - [double](room_type) room please
    - [double](room_type) bed
    - [double](room_type) bedroom please
    - do you have a [double](room_type) room?
    - i want a [double](room_type) room
    - [king sized]{"entity": "room_type", "value": "double"}
    - [king sized]{"entity": "room_type", "value": "double"} please
    - [king size]{"entity": "room_type", "value": "double"} bed
    - [king sized]{"entity": "room_type", "value": "double"} room
    - [king size]{"entity": "room_type", "value": "double"} bed in my room please 
    - do you have a [king size]{"entity": "room_type", "value": "double"} room?
    - i want a [king size]{"entity": "room_type", "value": "double"} room

    - [1]{"entity": "no_of_guests", "value": "1"}
    - [2]{"entity": "no_of_guests", "value": "2"}
    - [3]{"entity": "no_of_guests", "value": "3"}
    - [one]{"entity": "no_of_guests", "value": "1"}
    - [two]{"entity": "no_of_guests", "value": "2"}
    - [three]{"entity": "no_of_guests", "value": "3"}
    - only [one person]{"entity": "no_of_guests", "value": "1"} will attend
    - [one person]{"entity": "no_of_guests", "value": "1"} only
    - [just me]{"entity": "no_of_guests", "value": "1"}
    - all [three]{"entity": "no_of_guests", "value": "3"}
    - [three]{"entity": "no_of_guests", "value": "3"} people
    - [2 people]{"entity": "no_of_guests", "value": "2"}
    - [two people]{"entity": "no_of_guests", "value": "2"}

The rules.yml:

version: "3.0"

rules:
- rule: Say goodbye anytime the user says goodbye
  steps:
  - intent: goodbye
  - action: utter_goodbye

- rule: Say 'I am a bot' anytime the user challenges
  steps:
  - intent: bot_challenge
  - action: utter_iamabot

- 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

The pipeline config.yml

# The config recipe.
# https://rasa.com/docs/rasa/model-configuration/
recipe: default.v1

# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en

pipeline:
# No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
# If you'd like to customize it, uncomment and adjust the pipeline.
# See https://rasa.com/docs/rasa/tuning-your-model for more information.
  - name: WhitespaceTokenizer
  - name: RegexFeaturizer
  - name: LexicalSyntacticFeaturizer
  - name: CountVectorsFeaturizer
  - name: CountVectorsFeaturizer
    analyzer: char_wb
    min_ngram: 1
    max_ngram: 4
  - name: DIETClassifier
    epochs: 100
    constrain_similarities: true
  - name: EntitySynonymMapper
  - name: ResponseSelector
    epochs: 100
    constrain_similarities: true
  - name: FallbackClassifier
    threshold: 0.3
    ambiguity_threshold: 0.1
  - name: "SpacyNLP"
    # language model to load
    model: "en_core_web_md"
    case_sensitive: False
    # language model to load
  - name: "SpacyEntityExtractor"
    dimensions: ["DATE"]
    ambiguity_threshold: 0.1

and the rules.yml:

version: "3.0"

intents:
  - greet
  - goodbye
  - affirm
  - deny
  - bot_challenge
  - hotel_reservation

entities: 
- DATE
- room_type
- no_of_guests

responses:
  utter_greet:
  - text: "Hey! How are you?"
  utter_did_that_help:
  - text: "Did that help you?"
  utter_ask_arrival_date:
  - text: "On what date will you arrive?"
  utter_ask_departure_date:
  - text: "What date would you like to depart?"
  utter_ask_room_type:
  - text: "What room type would you like to book? (single or double)"
  utter_ask_no_of_guests:
  - text: "How many guests would you like to book for the room?"
  utter_completed_hotel_reservation:
  - text: "Thank you for making the reservation! The room booked is a {room_type}"
  utter_ask_room_type_not_recognized:
  - text: "The room type has not been recognised. Please try again with either single or double"
  utter_goodbye:
  - text: "Bye"
  utter_iamabot:
  - text: "I am a bot, powered by Rasa."

slots:
  arrival_date:
    type: text
    mappings:
    - type: from_entity
      entity: DATE
    influence_conversation: false

  departure_date:
    type: text
    mappings:
    - type: from_entity
      entity: DATE
    influence_conversation: false

  no_of_guests:
    type: categorical
    values:
      - 1
      - 2
      - 3
    mappings:
    - type: custom
    
  room_type:
    type: categorical
    values:
      - single
      - double
    mappings:
    - type: custom


forms:
  hotel_reservation_from:
    required_slots:
      - no_of_guests
      - room_type
      - arrival_date
      - departure_date

session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true

Hope someone can let me know what I have done wrong. Only the categorical slots are not working. The arrival_date and departure_date are working just fine. I have been stuck on this for a while now. Thank you (:

1 Like

Hi @anne576,

My first guess for the issue would be the discrepancy between the NLU data entity annotations and the values in the domain:

# NLU
# "2" is a string
    - [2]{"entity": "no_of_guests", "value": "2"}
# Domain
# 1, 2, and 3 are integers
  no_of_guests:
    type: categorical
    values:
      - 1
      - 2
      - 3

Perhaps changing your domain in order to match your NLU data would work.

Alternatively, you could use a float slot, which is specifically intended for numbers:

Your domain could be something like:

  no_of_guests:
    type: float
    values:
    min_value: 1
    max_value:  3

For the mappings itself, I’m unsure. A few ideas:

  • You could just change your NLU data entity annotations to use integers and not strings, then use from_entity
  • You could use Duckling to extract numbers (I’ve never tried this though): (Components)
  • You could write a form validation action which figures out the no_of_guests slot

Hope that helps!

1 Like

I stumbled upon the answer to my own question. I used this from the docs: Version Migration Guide which transcribed my working 2.6 domain file to a working 3.0 version. Command used:

rasa data migrate -d domain.yml --out original_domain.yml

if anyone is interested how the domain.yml looks like atm:

version: '"3.0"'
session_config:
  session_expiration_time: 60
  carry_over_slots_to_new_session: true
intents:
- greet
- goodbye
- affirm
- deny
- bot_challenge
- hotel_reservation
entities:
- DATE
- room_type
- no_of_guests
slots:
  arrival_date:
    type: text
    influence_conversation: false
    mappings:
    - type: from_entity
      entity: DATE
      conditions:
      - active_loop: hotel_reservation_from
  departure_date:
    type: text
    influence_conversation: false
    mappings:
    - type: from_entity
      entity: DATE
      conditions:
      - active_loop: hotel_reservation_from
  no_of_guests:
    type: categorical
    values:
    - 1
    - 2
    - 3
    mappings:
    - type: from_entity
      entity: no_of_guests
      conditions:
      - active_loop: hotel_reservation_from
    - type: from_entity
      entity: no_of_guests
  room_type:
    type: categorical
    values:
    - single
    - double
    mappings:
    - type: from_entity
      entity: room_type
      conditions:
      - active_loop: hotel_reservation_from
    - type: from_entity
      entity: room_type
responses:
  utter_greet:
  - text: Hey! How are you?
  utter_did_that_help:
  - text: Did that help you?
  utter_ask_arrival_date:
  - text: On what date will you arrive?
  utter_ask_departure_date:
  - text: What date would you like to depart?
  utter_ask_room_type:
  - text: What room type would you like to book? (single or double)
  utter_ask_no_of_guests:
  - text: How many guests would you like to book for the room?
  utter_completed_hotel_reservation:
  - text: Thank you for making the reservation! The room booked is a {room_type}
  utter_ask_room_type_not_recognized:
  - text: The room type has not been recognised. Please try again with either single or double
  utter_goodbye:
  - text: Bye
  utter_iamabot:
  - text: I am a bot, powered by Rasa.
forms:
  hotel_reservation_from:
    ignored_intents: []
    required_slots:
    - arrival_date
    - departure_date
    - room_type
    - no_of_guests

1 Like

Thank you for your answer. I will also make the changes to the discrepancy! :slight_smile: