# Appending data to slots of list type

**URL:** <https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552>\
**Category:** Rasa Open Source\
**Created:** [January 13, 2022, 7:50am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552 "2022-01-13T07:50:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 13, 2022, 7:50am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/1 "2022-01-13T07:50:42Z")

</div>

I wish to have a form, where I collect the personal details of the user and the last slot of the form is a boolean value which asks the user if he/she wants to add another user. If the answer is yes, then I have to run the form again so that the slots get filled again. The slots are list type so that I can add multiple entry to a slot. How can I achieve this?

---

<div class="post-metadata">

**Author:** ![Belen](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Belen](https://forum.rasa.com/u/Belen)\
**Post date:** [January 15, 2022, 8:40am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/2 "2022-01-15T08:40:32Z")

</div>

Do you want to set the slots to `None` so they can be filled again or add the new values to the existing lists in the slots?

When a form is active it asks for slots that haven’t been filled yet, I don’t think you can ask for a slot that already contains a list.

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 4:46am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/3 "2022-01-17T04:46:05Z")

</div>

Ok…so how can I enter multiple values to a list during a single entry. When I tried to enter using commas it takes commas as part of the string

---

<div class="post-metadata">

**Author:** ![Belen](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Belen](https://forum.rasa.com/u/Belen)\
**Post date:** [January 17, 2022, 8:16am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/4 "2022-01-17T08:16:18Z")

</div>

You have to define your slot as a list in you domain, note that you will also have to define an entity that represents the elements of the list

```auto
  shopping_list:
    type: list
    mappings:
    - type: from_entity
      entity: groceries

```

And then add examples in the nlu file like this:

```auto
- I have to buy [eggs](groceries), [milk](groceries) and [cookies](groceries)

```

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 8:17am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/5 "2022-01-17T08:17:01Z")

</div>

I wish to take data from text not from entity

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 8:28am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/6 "2022-01-17T08:28:45Z")

</div>

so you mean a list slot can contain multiple entitites as list and not a single slot which can hold multiple values?

---

<div class="post-metadata">

**Author:** ![Belen](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Belen](https://forum.rasa.com/u/Belen)\
**Post date:** [January 17, 2022, 8:59am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/7 "2022-01-17T08:59:34Z")

</div>

> [@Suganth](#):
>
> I wish to take data from text not from entity

If you want to extract data from the text without an entity you should define a [extraction function](https://rasa.com/docs/rasa/forms#custom-slot-mappings).

In the actions file, within the validation class of the form you must define the function extract\_slot, and define how the values of the user’s text are extracted.

For example if they are fixed values you can search for those values and store them in a list.

> [@Suganth](#):
>
> so you mean a list slot can contain multiple entitites as list and not a single slot which can hold multiple values?

Yes, a text type slot can contain a list, but in string format.

For example, with the shopping list that I told you about before.

If you defined the list type slot it would be `['eggs', 'milk', 'cookies']`

If you defined it as text type it would be: `'eggs, milk and cookies'`

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 9:09am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/8 "2022-01-17T09:09:10Z")

</div>

```auto
  names:
    type: list
    influence_conversation: True
    mappings:
    - type: from_text
      conditions:
      - active_loop: booking_details_form
        requested_slot: names

```

this is what I have been using and it returns a string. so the only way possible is to use from\_entity right?

---

<div class="post-metadata">

**Author:** ![Belen](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Belen](https://forum.rasa.com/u/Belen)\
**Post date:** [January 17, 2022, 9:15am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/9 "2022-01-17T09:15:02Z")

</div>

No, you could define the function to extract the slot in your actions file or you could use the entity, for this case I think the entity would be the most useful.

If you use the entity you should define the entity `name` to extract names from the text and be able to store them in the slot `names`

```auto
  names:
    type: list
    influence_conversation: true
    mappings:
    - type: from_entity
      entity: name

```

Also, you will need to add some instances of the entity `name` in the nlu file

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 9:29am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/10 "2022-01-17T09:29:10Z")

</div>

But while defining an entity…the model only validates those examples which we gave…but in my case the names should be anything that the user gives…because names can be anything right…that’s why I used text. Is there a way to define an entity which takes any given name?

---

<div class="post-metadata">

**Author:** ![Belen](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Belen](https://forum.rasa.com/u/Belen)\
**Post date:** [January 17, 2022, 9:43am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/11 "2022-01-17T09:43:29Z")

</div>

No, by defining examples it then extracts similar things from the text using machine learning.

Here it defines a bit how DIET works [Components](https://rasa.com/docs/rasa/components#dietclassifier)

but I recommend you watch the video in which they explain it to fully understand how it works [https://www.youtube.com/playlist?list=PL75e0qA87dlG-za8eLI6t0\_Pbxafk-cxb](https://www.youtube.com/playlist?list=PL75e0qA87dlG-za8eLI6t0_Pbxafk-cxb)

It is true that it does not always identify them correctly, but the more and varied examples they are, the better it will work.

---

<div class="post-metadata">

**Author:** ![Suganth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/suganth/32/18670_2.png) [@Suganth](https://forum.rasa.com/u/Suganth)\
**Post date:** [January 17, 2022, 10:17am UTC](https://forum.rasa.com/t/appending-data-to-slots-of-list-type/50552/12 "2022-01-17T10:17:28Z")

</div>

will check out…thanks for taking time to explain😀
