Appending data to slots of list type

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?

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.

1 Like

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

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

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

And then add examples in the nlu file like this:

- I have to buy [eggs](groceries), [milk](groceries) and [cookies](groceries)
1 Like

I wish to take data from text not from entity

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

If you want to extract data from the text without an entity you should define a extraction function.

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.

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'

1 Like
  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?

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

  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

1 Like

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?

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

Here it defines a bit how DIET works Components

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

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

1 Like

will check out‚Ķthanks for taking time to explainūüėÄ