Categorical slots and stories

Hi,

Kindly advise on below. For eg, If I’ve a categorical slot like below

slots:
  car_name:
    type: categorical
    values:
      - audi
      - bmw
      - renault

I want to perform same action if car value is any of the above and different action if other. So I hope I need to set “influence_conversation” to True in Slot definition.

Then should I repeat the same set of stories 3 times…one for each valid value “audi”, “bmw” and “renault” and separate story for option “other”? Or is it sufficient if I give only one story path for all 3 valid slot values? Please help.

Categorical slots will only take one of its values. Thus, it can never be “other” in your example.

You can convert it into a regular text slot, then in acustom action or slot validation, you can check if slot in ['audi', 'bmw', 'renault'] with Python and respond differently if True or False.

1 Like

@ChrisRahme Thank you! I got your 2nd point where you emphasize about custom validation. But could you please explain a little on how that slot can never be “other” in above example?

I read about Slot Type in Domain and it says

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__ . __other__ should not be used as a user-defined value; if it is, it will still behave as the default to which all unseen values are mapped.

So I thought if user input has any value which is other than [‘audi’, ‘bmw’, ‘renault’], then the Slot will be filled with Other.

Please clarify.

1 Like

Raj,

Yes, a categorical slot will be set to __other__ if you set it to a value that is not listed. You would typically want do validate the slot on entry to make sure it is valid.

I assume you want to use categorical because there are some stories that vary based upon the value provide? And, other stories that only care if it is set or not?

To test for slot was set to anything (assuming you’ve validated to make sure you don’t have __other__):

stories:
- story: car name is set
  steps:
    # ... other story steps
    - action: action_that_sets_slot
    - slot_was_set:
      - car_name
    # ... more story steps

Greg

2 Likes

@stephens Thank you for the explanation!!