Set multiple Slots

rasa-core

(Max ) #1

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.

Thanks!


(Hendrik Niefeld) #2

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


(Souvik Ghosh) #3

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?


(Hendrik Niefeld) #4

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


(Souvik Ghosh) #5

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"})

(Max ) #6

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


(Max ) #7

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.


(Hendrik Niefeld) #8

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


(Max ) #9

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

Thanks guys!


(Souvik Ghosh) #10

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


(Deepak Shetty) #11

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 ?


(Hendrik Niefeld) #12

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

rasa_core~=0.10.2


(Leo@Vocinity) #13

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])
             slots.append(slot)
        return slots

(Max ) #14

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


(Agustin Gonzalez) #15

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

Thanks!