Hi all,
I am currently building a chatbot that will fill forms to know how to better help a user and provide solutions. I would like to allow my chatbot to be able to detect when the user intent switches, be able to ask for confirmation, then deactivate the current active loop and start a new one for the newly detected intent.
I know that it is advised to provide unhappy paths on rules or stories to manage this type of behaviour, but I would like my chatbot to manage over 10 intents starting forms, and this would mean writing an unmanageable amount of unhappy path.
Instead, I have built this custom action to try and manage all of those unhappy path at once. It detects intents that are not related to the current form, and I would like it to call utter_pi_outside_form to ask for confirmation and then switch path if an affirm is detected, or keep the current active loop if a deny is detected.
### ACTION_ASK classes
class ActionGetParentIntent(Action):
def name(self) -> Text:
return "action_check_parent_intent"
def run(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
intent = tracker.latest_message['intent'].get('name')
lambda x: x.replace(' ', '_')
parent_intents = df['Intentions Parents DialOnce (Super admin)'].unique()
converter = lambda x: x.replace(' ', '_')
parent_intents = list(map(converter, parent_intents))
if intent in parent_intents:
# If intent slot empty, apply filter
print(tracker.get_slot('current_intent'))
if not tracker.get_slot('current_intent'):
print('Setting filter for intent first one')
global filt_tot
filt_tot = (df['Intentions Parents DialOnce (Super admin)'] == intent.replace('_', ' '))
elif tracker.get_slot('current_intent') != intent:
print('New intent, different from previous one')
dispatcher.utter_message(text= f"Nous venons de detecter un \
changement d'intention de votre part. Pouvez-vous nous confi\
rmer qu'il ne s'agit pas d'une erreur, et que vous voulez \
bien {intent.replace('_', ' ')}, et non pas \
{tracker.get_slot('current_intent').replace('_', ' ')}")
return [SlotSet("current_intent", intent if intent is not None else "Not applicable"),FollowupAction('utter_pi_outside_form')]
return [SlotSet("current_intent", intent)]
When I run my chatbot, it is able to detect intent switching successfully, but unfortunately, I get this error.
2022-03-05 14:08:09 INFO rasa.core.actions.action -
Running custom action 'action_check_parent_intent' has resulted in an event of type 'followup'. This is disallowed and the tracker will not be updated with this event.
Could this be because I donât have rules managing this type of path yet?
I have tried using Followup() events on other custom actions of type action_ask_<slot_name> and they work without an issue.
Thanks for reading, I would really appreciate any help here