So my requirement is this, I want to give users an option to stop the conversation in between, like this
something
Do you have this?
yes
Do you have that?
stop
utter_ask_continue
no
utter_okay
so after getting a stop signal(intent) from user bot will ask if user wants to continue or not, if not it should stop, otherwise it should ask the same question again, like this:
something
Do you have this
yes
Do you have that
stop
utter_ask_continue
yes
Do you have that
solution 1: you should add stories having this feature.
tried both the keras policy and embedding policy but the results are not great, it is just memorizing the training stories and not working properly on unseen stories.
solution 2: you should add a custom action(may be form action) which should retrieve the last executed action, and according to user’s reply should force either okay message or the last action.
now the problem here is how to retrieve the last executed action, since it is action_listen most of the time, is there any way to get last 2 or 3 actions and forcing the last action again.
##goes back through the list of events and finds
##the last utter_action
for event in reversed(tracker.events):
try:
#print("current action name is", event.get('name'))
if event.get('name') not in [ 'action_listen', None, 'utter_ask_continue' ] :
last_utter_action = event.get('name')
#print('found action', last_utter_action)
return last_utter_action
else :
#print(event.get('name'))
pass
except:
pass
#print(event.get('text'))
return 'error! no last action found'
@lgrinberg Thank you so much, so i am able to get the required last action but struggling with adding it again to tracker, i’m using this
return [FollowupAction(next_action)]
but it is throwing a error: TypeError: Object of type FollowupAction is not JSON serializable
@lgrinberg It worked, basically issue was with import rather then using rasa_core_sdk I used rasa_core to import FollowupAction, thank you so much for help.
Hi @lgrinberg even this approach(getting previous action and sending it back as a followup action) is also not that good, it is just memorizing the stories and not working good in general, mostly in cases when user wants to continue after the interruption, it should behave just like original stories(without interruption). Can you suggest any other approach for the problem described in the first message. thanks