# Setting slot without returning SlotSet (there's a reason)

**URL:** <https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921>\
**Category:** Rasa Open Source\
**Created:** [October 16, 2019, 8:49pm UTC](https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921 "2019-10-16T20:49:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [October 16, 2019, 8:49pm UTC](https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921/1 "2019-10-16T20:49:56Z")

</div>

I manage a fair bit of user state in actions - mostly flags and counters - so I can be smarter handling failure cases - e.g., if they don’t understand me one way, I’ll try to express it a different way. If they don’t get that, I might do a final way and if that fails, I’ll just set some default value.

So I have a user\_obj slot that is a stringified json object that holds this stuff. Ideally, I’d like to just have a few functions exposed to actions that hide all the slot interface. e.g.,

```
if user_increment('shoe_size_fails') == 10:
  dispatcher.utter_message("Seriously, I'm sick of asking you. What is your shoe size?")

```

where user\_increment is a convenience function that adds 1 to the user property ‘shoe\_size\_fails’.

and then user\_increment() manages the interface with the slot. Otherwise, I have to return the json string from these functions and then every action validate function has to remember to set the slot, etc. It just makes things much messier.

Is there a way that I can encapsulate the slot set in the user object functions? If not, I’ll probably just maintain it myself outside of Rasa, but I’d like to avoid if possible.

Thx.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 22, 2019, 9:21am UTC](https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921/2 "2019-10-22T09:21:13Z")

</div>

@mmm3bbb i don’t fully understand what you’re trying to do. Does `user_incrememnt` set some sort of slot?

---

<div class="post-metadata">

**Author:** ![mmm3bbb](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mmm3bbb](https://forum.rasa.com/u/mmm3bbb)\
**Post date:** [October 22, 2019, 5:25pm UTC](https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921/3 "2019-10-22T17:25:45Z")

</div>

@akelad. Sort of it. It sets a property on an object that is stored in the unfeaturized user\_obj slot. e.g., user\_obj slot = ‘{“shoe\_size\_fails”:3, “user\_level”:“pro”, etc.}’ In an action, when I need some user property, I deserialize this, get the property, modify the property and reserialize and store back into the user\_obj slot.

I want to do this instead of creating a new unfeaturized slot for each user property because it really simplifies things for me. I am creating about 50 different models and each one will need to store its own user properties. With this approach, all I have to do is create a ‘user\_obj’ unfeaturized slot in each model and then I can reuse the functions that set/get properties on that as I described above.

Otherwise, I have to maintain a list of unfeaturized slots for every model and then in my action code, I need to return [SlotSet()] for each of these. I know that doesn’t sound like that much, but it’s more clutter and it’s multiplied by 50 times.

To make this clean, I need to set the user\_obj slot from a centralized function instead of having to return it as an event (yes, I could simply return the slot set event for the user\_obj for each validate function, but that defeats the purpose).

Because I don’t know how to set a slot value directly (without returning an event), I have simply moved all this out of Rasa. I now just store this user\_obj data in Redis (keyed by session id). It works fine, but I wouldn’t need to do this if I could just set the slot from a central function.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [October 25, 2019, 1:15pm UTC](https://forum.rasa.com/t/setting-slot-without-returning-slotset-theres-a-reason/19921/4 "2019-10-25T13:15:49Z")

</div>

@mmm3bbb to be honest I think the approach you’ve gone with is a better solution than doing it inside rasa
