Set multiple Slots

Hey there!

Is return[SlotSet("key", "value")] the only way to set slots? I’d like to set multiple slots from within a python if statement.


I have the same issue: How do you set multiple slots at once?

I may be wrong here but isn’t that an array you are returning

return [SlotSet("key","value1"), SlotSet("key2","value2"]

this won’t work?

That does not work for me - second SlotSet gets ignored…

Sorry I use the HTTP API /continue and send events of type slots

({"event": "slot", "name": "cuisine", "value": "mexican"},{"event": "slot", "name": "location", "value": "CA"})

Could it be possible to solve via the training stories? By calling multiple times - slot{"key":"value"}

okay that doesn’t seem to work. Is there something like tracker.set_slot("key", "value") equivalent to the method tracker.get_slot("key")? That would be something good to call out of a python method.

Okay - in my case, problem was one of the keys got a value “None” - filled it with a “0” and it works fine now

1 Like

Yes in fact I also got it to work with multiple SlotSets in return of submit

Thanks guys!

Can you post your solution? It might help others :slight_smile:

Setting multiple slot works fine for me . When you say ignored what do you mean - It might be the slot is set but things are not working (or perhaps your custom action is throwing an error )- if you use interactive mode , you can see the set slots etc and if any error got thrown

I have something like this in my CustomAction which works slot_set.append(SlotSet(“x”, y)) if (x != ‘zero’) : available_x = psc.get_x(res) slot_set.append(SlotSet(“available_x”,list(available_x))) return slot_set and both can set

Also which version of rasa ?

Yes works for me too now - problem was one of the keys got a value “None” - i filled it with a “0” and that did it


SlotSet is a class. So what you can do is create a list of class SlotSet objects and then return it.
Like this:

        for key in slot_keys_values.keys(): 
             slot=SlotSet(key, slot_keys_values[key])
        return slots

Sure thing! It’s as easy as:

return[SlotSet("Key1", "Value1"), SlotSet("Key2", "Value2")]

Of course this way only can be done with a fixed number of slots to fill

Hello, a have a question: If a need excute an Action in RASA CORE 0.11.2…

I use core.sdk so:

  • last version: tracker.update(SlotSet(“my_slot”, “value”)) OR tracker.slots[‘my_slot’] = value

dispatcher.utter_message(’…’, tracker, {‘name’ : tracker.get_slot(‘my_slot’) })

return[SlotSet(“my_slot”, “value”)]

  • new version ? tracker.slots[‘my_slot’] = value //None so: utter_message value is None


works perfectly as expected


return [SlotSet(“rating”,None), SlotSet(“relation_operator”,None)]