# Categorical Slots with slot\_was\_set stories

**URL:** <https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116>\
**Category:** Rasa Open Source\
**Created:** [December 16, 2020, 2:03pm UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116 "2020-12-16T14:03:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FGA-Traverse](https://avatars.discourse-cdn.com/v4/letter/f/bc79bd/32.png) [@FGA-Traverse](https://forum.rasa.com/u/FGA-Traverse)\
**Post date:** [December 16, 2020, 2:03pm UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/1 "2020-12-16T14:03:16Z")

</div>

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:

```auto
- 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:

```auto
- 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

---

<div class="post-metadata">

**Author:** ![j.mosig](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/j.mosig/32/3588_2.png) [@j.mosig](https://forum.rasa.com/u/j.mosig)\
**Post date:** [December 16, 2020, 3:03pm UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/2 "2020-12-16T15:03:24Z")

</div>

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.

> [@FGA-Traverse](#):
>
> does RASA allow for multiple values to be put in the slot\_was\_set event,

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](https://rasa.com/docs/rasa/2.0.x/domain#custom-slot-types). 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`.

---

<div class="post-metadata">

**Author:** ![FGA-Traverse](https://avatars.discourse-cdn.com/v4/letter/f/bc79bd/32.png) [@FGA-Traverse](https://forum.rasa.com/u/FGA-Traverse)\
**Post date:** [December 16, 2020, 3:54pm UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/3 "2020-12-16T15:54:26Z")

</div>

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:

```auto
- 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:

```auto
- 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.

---

<div class="post-metadata">

**Author:** ![j.mosig](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/j.mosig/32/3588_2.png) [@j.mosig](https://forum.rasa.com/u/j.mosig)\
**Post date:** [December 16, 2020, 4:34pm UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/4 "2020-12-16T16:34:14Z")

</div>

@FGA-TraverseThank 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.

---

<div class="post-metadata">

**Author:** ![FGA-Traverse](https://avatars.discourse-cdn.com/v4/letter/f/bc79bd/32.png) [@FGA-Traverse](https://forum.rasa.com/u/FGA-Traverse)\
**Post date:** [December 17, 2020, 11:51am UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/5 "2020-12-17T11:51:45Z")

</div>

> 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!

---

<div class="post-metadata">

**Author:** ![lullaby-afa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lullaby-afa/32/20035_2.png) [@lullaby-afa](https://forum.rasa.com/u/lullaby-afa)\
**Post date:** [July 5, 2021, 2:55am UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/6 "2021-07-05T02:55:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![j.mosig](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/j.mosig/32/3588_2.png) [@j.mosig](https://forum.rasa.com/u/j.mosig)\
**Post date:** [July 7, 2021, 11:18am UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/7 "2021-07-07T11:18:30Z")

</div>

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](https://github.com/RasaHQ/rasa/issues/8933)

---

<div class="post-metadata">

**Author:** ![lullaby-afa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lullaby-afa/32/20035_2.png) [@lullaby-afa](https://forum.rasa.com/u/lullaby-afa)\
**Post date:** [July 7, 2021, 11:19am UTC](https://forum.rasa.com/t/categorical-slots-with-slot-was-set-stories/38116/8 "2021-07-07T11:19:48Z")

</div>

Thanks！
