Problem triggering a form from a custom action in Rasa 3

Thank you @stephens

TL;DR

The solution was to add two FollowupAction events and stories.

I’m probably not understanding Rasa very well, but as a new user I’d like to see an easier way to do do this if there was an event that could trigger a rule or intent directly. It appears that a couple actions being triggered allows a story to be used, which seems like a hack compared to triggering an intent or rule directly.

        slot_events.append(FollowupAction(name="utter_hello_form"))
        slot_events.append(FollowupAction(name="my_form"))

From the readme in my github repo demonstrating the issue you’ll see that the form works as expected when triggered from an intent retrieved from dialog, but not from a custom action.

I’ve used UserUttered to mock triggering the intent, and I’ve tried using a condition, slot is set to trigger the form. Neither seems to work.

I’ve demonstrated the issue and provided a complete config here. Unsure if this is a bug or an issue with my configuration of intents, slots, forms;… or something else.

GitHub - Hendler/rasa-form-from-custom-action

Filed a bug also Rasa 3 - form activation from custom action failing with several approaches · Issue #11049 · RasaHQ/rasa · GitHub

As a preview

The way I’m trying to do so is with simulating a user inent using UserUttered:

slot_events = []
intent = {"intent": {"name": "activate_my_form", "confidence": 1.0}}
utter_event = UserUttered("Activate my form", intent)
slot_events.append(utter_event)
return slot_events

I have also tried this in the

slot_events.append(SlotSet(key="my_form_trigger", value=True))

I’ve read Rasa is not triggering the custom form action for example , Have problem Triggering rasa intents and custom actions in a independent program and many others.

I’m not sure where to focus in the logs or configs to understand the issue, as I’d expect the form to be activated:

  • I see errors like Circuit breaker tripped. Stopped predicting more actions for sender
  • There is no memorised next action
  • There is no trained model for 'ResponseSelector': The component is either not trained or didn't receive enough training data.
  • Action 'action_default_fallback' ended with events '[<rasa.shared.core.events.UserUtteranceReverted object at 0x1a7e4f850>]'.
  • rasa.core.policies.unexpected_intent_policy - Skipping predictions for UnexpecTEDIntentPolicy as either there is no event of type UserUttered, event's intent is new and not in domain or there is an event of type ActionExecutedafter the lastUserUttered.

current status looking at the policy file

In debugging we see DefinePrevUserUtteredFeaturization

  • action_default_fallback

Reading Rasa-core: 'action_default_fallback' triggered for valid input - #3 by madhanaravind added

  • AugmentedMemoizationPolicy

Reading Action_default_fallback always prompted when threshold is high

added

  • model_confidence: softmax

Then saw

  • Skipping predictions for UnexpecTEDIntentPolicy as either there is no event of type UserUttered, event’s intent is new and not in domain or there is an event of type ActionExecuted after the last UserUttered.

Led to

It looks from your code like you tried FollowupAction which is the way to do this.

slot_events.append(FollowupAction("utter_hello_form"))

However, I don’t generally use FollowupAction as a first approach. The rules & stories in the financial-demo show a good approach to forms.

I created a branch with the change and some comments/questions on your pipeline in NOTES.md.

2 Likes

Thanks for looking!

I tried followupaction, and it seems that it triggers a single action but not the story, form, or rule. Maybe I need to try your changes when I am in front of a computer again. Did you see the form fully execute with that change?

More context, the repo is a contrived example from another repo. So the configuration is from there.

Spacy is for entity extraction, Bert for a custom component.

There’s no rule/story for custom_action_intent. Also, why not invoke action_hello_world from a rule/story instead of a custom action?

The goal is that any custom action could trigger the form depending on custom business logic that preprocesses messages to any custom action.

I wanted to avoid all the stories. It can’t be an intent rule because most times the intents will not trigger the form. There can be slot is set rules or action rules, so I guess I just needed to sort through when rules and stories could be triggered.

Thanks for following up!

yes you can achieve dynamic flow in forms, but it’s not with custom action but customizing the flow of forms. If you look at docs, you will find there is a method called as required_slots this method will help you remove or append any slots and based on that Rasa will run validation method named with prefix as extract_

1 Like

Thank you. Dynamic forms make sense, but in this case I think it might be different because there are multiple forms called from multiple actions, and we don’t want an active loop for a single form running.

The dynamic form approach seems good for a lot of cases though. I also see slot is set condition to trigger a form, but the code sample I have didn’t seem to work.

I wanted to avoid all the stories

Yes, you can do this without FollowupAction and without a lot of stories. The financial demo takes a good approach that scales. It also handles changing flows between forms or out of and back to a form.

Regarding the use of BERT. There are a couple of good Rasa blog posts on this here and here.

I know this is solved, but I just wanted to jump in and say there’s so much useful information in this post. @Hendler great job debugging and posting details as you went complete with a GitHub repo. :+1: