How do we access list slot is rasa custom actions?

is there any way to append and remove values from a list slot. because when i access the list slot by current_list = tracker.get_slot("ques_order") and utter, it will return None instead of list. how i manage this problem.

this how i created the list slot;

ques_order:
    type: list
    influence_conversation: false
    mappings:
    - type: custom

Hi Nadhir,

the behaviour you’re explaining is the default since you haven’t set list to anything so it is set to None.

You can change the initial value by setting initial_value property when defining the slot.

I see that you have custom mapping set for the slot so I guess you’d like to modify it through code. To do so you can use something like this:

class ActionCheckRestaurants(Action):
   def name(self) -> Text:
      return "action_check_restaurants"

   def run(self,
           dispatcher: CollectingDispatcher,
           tracker: Tracker,
           domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

      cuisine = tracker.get_slot('cuisine')
      q = "select * from restaurants where cuisine='{0}' limit 1".format(cuisine)
      result = db.query(q)

      return [SlotSet("matches", result if result is not None else [])]

Please note the SlotSet portion. With this event you’re able to set your ques_order to any list value you’d like.

Let me know if this answers your question and if I can assist you any further.

Regards, Nikola