I am using the TwoStageFallbackPolicy. Within the action ‘action_default_ask_affirmation’, I have a button for affirmation with the payload containing an intent and entities from a user message that has to be affirmed, e.g.,
{'title': 'Yes', 'payload': '/inform{"location":"berlin"}'}
Let’s say I have a slot ‘location’ that is filled with the value of the corresponding entity.
However, when a user affirms, ‘action_revert_fallback_events’ reverts not only fallback events but also the filling of the slot “location”. So what I have after affirmation is: intent=inform, entity_location=berlin, slot_location=None.
How can I prevent the slot filling to be reverted after affirmation?
Hi @Tobias_Wochinger ,
Thanks for your reply! I am glad that it will be fixed in one of the next versions and I won’t have to use my custom workaround anymore.
I had to add the following modifications to _run_action() method in rasa_core.processor.MessageProcessor
def _run_action(self, action, tracker, dispatcher, policy=None,
confidence=None):
# events and return values are used to update
# the tracker state after an action has been taken
try:
events = action.run(dispatcher, tracker, self.domain)
# custom code starts here
# after ACTION_REVERT_FALLBACK_EVENTS_NAME,
# fill slots from entities of the last user message
if action.name() == ACTION_REVERT_FALLBACK_EVENTS_NAME:
logger.debug('Filling slots after {} if necessary'
.format(ACTION_REVERT_FALLBACK_EVENTS_NAME))
last_user_event = tracker.get_last_event_for(UserUttered)
for e in self.domain.slots_for_entities(last_user_event.parse_data["entities"]):
events.append(e)
# custom code ends here
except ActionExecutionRejection:
.....
So at the end I have a custom Agent (rasa_core.agent.Agent) that uses a custom MessageProcessor where the _run_action() method is overwritten as shown above.
I don’t know if it is the best way to solve the problem. But it works at least until the official fix will be released.