Triggering action_default_fallback from custom form slot validation code

Hi,

I have a slot within a form which uses some fuzzy search logic to match what the user enters against a list. As this is a dynamic list and can’t be handled with RASA entity lists etc., the form slot is marked as “from_text” - I place all the validation into the code.

This works as expected but if the user does not match I want to call the action_default_fallback action to trigger the “I did not understand” response. This action also has some custom code to count the number of repeated incorrect inputs to leave the form should they get stuck i.e. I can’t simply use the dispatcher to display the fallback response.

Is there a way to trigger an action using form validation code on this specific form slot?

Thanks!

1 Like

Not sure if that’s the best way to do it but here’s my idea:

You’re probably inside a validation action, so you cannot return the FollowupAction event. But you can set a particular slot to a particular value.

You create a story and/or rule which checks if this slot and/or value was set, and then trigger a specific action. This action will in turn return the FollowupAction event.

Or maybe you directly predict action_default_fallback in the story/rule.


Anyway, I don’t understand why you’d want to fallback. Can’t you set the slot the None and utter “I did not understand”? And you use another slot to count/increment the number of incorrect inputs. I did exactly thing for a username/password wrong info counter.

1 Like

Hi Chris,

Thanks for responding.

As mentioned in my post, I have logic in my action_default_fallback action to cater for stuck loops i.e. if you are requesting a slot and you have had the default fallback response in 3 successive turns (when requesting a slot), it jumps out the form - without going into too much detail, there is additional logic in there meaning I can’t just utter the default fallback message in my validation code.

As you say, I could create a rule of course to trigger on a particular slot being populated - I did think of that myself. I wondered if I was missing something but this route isn’t the end of the world. Certainly modular and easy to understand.

Thanks for commenting!

Mark

1 Like

Hi Chris,

So I tried what I thought was right, but I can’t get it to trigger the default action fallback.

In my validation code I set a slot called “call_default_fallback” to True when validation fails. Then I have a rule to try and force the action_default_fallback call before my next action_listen:

- rule: Call default fallback
  condition:
  - slot_was_set:
    - call_default_fallback: True
  steps:
  - action: action_default_fallback

Is this what you meant?

Thanks Mark

Can anybody else give some guidance here? I’ve read rules are ignored in a form so the above will never trigger.

How do I trigger an action from validation code in RASA? Is this possible?

Thanks Mark

Hm yeah this is it what I meant.

But maybe the format is not correct? Try something more like this:

- story: Story
  steps:
  - intent: log_in
  - action: form_log_in
  - active_loop: form_log_in
  - slot_was_set:
    - call_default_fallback: True
  - action: action_deactivate_loop
  - active_loop: null
  - action: action_default_fallback

Hi Chris,

Not sure that will work for me. I’m in the middle of a form and I simply don’t know what intent will be triggered. I also want to return to the form slot.

The behaviour I get at the moment is perfect if I use a slot_type of “from_entity” i.e if the entity is not extracted and therefore can’t be validated, the default fallback is called (i.e. the action action_default_fallback). Seems there is no way of easily having the same behaviour if my slot_type is “from_text” and I have my own slot validation.

I’ve tried a few things today and all have ended in failure.

Frustrating to say the least. Thanks for trying to help though Chris! Maybe a RASA employee could suggest something?

Mark

1 Like