Getting action_listen for followup_action value even after adding a followup action

Hi,

I followed the docs -

http://rasa.com/docs/core/api/events/#force-a-followup-action

and added custom action like this -

class ActionResetPass(Action):

def apply_to(self, tracker):

  tracker.trigger_follow_up_action(self.ActionEmployeeCodeInput)

Now according to the docs i should get my next action name in followup_ action value but that is not happening rather i am getting action_listen instead!

this should be called in your actions run method

here’s a guide on how to write custom actions, you should only need to define the name() and run() methods

you mean to say that i will have to add this -

tracker.trigger_follow_up_action(self.ActionEmployeeCodeInput)

in my class run method?

my action server is displaying error on doing that

image

tracker.trigger_followup_action() i belive it’s called

so their should be correction in docs

https://rasa.com/docs/core/api/events/#force-a-followup-action

changing that also did not made any diff getting same error from action server

tracker.trigger_followup_action(self.ActionEmployeeCodeInput)

AttributeError: ‘Tracker’ object has no attribute ‘trigger_followup_action’ 127.0.0.1 - - [2018-09-17 16:48:41] “POST /webhook HTTP/1.1” 500 412 0.000000

my code is this -

class ActionResetPass(Action): def name(self): return ‘next_action_ask_user_empID’

def run(self, dispatcher, tracker, domain):

 tracker.trigger_followup_action(self.ActionEmployeeCodeInput)
  
  response ="Pls provide with your employee code"

  dispatcher.utter_message(response)

Oops actually sorry, if you’re triggering a followup action from the action server, you should return a FollowupAction("action_name") event

4 Likes

nothing of this sort is mentioned in docs… So i have to pass FollowupAction(“action_name”) in return like we do for slot setting… am i right?

for instance -

return [SlotSet(‘mobNum’,mobNum),FollowupAction(“action_name”)]

1 Like

yes, it’s mentioned here: https://rasa.com/docs/core/api/events/#force-a-followup-action

1 Like

Does this followup action work for you? When I try to execute FollowupAction(“enter_name”), it is getting executed but then default_fallback_action is getting predicted before its goes to “Action_listen”. As I am not getting much from forum, I am trying to debug the code to find the process steps. If you have any updates on this, pls do share. Thnk you.

2 Likes

Never mind. Its working as expected.

How did you fix it? I’m having some similar trouble right now :frowning:

@pnandhini yes, how did you fix it? @EllisonFord did you managed to fix it?

I just changed the training policy until I got one that didn’t mess up. I had to remove the KerasPolicy. Hope it works for you as well.

1 Like

I use a custom action function to decompose a multi-intent to its respective intents’ actions. However, enqueuing multiple FollowupActions in this custom action does not lead to execution of all FollowupActions. It seems that the first Followup action is properly acted upon, but other policies interrupt subsequently queued FollowupActions:

Here is an action for a multi-intent that is supposed to enqueue other actions:

class ActionMulti_VC_CT(Action):

    def name(self):
        return "action_VC_CT"

    def run(self, dispatcher, tracker, domain):

        intent = tracker.latest_message['intent'].get('name')
        list_of_actions = routeMultiIntent(intent)

        if len(list_of_actions) > 0:
            return [FollowupAction(x) for x in list_of_actions]
        else:
            return [FollowupAction("action_default_fallback")]

When it is triggered, the tracker correctly prints that two followup actions are registered for the particular multi-intent inform_partyVehics+inform_peopleCount:

2020-05-04 00:39:50 DEBUG rasa.core.processor - Action 'action_PV_PC' ended with events '[<rasa.core.events.FollowupAction object at 0x7f2c242c05d0>, <rasa.core.events.FollowupAction object at 0x7f2c24242c50>]'.

(these followup actions are action_inform_partyVehics and action_inform_peopleCount):

However, as you can see, the bot only does the first FollowupAction:

Your input ->  3 adult and 2 kids. 2 cars                                                                                                                          
2020-05-04 00:39:50 DEBUG    rasa.core.tracker_store  - Recreating tracker for id 'c21e2c7a4d2640489471956fc08795e6'
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Received user message '3 adult and 2 kids. 2 cars' with intent '{'name': 'inform_partyVehics+inform_peopleCount', 'confidence': 0.5743247866630554}' and entities '[{'entity': 'number_people', 'start': 0, 'end': 1, 'extractor': 'DIETClassifier', 'value': '3'}, {'entity': 'number_people', 'start': 12, 'end': 13, 'extractor': 'DIETClassifier', 'value': '2'}, {'entity': 'number', 'start': 20, 'end': 21, 'extractor': 'DIETClassifier', 'value': '2'}, {'start': 0, 'end': 1, 'text': '3', 'value': 3, 'confidence': 1.0, 'additional_info': {'value': 3, 'type': 'value'}, 'entity': 'number', 'extractor': 'DucklingHTTPExtractor'}, {'start': 12, 'end': 13, 'text': '2', 'value': 2, 'confidence': 1.0, 'additional_info': {'value': 2, 'type': 'value'}, 'entity': 'number', 'extractor': 'DucklingHTTPExtractor'}, {'start': 20, 'end': 21, 'text': '2', 'value': 2, 'confidence': 1.0, 'additional_info': {'value': 2, 'type': 'value'}, 'entity': 'number', 'extractor': 'DucklingHTTPExtractor'}]'
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Current slot values: 
	age: None
	can_use_spacy: None
	countTime: 2020-05-04T12:00:00.000-07:00
	current_api: None
	data_stored: None
	entity_extractor: None
	feedback_message: None
	feedback_value: None
	howLong: None
	language: None
	name: None
	nlu_part: None
	onboarding: None
	package_manager: None
	partyVehics: None
	peopleCount: 3
	problem_description: None
	product: None
	requested_slot: partyVehics
	returnStatus: restart
	search_results: None
	seenBefore: False
	seenPastDay: None
	shown_privacy: None
	source: None
	step: None
	suggestion: None
	trailVisits: None
	unknown_nlu_part: None
	unknown_product: None
	vehicleCount: 7
	yearBorn: None
	zipCode: None
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 204 events.
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - Current tracker state [{'prev_action_listen': 1.0, 'intent_hello': 1.0}, {'prev_action_setDefaultSlotValues': 1.0, 'intent_hello': 1.0}, {'prev_utter_hello': 1.0, 'intent_hello': 1.0}, {'prev_count_episode': 1.0, 'active_form_count_episode': 1.0, 'intent_hello': 1.0, 'slot_returnStatus_2': 1.0}, {'prev_action_listen': 1.0, 'active_form_count_episode': 1.0, 'entity_number_people': 1.0, 'intent_inform_partyVehics+inform_peopleCount': 1.0, 'entity_number': 1.0, 'slot_returnStatus_2': 1.0}]
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-05-04 00:39:50 DEBUG    rasa.core.policies.mapping_policy  - The predicted intent 'inform_partyVehics+inform_peopleCount' is mapped to  action 'action_PV_PC' in the domain.
2020-05-04 00:39:50 DEBUG    rasa.core.policies.form_policy  - There is an active form 'count_episode'
2020-05-04 00:39:50 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-05-04 00:39:50 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_MappingPolicy
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Predicted next action 'action_PV_PC' with confidence 1.00.
2020-05-04 00:39:50 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'action_PV_PC'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Action 'action_PV_PC' ended with events '[<rasa.core.events.FollowupAction object at 0x7f2c242c05d0>, <rasa.core.events.FollowupAction object at 0x7f2c24242c50>]'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Current slot values: 
	age: None
	can_use_spacy: None
	countTime: 2020-05-04T12:00:00.000-07:00
	current_api: None
	data_stored: None
	entity_extractor: None
	feedback_message: None
	feedback_value: None
	howLong: None
	language: None
	name: None
	nlu_part: None
	onboarding: None
	package_manager: None
	partyVehics: None
	peopleCount: 3
	problem_description: None
	product: None
	requested_slot: partyVehics
	returnStatus: restart
	search_results: None
	seenBefore: False
	seenPastDay: None
	shown_privacy: None
	source: None
	step: None
	suggestion: None
	trailVisits: None
	unknown_nlu_part: None
	unknown_product: None
	vehicleCount: 7
	yearBorn: None
	zipCode: None
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Predicted next action 'action_inform_peopleCount' with confidence 1.00.
2020-05-04 00:39:50 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'action_inform_peopleCount'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Action 'action_inform_peopleCount' ended with events '[<rasa.core.events.SlotSet object at 0x7f2c24018a50>]'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Current slot values: 
	age: None
	can_use_spacy: None
	countTime: 2020-05-04T12:00:00.000-07:00
	current_api: None
	data_stored: None
	entity_extractor: None
	feedback_message: None
	feedback_value: None
	howLong: None
	language: None
	name: None
	nlu_part: None
	onboarding: None
	package_manager: None
	partyVehics: None
	peopleCount: 3
	problem_description: None
	product: None
	requested_slot: partyVehics
	returnStatus: restart
	search_results: None
	seenBefore: False
	seenPastDay: None
	shown_privacy: None
	source: None
	step: None
	suggestion: None
	trailVisits: None
	unknown_nlu_part: None
	unknown_product: None
	vehicleCount: 7
	yearBorn: None
	zipCode: None
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'prev_action_listen': 1.0, 'intent_hello': 1.0}, {'prev_action_setDefaultSlotValues': 1.0, 'intent_hello': 1.0}, {'prev_utter_hello': 1.0, 'intent_hello': 1.0}]
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - There is a memorised next action 'count_episode'
2020-05-04 00:39:50 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'inform_partyVehics+inform_peopleCount'.
2020-05-04 00:39:50 DEBUG    rasa.core.policies.form_policy  - There is an active form 'count_episode'
2020-05-04 00:39:50 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-05-04 00:39:50 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_0_MemoizationPolicy
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Predicted next action 'count_episode' with confidence 1.00.
2020-05-04 00:39:50 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'count_episode'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Action 'count_episode' ended with events '[BotUttered('How many vehicles did your party bring to the trailhead today?', {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, {"countTime": "2020-05-04T12:00:00.000-07:00", "peopleCount": "3", "requested_slot": "partyVehics", "returnStatus": "restart", "vehicleCount": 7}, 1588552790.6476474), <rasa.core.events.SlotSet object at 0x7f2c24172290>]'.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Current slot values: 
	age: None
	can_use_spacy: None
	countTime: 2020-05-04T12:00:00.000-07:00
	current_api: None
	data_stored: None
	entity_extractor: None
	feedback_message: None
	feedback_value: None
	howLong: None
	language: None
	name: None
	nlu_part: None
	onboarding: None
	package_manager: None
	partyVehics: None
	peopleCount: 3
	problem_description: None
	product: None
	requested_slot: partyVehics
	returnStatus: restart
	search_results: None
	seenBefore: False
	seenPastDay: None
	shown_privacy: None
	source: None
	step: None
	suggestion: None
	trailVisits: None
	unknown_nlu_part: None
	unknown_product: None
	vehicleCount: 7
	yearBorn: None
	zipCode: None
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'prev_action_listen': 1.0, 'intent_hello': 1.0}, {'prev_action_setDefaultSlotValues': 1.0, 'intent_hello': 1.0}, {'prev_utter_hello': 1.0, 'intent_hello': 1.0}]
2020-05-04 00:39:50 DEBUG    rasa.core.policies.memoization  - There is a memorised next action 'count_episode'
2020-05-04 00:39:50 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'inform_partyVehics+inform_peopleCount'.
2020-05-04 00:39:50 DEBUG    rasa.core.policies.form_policy  - There is an active form 'count_episode'
2020-05-04 00:39:50 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2020-05-04 00:39:50 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_3_FormPolicy
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2020-05-04 00:39:50 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'.
2020-05-04 00:39:50 DEBUG    rasa.core.lock_store  - Deleted lock for conversation 'c21e2c7a4d2640489471956fc08795e6'.

After the first action_inform_peopleCount is executed, the second followup action is nowhere to be seen, and the line 2020-05-04 00:39:50 DEBUG rasa.core.policies.memoization - There is a memorised next action 'count_episode' occurs.

How can you execute multiple enqueued followup actions?

This is the first “nested” action that is called as a FollowupAction:

class ActionStorePartyVehics(Action):
    """Stores the number of vehicles in a party in a slot"""

    def name(self):
        return "action_inform_partyVehics"

    def run(self, dispatcher, tracker, domain):

        intent = tracker.latest_message['intent'].get('name')
        partyVehics = next(tracker.get_latest_entity_values('number_vehic'), None)

        if not partyVehics:
            partyVehics = next(tracker.get_latest_entity_values('number'), None)


        if partyVehics:
            return [SlotSet('partyVehics', partyVehics)]
        elif intent in ["skip_please", "deny"]:
            return [SlotSet('partyVehics', "SKIPPED"), FollowupAction("action_skip_please")]
        else:
            return [SlotSet('partyVehics', tracker.latest_message.get('text'))]

Is the return statement in the action’s run() overwriting previously scheduled events? If so, how do I get around this and allow one multi-intent to call its respective component intents’ actions?

Related: Bug when returning multiple FollowupAction events in action

Thanks

Hi @argideritzalpea, this isn’t a bug, it’s intentional that there can only be one FollowUpAction(). Can I ask why you’re not handling this in your stories instead? That’s the recommended way, otherwise your tracker history might get confusing quickly

Hello! Is that doable that initialize a tracker object and trigger an custom action with trigger_followup_action() “out side” the action server?

The project I am working on initializes the agent(by loading the models) in an independent python program. Have to find out a way to trigger the intention/action directly in that program.