Unable to Change Forms based on slot value

Hello Everyone, I have a scenario in which I am executing a form A, based on users response i need to switch to form B or form C. I have tried using slot_was_set in stories as well as rules. But stories are ending up predicting action_listen if both the conditions are applied. If I apply only one condition, then form is switched.

My Story-

  • story: car insurance form for old steps:

    • intent: make_claim_car
    • action: car_form
    • active_loop: car_form
    • slot_was_set:
      • car_insurance_exist: [“yes”]
    • active_loop: null
    • action: insurance_holder_form
    • active_loop: insurance_holder_form
  • story: car insurance form for new steps:

    • intent: make_claim_car
    • action: car_form
    • active_loop: car_form
    • slot_was_set:
      • car_insurance_exist: [“no”]
    • active_loop: null
    • action: new_car_inc_form
    • active_loop: new_car_inc_form

If I am writing any one of the above story then the form gets switched and as per the slot value next action/form is executed. But If I mention both the stories then action_listen is predicted.

Can we not switch from One Form to Another based on slot value? Please Help. I am using Rasa 2.2

I’m wondering if it makes sense to switch forms here or to have a dynamic form. It’s possible to add/remove slots from the current form based on what somebody has filled in. The dynamic form behavior is documented here. Is there a reason why this might not work for your use-case?

1 Like

@koaning Thanks for the response.

I know that this could be solved by using actions.py , but we wanted to achieve this solely by using stories, rasa core part.

Is it, at all possible to use stories and achieve this? If yes, what I am missing out in stories?

I need to double check but I think that the active_loop is something that is specific to forms.

@Ghostvv can you confirm?

I am indeed using forms. The main doubt is that, just based on stories I am unable to achieve conditional form execution, i.e. Just based on slot values making the current form null and starting another form.

It feels to me like it might be preferable to make a single form to handle all of this logic. Alternatively, you could also make rules for these where you add a condition on the car_insurance_exists slot. One thing: is there a reason why you cannot do all of this in a single form?

You might find this tutorial video on dynamic forms useful on youtube. It’s explaining a different use-case but it does demonstrate how the forms can be dynamically generated based on the values of slots.

the switching concept based on slots should be possible. Could you please elaborate what do you mean by

But stories are ending up predicting action_listen if both the conditions are applied.

ahh, do you mean if you put both stories in the training data?

what type of slot do you use for car_insurance_exist?

@Ghostvv Yes If I put both the stories I get no response and If I repeat one story twice then that story is predicted.

I have tried with both type text and unfeaturized for the slot.

@koaning I tried it with rules, it gives contradiction while training.

We need to maintain different form as each form is expected to contain comparatively larger number of questions. And more importantly we want to achieve this with stories/rules solely and not action server.

I have tried with both type text and unfeaturized for the slot.

unfeaturized slot doesn’t influence the prediction at all, text slot featurization is independent of the value. You need to use categorical or bool slot, then you can use it in both rules and stories and they shouldn’t be contradicting.

1 Like