# How to write training stories with multiple values for one entity

**URL:** <https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579>\
**Category:** Rasa Open Source\
**Created:** [February 10, 2020, 10:22am UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579 "2020-02-10T10:22:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitrovg](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@mitrovg](https://forum.rasa.com/u/mitrovg)\
**Post date:** [February 10, 2020, 10:22am UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/1 "2020-02-10T10:22:28Z")

</div>

Hello,

I am new to the Rasa platform and I have a question about how to write the stories for training where one entity can have two or more different values extracted from the NLU part. I will ask my question through example.

1. I have an intent _ask\_product\_info_ with the following training data:

```auto
## intent:ask_product_info
- Can you tell me more about rasa [core](product)?
- Please, provide me more information about rasa [nlu](product)
- information about [core](product)
- can you explain how [nlu](product) works 

```

1. I have separate utterances that explains core and nlu **utter\_provide\_core\_info**** utter\_provide\_nlu\_info**.

2. At the beginning, I have the following stories:

```auto
* greet
    - utter_greet
* ask_product_info{"product": "core"}
    - utter_provide_core_info

* greet
    - utter_greet
* ask_product_info{"product": "nlu"}
    - utter_provide_nlu_info

```

So, basically I want the bot to provide different information based on the entity that is extracted. I am somewhat familiar with slots as well, but I excluded that part for simplicity.

Question: My question is, is there a way to create story where for the _product_ entity there would be multiple values, for example something like this:

```auto
* greet
    - utter_greet
* ask_product_info{"product": ["core", "nlu"]}
    - utter_provide_core_info
    - utter_provide_nlu_info

```

I haven’t seen this kind of example yet. Also, I tried using Interactive Learning, but it didn’t solve my problem. I typed “Can you tell me more about rasa core and rasa nlu?”, and the NLU part extracted both entities correctly, but after I finished with Interactive Learning and exported the data, my story had the following format:

```auto
* greet
    - utter_greet
* ask_product_info{"product": "nlu"}

```

So, the entity value for “core” was lost.

I would appreciate if someone could help me with this or provide me an opinion how to solve this. This is just an example, I couldn’t provide the original code because it is in Cyrillic and tried to reformat my problem with the example that I used. Thanks

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [February 11, 2020, 8:07pm UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/2 "2020-02-11T20:07:22Z")

</div>

Hi Goran, there’s a good example of this in the [CarbonBot](https://github.com/RasaHQ/carbon-bot) and it’s use of the [city](https://github.com/RasaHQ/carbon-bot/blob/02920b7068adf179e8697cba12db82f93c5f200b/domain.yml#L70) slot. You would define your product entity as a list (like city) and then use a form like [airtravel\_form](https://github.com/RasaHQ/carbon-bot/blob/02920b7068adf179e8697cba12db82f93c5f200b/actions.py#L281). From the [stories.md](https://raw.githubusercontent.com/RasaHQ/carbon-bot/85dc50eeceba5ea04b63e37dd6f2dad7f8fcfd35/data/stories.md) you’ll see the example:

```auto
* inform{"city": "Berlin"}
    - slot{"city": ["Berlin", "San Francisco"]}
    - airtravel_form
    - form{"name": "airtravel_form"}
    - form{"name": null}

```

---

<div class="post-metadata">

**Author:** ![kombucha](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kombucha](https://forum.rasa.com/u/kombucha)\
**Post date:** [November 6, 2020, 12:21am UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/3 "2020-11-06T00:21:03Z")

</div>

What about the case where you just want to see if the slot has ANY value set?

Ie. check to see if the slot is not None?

This is really needed for dialogue flow, but I don’t see how to do it in the documentation.

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [November 6, 2020, 10:16pm UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/4 "2020-11-06T22:16:06Z")

</div>

You can specify it this way in either a Story or Rule. There’s a story example with a null value [here](https://rasa.com/docs/rasa/stories#slot-events).

```auto
    - slot_was_set:
      - my_slot_name: null

```

The syntax is the same for rules & stories. Rule conditions are discussed [here](https://rasa.com/docs/rasa/rules#rules-with-conditions).

---

<div class="post-metadata">

**Author:** ![kombucha](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kombucha](https://forum.rasa.com/u/kombucha)\
**Post date:** [November 6, 2020, 10:29pm UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/5 "2020-11-06T22:29:47Z")

</div>

Wonderful, thanks Greg.

I had tried ` - my_intent {"my_slot": null}` as suggested elsewhere in this forum, however contrary to what the poster said (“this works for me”) it did not actually seem to work.

However, I see this uses a Rule:

1. Does that mean I need to add RulePolicy to policies.yml ?
2. And does that mean it only works with 2.0, and not Rasa 1.x ?

---

<div class="post-metadata">

**Author:** ![kombucha](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kombucha](https://forum.rasa.com/u/kombucha)\
**Post date:** [December 9, 2020, 12:55am UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/6 "2020-12-09T00:55:49Z")

</div>

Hmm, I appreciate the reply, but that does not work at all. Using the syntax you provided:

`-slot_was_set:`

` - my_slot_name: null`

results in:

`Failed to use action 'my_slot_name: null' in history. Please make sure all actions are listed in the domains action list.`

(to be clear, `my_slot_name` is the name of the actual slot.)

Also, what about cases where you want to check that the slot IS set (to any value, ie `not null`)

Also, the example you linked to is really unclear, it seems like it is setting the slot, not seeing if it is set!

What’s going on here? This is incredibly confusing. What exactly is going on here? The syntax given in the answer does not work, is there something missing?

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [December 9, 2020, 5:31pm UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/7 "2020-12-09T17:31:18Z")

</div>

Looks like there was a known issue regarding this which is discussed in more detail [here](https://github.com/RasaHQ/rasa/issues/7253) and was fixed in version `2.1.0`.

---

<div class="post-metadata">

**Author:** ![kombucha](https://avatars.discourse-cdn.com/v4/letter/k/da6949/32.png) [@kombucha](https://forum.rasa.com/u/kombucha)\
**Post date:** [December 10, 2020, 1:56am UTC](https://forum.rasa.com/t/how-to-write-training-stories-with-multiple-values-for-one-entity/24579/8 "2020-12-10T01:56:20Z")

</div>

Glad to hear this was a known issue! It resulted in some extremely weird side effects that required significant debugging!

Does this mean that slot\_was\_set is working in 2.1.0 for stories? Or do you have to apply it using Rules?

Also, do you have anyone there who can explain the reason behind using “null” rather than “None”? Python doesn’t actually have “null” but instead uses the None singleton. Is there a CPP library being invoked here? Thanks, it’s a bit confusing.
