# How to set list slot in custom action

**URL:** <https://forum.rasa.com/t/how-to-set-list-slot-in-custom-action/5668>\
**Category:** Rasa Open Source\
**Created:** [March 3, 2019, 10:07am UTC](https://forum.rasa.com/t/how-to-set-list-slot-in-custom-action/5668 "2019-03-03T10:07:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirfan899](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mirfan899/32/173_2.png) [@mirfan899](https://forum.rasa.com/u/mirfan899)\
**Post date:** [March 3, 2019, 10:07am UTC](https://forum.rasa.com/t/how-to-set-list-slot-in-custom-action/5668/1 "2019-03-03T10:07:12Z")

</div>

I’m trying to append values to list slot but failed. It seems no documentation is available for such behavior.

stories:

## Rearrange words question with no option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“N”: “no”}
  - slot{“N”: “no”}
  - utter\_rearrange\_structure
  - action\_slot\_reset
  - action\_restart

## Rearrange words question with no option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“N”: “no”}
  - slot{“N”: “no”}
  - utter\_rearrange\_structure
  - action\_slot\_reset
  - action\_restart

## Rearrange words question with no option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“N”: “no”}
  - slot{“N”: “no”}
  - utter\_rearrange\_structure
  - action\_slot\_reset
  - action\_restart

## Rearrange words question with no option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“N”: “no”}
  - slot{“N”: “no”}
  - utter\_rearrange\_structure
  - action\_slot\_reset
  - action\_restart

## Rearrange words question with no option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“N”: “no”}
  - slot{“N”: “no”}
  - utter\_rearrange\_structure
  - action\_slot\_reset
  - action\_restart

## Rearrange words question with yes option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“Y”: “yes”}
  - slot{“Y”: “yes”}
  - utter\_ask\_rearrange\_question\_1

- rearrange.answer{“S”: “we”, “V”: “should eat”, “P”: “enough vegetables and cereals”}
  - slot{“P”: [“enough vegetables and cereals”]}
  - slot{“S”: [“we”]}
  - slot{“V”: [“should eat”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_2

- rearrange.answer{“S”: “he”, “V”: “has”, “P”: “plenty of time to sleep”, “C”: “because”, “S”:“he”, “V”:“likes”, “P”:“his job”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“his job”, “plenty of time to sleep”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“likes”, “has”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_3

- rearrange.answer{“S”: “he”, “V”: “works”, “P”: “on a plane”, “C”: “because”, “S”: “he”, “V”: “needs”, “P”: “to be very careful”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“to be very careful”, “on a plane”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“needs”, “works”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_4

- rearrange.answer{“S”: “it”, “V”: “give”, “C”: “and”, “P”: “you vitamins”, “V”: “is”, “S”:“vegetables and fruits”, “C”:“because”}
  - slot{“C”: [“because”, “and”]}
  - slot{“P”: [“you vitamins”]}
  - slot{“S”: [“it”, “vegetables and fruits”]}
  - slot{“V”: [“is”, “give”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_5

- rearrange.answer{“S”: “she”, “V”: “take”, “P”: “photos of famous people”}
  - slot{“P”: [“photos of famous people”]}
  - slot{“S”: [“she”]}
  - slot{“V”: [“takes”]}
  - action\_slot\_set
  - action\_check\_answer
  - action\_slot\_reset

## Rearrange words question with yes option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“Y”: “yes”}
  - slot{“Y”: “yes”}
  - utter\_ask\_rearrange\_question\_1

- rearrange.answer{“S”: “we”, “V”: “should eat”, “P”: “enough vegetables and cereals”}
  - slot{“P”: [“enough vegetables and cereals”]}
  - slot{“S”: [“we”]}
  - slot{“V”: [“should eat”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_2

- rearrange.answer{“S”: “he”, “V”: “has”, “P”: “plenty of time to sleep”, “C”: “because”, “S”:“he”, “V”:“likes”, “P”:“his job”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“his job”, “plenty of time to sleep”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“likes”, “has”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_3

- rearrange.answer{“S”: “he”, “V”: “works”, “P”: “on a plane”, “C”: “because”, “S”: “he”, “V”: “needs”, “P”: “to be very careful”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“to be very careful”, “on a plane”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“needs”, “works”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_4

- rearrange.answer{“S”: “it”, “V”: “give”, “C”: “and”, “P”: “you vitamins”, “V”: “is”, “S”:“vegetables and fruits”, “C”:“because”}
  - slot{“C”: [“because”, “and”]}
  - slot{“P”: [“you vitamins”]}
  - slot{“S”: [“it”, “vegetables and fruits”]}
  - slot{“V”: [“is”, “give”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_5

- rearrange.answer{“S”: “she”, “V”: “take”, “P”: “photos of famous people”}
  - slot{“P”: [“photos of famous people”]}
  - slot{“S”: [“she”]}
  - slot{“V”: [“takes”]}
  - action\_slot\_set
  - action\_check\_answer
  - action\_slot\_reset

## Rearrange words question with yes option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“Y”: “yes”}
  - slot{“Y”: “yes”}
  - utter\_ask\_rearrange\_question\_1

- rearrange.answer{“S”: “we”, “V”: “should eat”, “P”: “enough vegetables and cereals”}
  - slot{“P”: [“enough vegetables and cereals”]}
  - slot{“S”: [“we”]}
  - slot{“V”: [“should eat”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_2

- rearrange.answer{“S”: “he”, “V”: “has”, “P”: “plenty of time to sleep”, “C”: “because”, “S”:“he”, “V”:“likes”, “P”:“his job”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“his job”, “plenty of time to sleep”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“likes”, “has”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_3

- rearrange.answer{“S”: “he”, “V”: “works”, “P”: “on a plane”, “C”: “because”, “S”: “he”, “V”: “needs”, “P”: “to be very careful”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“to be very careful”, “on a plane”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“needs”, “works”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_4

- rearrange.answer{“S”: “it”, “V”: “give”, “C”: “and”, “P”: “you vitamins”, “V”: “is”, “S”:“vegetables and fruits”, “C”:“because”}
  - slot{“C”: [“because”, “and”]}
  - slot{“P”: [“you vitamins”]}
  - slot{“S”: [“it”, “vegetables and fruits”]}
  - slot{“V”: [“is”, “give”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_5

- rearrange.answer{“S”: “she”, “V”: “take”, “P”: “photos of famous people”}
  - slot{“P”: [“photos of famous people”]}
  - slot{“S”: [“she”]}
  - slot{“V”: [“takes”]}
  - action\_slot\_set
  - action\_check\_answer
  - action\_slot\_reset

## Rearrange words question with yes option

- greet
  - utter\_greet
  - utter\_rearrange\_question\_detail
  - utter\_rearrange\_question

- rearrange.yes\_no{“Y”: “yes”}
  - slot{“Y”: “yes”}
  - utter\_ask\_rearrange\_question\_1

- rearrange.answer{“S”: “we”, “V”: “should eat”, “P”: “enough vegetables and cereals”}
  - slot{“P”: [“enough vegetables and cereals”]}
  - slot{“S”: [“we”]}
  - slot{“V”: [“should eat”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_2

- rearrange.answer{“S”: “he”, “V”: “has”, “P”: “plenty of time to sleep”, “C”: “because”, “S”:“he”, “V”:“likes”, “P”:“his job”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“his job”, “plenty of time to sleep”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“likes”, “has”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_3

- rearrange.answer{“S”: “he”, “V”: “works”, “P”: “on a plane”, “C”: “because”, “S”: “he”, “V”: “needs”, “P”: “to be very careful”}
  - slot{“C”: [“because”]}
  - slot{“P”: [“to be very careful”, “on a plane”]}
  - slot{“S”: [“he”, “he”]}
  - slot{“V”: [“needs”, “works”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_4

- rearrange.answer{“S”: “it”, “V”: “give”, “C”: “and”, “P”: “you vitamins”, “V”: “is”, “S”:“vegetables and fruits”, “C”:“because”}
  - slot{“C”: [“because”, “and”]}
  - slot{“P”: [“you vitamins”]}
  - slot{“S”: [“it”, “vegetables and fruits”]}
  - slot{“V”: [“is”, “give”]}
  - action\_slot\_set
  - utter\_ask\_rearrange\_question\_5

- rearrange.answer{“S”: “she”, “V”: “take”, “P”: “photos of famous people”}
  - slot{“P”: [“photos of famous people”]}
  - slot{“S”: [“she”]}
  - slot{“V”: [“takes”]}
  - action\_slot\_set
  - action\_check\_answer
  - action\_slot\_reset

domain.yml

```
slots:
Y:
type: text
N:
type: text
S:
type: list
V:
type: list
P:
type: list
C:
type: list
rearrange_answers:
type: list

```

entities:

- Y
- N
- S
- C
- P
- V

intents:

- rearrange.detail
- rearrange.question
- rearrange.answer
- rearrange.yes\_no
- greet

templates: utter\_greet:

- text: “I’m fine, thanks” utter\_rearrange\_question\_detail:
- text: “Holly is playing a game. Read the words and rearrange the words in correct order.” utter\_rearrange\_question:
- text: “Do you know what a sentence structure is? (Yes / No)” utter\_ask\_rearrange\_question\_1:
- text: “Enough / , / vegetables / cereals / we / eat / should / and /” utter\_ask\_rearrange\_question\_2:
- text: “likes / his job / to sleep / , / he / because / plenty of time / has / he” utter\_ask\_rearrange\_question\_3:
- text: “works / he / very / needs / , / to be / careful / on a plane / because / he” utter\_ask\_rearrange\_question\_4:
- text: “give / , / is / fruit / because / you / vitamins / it / and / vegetables” utter\_ask\_rearrange\_question\_5:
- text: “famous / , / photos / she / beautiful / takes / of / people” utter\_rearrange\_structure:
- text: “A basic sentence structure is as follow” image: “[Imgur: The magic of the Internet](https://imgur.com/oaLXpFU)”

actions:

- utter\_greet
- utter\_rearrange\_question
- utter\_rearrange\_question\_detail
- utter\_show\_rearrange\_detail
- utter\_rearrange\_structure
- utter\_ask\_rearrange\_question\_1
- utter\_ask\_rearrange\_question\_2
- utter\_ask\_rearrange\_question\_3
- utter\_ask\_rearrange\_question\_4
- utter\_ask\_rearrange\_question\_5
- action\_check\_answer
- action\_slot\_reset
- action\_slot\_set
- action\_restart

policies:

- name: KerasPolicy epochs: 100 max\_history: 15
- name: FallbackPolicy nlu\_threshold: 0.4 core\_threshold: 0.3 fallback\_action\_name: ‘action\_default\_fallback’
- name: MemoizationPolicy max\_history: 15
- name: FormPolicy

slot `rearrange_answers` only get the latest text from the tracker and I don’t know how to append it to list slot.

here is my custom code `action.py` from rasa\_core\_sdk import Action from rasa\_core\_sdk.events import AllSlotsReset, Restarted, SlotSet

```
class ActionSlotReset(Action):
    def name(self):
    return 'action_slot_reset'

def run(self, dispatcher, tracker, domain):
    return [AllSlotsReset()]

class ActionRestarted(Action):
""" This is for restarting the chat"""
    def name(self):
        return "action_restart"

def run(self, dispatcher, tracker, domain):
    return [Restarted()]

class ActionSlotSet(Action):
    def name(self):
        return "action_slot_set"

def run(self, dispatcher, tracker, domain):
    answer = tracker.latest_message.get("text")
    return [SlotSet("rearrange_answers", answer)]

class ActionCheckAnswer(Action):
    def name(self):
        return "action_check_answer"

def run(self, dispatcher, tracker, domain):
    text = tracker.latest_message.get("text")
    answers = tracker.get_slot("rearrange_answer_1").lower()

```

I don’t know how to set `rearrange_answers` list slot from the user text message. Also, entity values are lost after `action_listen` is executed every time during a story.
