Categorical Slots with slot_was_set stories

I have an action which sets a categorical slot which can take up to 5 possible values, and these values will influence the story later on which is why the slot has to be of type categorical. The current set up for the stories is:

- intent: inform
- action: action_update_slot_value
- slot_was_set:
  - slot_name: slot value
- action: utter_continue

As some of the slot values will result in the same questions being asked later on, does RASA allow for multiple values to be put in the slot_was_set event, and if the action updates the slot value with just one of the options, it will continue on with the story? I currently plan to have another similar situation later into the stories so I was facing potentially having to write 100+ stories to account for every possible combination of slot values. Is something like this possible:

- story: 1
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value1, value2
 - action: utter_continue

- story: 2
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value3, value4, value5
 - action: utter_continue

Currently I have tried with and without values enclosed in [ ], using yaml list format, and trying with an ā€˜ORā€™ statement with no success. Is this even possible with RASA, or would it require going into the source code for slot_was_set to achieve this?

RASA version: 2.1.0

rasa_sdk: 2.1.2

Hello @FGA-Traverse, welcome to the forum!

I am not entirely sure I understand you correctly. Do you want to store some list of items at the beginning of the dialogue, and then later ask the user about each item separately later in the dialogue? Depending on the specifics, this might be done with a list type slot, but then your conversation would only depend on whether the list has items or not.

A custom action can set as many slots as you like at once. You can also put any kind of information into a slot (given it has the right type). I assume you are struggling because the categorical type featurizes as ā€œeither A or B or C orā€¦ā€, but you are looking for something like ā€œA and C, but not Bā€? In this case you have to implement your own custom slot type. To do this, add a file addons.py to your project (same directory as the domain, config, etc.), and implement a new class BooleanVectorSlot, say, derived from Slot, as shown in the documentation Iā€™ve linked to. Then youā€™d use the slot type addons.BooleanVectorSlot instead of categorical.

1 Like

Hey @j.mosig!

Essentially I have a list of 5 possible values which ā€˜categoriseā€™ the conversation. In the actual bot they are types of disputes the user wants to submit a claim about. These values will result in individual stories, but some values will need similar questions to be asked such as asking about things like details of the claim.

I currently have a custom action which sets the value of the slot, which basically just checks if the user response matches with a list of the 5 possible values, and if it is then the slot is filled. This works totally fine but it means that I have to have an individual story for each value like this:

- story: 1
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value1
 - action: utter_continue

- story: 2
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value2
 - action: utter_continue

- story: 3
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value3
 - action: utter_continue

- story: 4
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value4
 - action: utter_continue

- story: 5
  steps:
 - intent: inform
 - action: action_update_slot_value
 - slot_was_set:
   - slot_name: value5
 - action: utter_continue

Is there a way of reducing the number of stories by having something like:

- slot_was_set:
  - slot_name: value1, value2, value3

Where if the action before sets the slot to either value1, value2, or value3, this one story can continue?

Hopefully this makes a bit more sense but let me know if it doesnā€™t.

@FGA-Traverse Thank you for your explanation! The or-connection of slots is not yet possible, but weā€™re working on something that should help here. In the meantime you can proceed as follows.

If the entire conversation will only depend on whether or not your categorical slot was filled, then just use a text slot instead. Rasa will only notice whether the text has been set or not.

If only the later part of the conversation will depend on the particular setting, but the earlier part does not (this is what I think you have in mind), then you can first store the information in a text slot, and later, when the details become relevant, run a custom action that fills a categorical slot from the text slot. I know that this is not very elegant, but it should work for now and it saves you from writing all those stories.

If only the later part of the conversation will depend on the particular setting, but the earlier part does not (this is what I think you have in mind), then you can first store the information in a text slot, and later, when the details become relevant, run a custom action that fills a categorical slot from the text slot. I know that this is not very elegant, but it should work for now and it saves you from writing all those stories.

Iā€™ve just managed to implement this and it works perfectly! Thank you so much for the suggestion!

1 Like

Now, can we slove this problem more elegant with rasa2.7?

Sorry, @lullaby-afa , it looks like this will only come with Rasa 3.0 later this year. You can follow the GitHub issue here: Make it possible to OR slot values - Implementation Ā· Issue #8933 Ā· RasaHQ/rasa Ā· GitHub

Thanksļ¼