How to pupulate a slot of type list

Hey there,

I’m currently creating a chatbot in which users should be able to subscribe to a few topics. I want them to be able to do this in one sentence. Example given, if they type “I would like to subscribe to topic_1 and topic_2”, the NLU will mark both topics as entities. The next step will be saving these topics in a slot to be used for further processing. I’ve noticed ‘list’ slots exist, however I find it difficult to find any documentation on how to use them. A normal slot will be automatically filled upon encountering the requested entity (assuming the entity name is equal to the slot name). How does that work with list slots? If I create a list slot will both these topics be automatically added to the list, or how else should this work?

Additionally I wonder how I later on control the list. Let’s say the user want to remove one topic from the list and change it with another one (eg. because the NLU misunderstood), how does one realize that?

I’m very new to RASA so any help is certainly welcome! Thanks in advance!

1 Like

Arno, For “If I create a list slot will both these topics be automatically added to the list” - yes

For un-subscription - that depends on how you create your stories and/or user interface. few options that you can try out - as part of your story you can explicitly ask for the categories user would like to unsubscribe or through your UI you can always present list of categories (with indicator for subscribed categories) and allow users to check or uncheck to update their preference. You can read this list and update user’s preference accordingly. This is just to give you an idea - I am sure there are other solutions as well.

Thank you Apurva

@apurva Can you please give me a link as how to use it , or kindly share me a dummy code of using list this way .

@Arno - if you have already configured the slot as type: list, you should simply be able to annotate your training examples in a very straightforward way.

Let’s say the slot that you’re using is topicList. I would annotate your example as -

I would like to subscribe to [topic_1](topicList) and [topic_2](topicList)

If you do so, you’ll get a single list object called topicList that contains both ‘topic_1’ and ‘topic_2’.

topicList:['topic_1', 'topic_2']

In effect, you can use more training examples to let the entity recognition itself add the slots to a list.

To remove a list item from a list however, you would need to run a custom action after you identify the right intent. So if the user says -

Could you replace topic_2 with topic_3?

You can annotate it under a new intent as “replace_topic” as

Could you replace [topic_2](topicToBeRemoved) with [topic_3](topicList)?

You can then use a custom action after replace_topic to remove topicToBeRemoved from topicList.

Does this help?

1 Like

I understood your answer . My only worry is , there will be two intents - one for taking inputs for the different subscribers and another will be for replacement. I have done it , but i am getting Conflicts . NLU is sometimes getting confused with these two intents and slots . It picks the correct intent but entities are picked wrong.

My question is how to solve conflicts when there are similar kind of intents taking similar Number and type of entities. I have trained the model with good variations Thanks

I have a similar kind of problem described here - Partial and conflicting list item utterances. There’s a potential solution that should theoretically avoid giving you errors, but I’ve not had the chance to try it yet.