Is there a way to make sure the slots only get filled when executing FormAction?

Hello,

I’m thinking of a situation in which you have a FormAction asking the user to provide some information for planing a meeting like date, time,… (which then get stored in slots). In the FormAction i have some validate function to check if the user provides valid date, time,…

The problem is if i have intents such as inform_date, inform_time, then the user can filled the slots without invoking the FormAction (it’s not normal for them to do so, but i assume in case of them wanting to mess thing up). In that situation, the ‘date’, ‘time’ slots can get filled without being validated (since the FormAction is not being active), and after that if the user invokes the FormAction, the bot won’t ask for those information anymore (since the slots already get filled).

So i want to know if there is a way to make sure some specific slots only get filled when executing FormAction ? Thank you very much.

Hey @fuih, I think the docs here may have an answer to your question. Let me know if this helps. By the way, there is another cool opportunity to chat with other Rasa users, hear about various use cases and talk to the creators of Rasa far beyond the docs pages: the summit :slight_smile:

Thank you for your help, @SamS. The docs help me to understand that the form also validates already filled required slots. But i still want some slots to not get filled outside of a FormAction, is it possible to achieve that ?

About the summit, it’s a really nice opportunity, although it’s not possible for me to participate because i live outside of USA. Thank you for the suggestion though :smiley:.

In that situation, the ‘date’, ‘time’ slots can get filled without being validated (since the FormAction is not being active)

What version of the SDK are you running? Something we added a little while ago is that pre-filled slots are actually validated upon form activation. Does that handle your issue?

Yes after reading the docs which SamS gave me and tried it out, the already filled slot did get validated. That problem is solved. I’m just wondering if there is a way we can make some slots to only be filled in a FormAction, cause if those slots accidentally get filled before (or by the user messing around), the bot will not ask the user to provide infomations for them when invoking the corresponding FormAction (if i’m not mistaking anything), even though they will still be validated (which is good).

Imagine when an user asks to plan a meeting: ‘I want to plan a meeting’. And the bot simply plan a meeting with the information it already had without asking anymore question. I know it’s farfetched but i’m just wondering if we can prevent that kind of behavior. Sorry for wasting your time :smiley:.

cause if those slots accidentally get filled before (or by the user messing around), the bot will not ask the user to provide infomations for them when invoking the corresponding FormAction (if i’m not mistaking anything), even though they will still be validated (which is good).

So the functionality of this depends on what your validation function returns. What we recommend usually is that if the validation passes, you return

{"slot_name": "validated_value"}

and if it doesn’t, return

{"slot_name": None}

If everything is working correctly, when the form activates, the pre-filled slots will be validated, and upon validation, if they are not valid, the slots will be cleared. Then the bot will have to ask for the slot to fill them again.

There are also other ways around this if it’s not working, which I can help you with. But this is definitely the easiest way as it doesn’t involve editing the domain or adding slot mappings.

Definitely not a waste of time! :slight_smile:

I guess my question is, is this what you really want? An example case is if someone already provides a valid email before the start of a form (e.g. subscribe ella@rasa.com to the email list → subscribe_form), i would want to use that information, so long as it is valid, and not ask for it again.

You definitely have a point. I guess i’m just worried about the user messing around (like enter intent inform_date randomly and the fallback policy didn’t catch it) so the slot get filled. Then when they invoke the form it will just use those information. That’s why i asked about validating slots which are already filled, but since that’s solved and we can still validate whatever the user enter before, it probably shouldn’t be a problem. Thank you :smile:.

1 Like

This only applies if the entity and slot have the same name, doesnt it?

OP might use this to get the behaviour he wants though.

@IgNoRaNt23 correct, the slots will only auto-fill if there is an entity with the same name as the slot. So another option could be using a special custom action like action_store_date to fill a date_slot or something like that that has a different name from date in which case it wouldn’t auto fill, you would have to call the storing action to store it.