I recently started working with rasa and am a little unsure of how slot_was_set works.
Specifically,
does slot_was_set tell rasa about slots set in the immediately preceding intent or custom action or can it be used as a conditional check for slots populated much earlier in the conversation?
For example, if I wanted to greet a customer based on whether the slot customer_id is set or not, does it make sense to do this:
I know I could just use a custom action which reads the slot customer_id and utter the correct response based on that, but I want to understand how slot_was_set works. Since customer_id isnāt exactly being set in this story, would slot_was_set actually work as expected? For me, this seems to work most of the time but since thereās a lot going on in the project, Iām not sure if there are some other factors affecting this.
One way to be sure would be to just use a āslot_setterā custom action that just reads all relevant slots and sets them to the same value again. The run method would look something like this:
TLDR:
Does slot_was_set tell rasa about slots set in the immediately preceding intent or custom action or can it be used as a conditional check for slots populated much earlier in the conversation or slots yet to be populated (currently having their defaullt value)? How does slot_was_set exactly work?
Yes for both questions. It can be used for conditional stories by checking if the slot had a particular value.
To be honest I donāt know about a null value for slot_was_set, since, as you said later, ācustomer_id isnāt exactly being set in this storyā. I would usually use Custom Actions in that case.
Just try if it works like that and keep us updated!
Try to use a rule instead of a story for the null slot.
Yeah thatās a nice way to make sure the slot is set even if it is null. Again, just try out your multiple options and keep the best one!
I know Iām telling you to try a lot. Iāve seen your question since it was posted and hoped someone more knowledgeable than me would reply, but nobody did and youāre still waiting so I answered.
Thanks a lot for the reply @ChrisRahme ! You answered one of my main questions here:
Does slot_was_set work even for slots set much earlier in the conversation. Ans: Yes
My second query, which you said you werenāt sure about is:
Can it be used for checking if slots havenāt been modified yet (still with their default values) even if that default value is null?
Hopefully, someone will have an answer for that.
My biggest issue regarding this is that certain things work most of the time, most likely due to the model learning from the stories. So though I can try (and already have, in most cases) different implementations, Iām never really confident if something is working just because of the model as opposed to a correct implementation on my part.
So though using slot_was_set to check for a slot being in its default value (null in this case) works, Iām not certain if its a good practise to do it this way.
@Polaris000 If I can suggest to you, please try use rasa interactive and you will be able to see how slot and slot_was_set is working, as you input it will display all the values and for next requested slots etc. I hope you will try
Thanks for the reply @nik202 . By rasa interactive, do you mean using the interactive command line mode by running rasa interactive? Iāve used that once before (prefer rasa x over that) but donāt remember anything that would suggest how slot_was_set works.
In any case, Iāll try that again and let you know if I find my answer. Thanks for pointing me in the right direction.
Hey @Polaris000 - did you discover an answer to your question?
Coming from a classical CS/programming background (object-oriented programming, state machines, etc) I find myself struggling to get Rasa to do what I want, and your question in this thread really resonated for me.
i.e. Can I use slot_was_set with specific values at the beginning of each story, to achieve which story gets āactivatedā based on current state? This would enable - for my use-case - an easy way to modularize stories into smaller sub-stories (similar to Dialogflow CXās workflow, which works like a state machine).
If anyone can direct me to other questions which may target an audience like me (someone who is trying to break down a bot in a manner similar to state machine), and why that is a good or bad idea, Iād very much appreciate it.
Hi @invalid-access . What worked for me was starting and ending modularized stories with the same action and setting a slot again at key points where I want it to have a stronger impact on the conversation.
there have been talk that using a null can be weird or unpredictable, but
14:54
there is explicit talk of using slot with a data or with no data, how I can implement this if not when using a ānullā? Is it not a regular thing to do if it is in tutorial vide of Rasa? In the video there is no talk about using custom actions as was mentioned above, there is talk only about slots and influecnce_conversation: true