Action_deactivate_form not working

I want to work out below story

> * greet
>     - utter_greet
> * fund_transfer
>     - bank_form
>     - form{"name": "bank_form"}
> * stop
>     - utter_ask_continue 
> * deny
>     - action_deactivate_form 
>     - form{"name": null}  

Everything works fine till utter_ask_continue (do you want to continue last action) action. When user say “No” (deny) in response to above , bot does not deactivate the form. Infact it predicts bank_form using FormPolicy.

This is strange. Do you have any other stories that might be conflicting with this one? Can you post the full debug log?

Your input -> hi 2019-06-14 20:15:48 DEBUG rasa_core.tracker_store - Creating a new tracker for id ‘default’. 2019-06-14 20:15:48 DEBUG rasa_core.processor - Received user message ‘hi’ with intent ‘{‘name’: ‘greet’, ‘confidence’: 0.9535133242607117}’ and entities ‘[]’ 2019-06-14 20:15:48 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 2 events 2019-06-14 20:15:48 DEBUG rasa_core.processor - Current slot values: account_details: None account_type: None amount: None authorized_user: None beneficiary: None closing_balance: None customer_id: None date: None opening_balance: None requested_slot: None user_acc_id: None user_beneficiary_id: None user_details: None 2019-06-14 20:15:48 DEBUG rasa_core.policies.memoization - Current tracker state [None, None, None, {}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}] 2019-06-14 20:15:48 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘8’ 2019-06-14 20:15:48 DEBUG rasa_core.policies.form_policy - There is no active form 2019-06-14 20:15:48 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_MemoizationPolicy 2019-06-14 20:15:48 DEBUG rasa_core.processor - Predicted next action ‘utter_greet’ with prob 1.00. 2019-06-14 20:15:48 DEBUG Hi! I am your banking bot. How can I help you? rasa_core.processor - Action ‘utter_greet’ ended with events ‘[]’ 2019-06-14 20:15:48 DEBUG rasa_core.processor - Bot utterance ‘BotUttered(text: Hi! I am your banking bot. How can I help you?, data: { “elements”: null, “buttons”: null, “attachment”: null })’ 2019-06-14 20:15:48 DEBUG rasa_core.policies.memoization - Current tracker state [None, None, {}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}] 2019-06-14 20:15:48 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘15’ 2019-06-14 20:15:48 DEBUG rasa_core.policies.form_policy - There is no active form 2019-06-14 20:15:48 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_MemoizationPolicy 2019-06-14 20:15:48 DEBUG rasa_core.processor - Predicted next action ‘action_login’ with prob 1.00. 2019-06-14 20:15:48 DEBUG rasa_core.actions.action - Calling action endpoint to run action ‘action_login’. 2019-06-14 20:15:55 DEBUG rasa_core.processor - Action ‘action_login’ ended with events ‘[“SlotSet(key: user_details, value: {‘BankName’: ‘BANK’, ‘CustId’: 123, ‘Email’: ‘ABC@abc.com’, ‘Name’: ‘ABC’, ‘Password’: ‘abc@1234’, ‘UID’: 2})”]’ 2019-06-14 20:15:55 DEBUG rasa_core.policies.memoization - Current tracker state [None, {}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}, {‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}] 2019-06-14 20:15:55 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘0’ 2019-06-14 20:15:55 DEBUG rasa_core.policies.form_policy - There is no active form 2019-06-14 20:15:55 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_MemoizationPolicy 2019-06-14 20:15:55 DEBUG rasa_core.processor - Predicted next action ‘action_listen’ with prob 1.00. 2019-06-14 20:15:55 DEBUG rasa_core.processor - Action ‘action_listen’ ended with events ‘[]’ 127.0.0.1 - - [2019-06-14 20:15:55] “POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1” 200 214 7.585275 Your input -> fund transfer 2019-06-14 20:16:01 DEBUG rasa_core.tracker_store - Recreating tracker for id ‘default’ 2019-06-14 20:16:01 DEBUG rasa_core.processor - Received user message ‘fund transfer’ with intent ‘{‘name’: ‘fund_transfer’, ‘confidence’: 0.9754638075828552}’ and entities ‘[]’ 2019-06-14 20:16:01 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 8 events 2019-06-14 20:16:01 DEBUG rasa_core.processor - Current slot values: account_details: None account_type: None amount: None authorized_user: None beneficiary: None closing_balance: None customer_id: None date: None opening_balance: None requested_slot: None user_acc_id: None user_beneficiary_id: None user_details: {‘BankName’: ‘BANK’, ‘CustId’: 123, ‘Email’: ‘ABC@abc.com’, ‘Name’: ‘ABC’, ‘Password’: ‘abc@1234’, ‘UID’: 2} 2019-06-14 20:16:01 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}, {‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘prev_action_listen’: 1.0}] 2019-06-14 20:16:01 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘23’ 2019-06-14 20:16:01 DEBUG rasa_core.policies.form_policy - There is no active form 2019-06-14 20:16:01 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_MemoizationPolicy 2019-06-14 20:16:01 DEBUG rasa_core.processor - Predicted next action ‘bank_form’ with prob 1.00. 2019-06-14 20:16:01 DEBUG rasa_core.actions.action - Calling action endpoint to run action ‘bank_form’. 2019-06-14 20:16:02 Validation failedDEBUG Enter customer_idrasa_core.processor

  • Action ‘bank_form’ ended with events ‘[‘Form(bank_form)’, ‘SlotSet(key: requested_slot, value: customer_id)’]’ 2019-06-14 20:16:02 DEBUG rasa_core.processor - Bot utterance ‘BotUttered(text: Validation failed, data: { “elements”: null, “buttons”: null, “attachment”: null })’ 2019-06-14 20:16:02 DEBUG rasa_core.processor - Bot utterance ‘BotUttered(text: Enter customer_id, data: { “elements”: null, “buttons”: null, “attachment”: null })’ 2019-06-14 20:16:02 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}, {‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘prev_action_listen’: 1.0}] 2019-06-14 20:16:02 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘23’ 2019-06-14 20:16:02 DEBUG rasa_core.policies.form_policy - There is an active form ‘bank_form’ 2019-06-14 20:16:02 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_3_FormPolicy 2019-06-14 20:16:02 DEBUG rasa_core.processor - Predicted next action ‘action_listen’ with prob 1.00. 2019-06-14 20:16:02 DEBUG rasa_core.processor - Action ‘action_listen’ ended with events ‘[]’ 127.0.0.1 - - [2019-06-14 20:16:02] “POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1” 200 248 1.131638 Your input -> stop 2019-06-14 20:16:13 DEBUG rasa_core.tracker_store - Recreating tracker for id ‘default’ 2019-06-14 20:16:13 DEBUG rasa_core.processor - Received user message ‘stop’ with intent ‘{‘name’: ‘stop’, ‘confidence’: 0.9798009395599365}’ and entities ‘[]’ 2019-06-14 20:16:13 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 15 events 2019-06-14 20:16:13 DEBUG rasa_core.processor - Current slot values: account_details: None account_type: None amount: None authorized_user: None beneficiary: None closing_balance: None customer_id: None date: None opening_balance: None requested_slot: customer_id user_acc_id: None user_beneficiary_id: None user_details: {‘BankName’: ‘BANK’, ‘CustId’: 123, ‘Email’: ‘ABC@abc.com’, ‘Name’: ‘ABC’, ‘Password’: ‘abc@1234’, ‘UID’: 2} 2019-06-14 20:16:13 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {‘prev_action_listen’: 1.0, ‘intent_greet’: 1.0}, {‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}, {‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘prev_action_listen’: 1.0}] 2019-06-14 20:16:13 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘23’ 2019-06-14 20:16:13 DEBUG rasa_core.policies.form_policy - There is an active form ‘bank_form’ 2019-06-14 20:16:13 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_3_FormPolicy 2019-06-14 20:16:13 DEBUG rasa_core.processor - Predicted next action ‘bank_form’ with prob 1.00. 2019-06-14 20:16:13 DEBUG rasa_core.actions.action - Calling action endpoint to run action ‘bank_form’. 2019-06-14 20:16:14 DEBUG rasa_core.actions.action - Failed to validate slot customer_id with action bank_form 2019-06-14 20:16:14 DEBUG rasa_core.policies.memoization - Current tracker state [{‘prev_utter_greet’: 1.0, ‘intent_greet’: 1.0}, {‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘prev_action_listen’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘active_form_bank_form’: 1.0, ‘prev_bank_form’: 1.0}, {‘active_form_bank_form’: 1.0, ‘prev_action_listen’: 1.0, ‘intent_stop’: 1.0}] 2019-06-14 20:16:14 DEBUG rasa_core.policies.memoization - There is no memorised next action 2019-06-14 20:16:14 DEBUG rasa_core.policies.form_policy - There is an active form ‘bank_form’ 2019-06-14 20:16:14 DEBUG rasa_core.policies.form_policy - There is a memorized tracker state [{‘prev_bank_form’: 1.0}, {‘active_form_bank_form’: 1.0, ‘prev_action_listen’: 1.0, ‘intent_stop’: 1.0}], added FormValidation(False) event 2019-06-14 20:16:14 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_0_KerasPolicy 2019-06-14 20:16:14 DEBUG rasa_core.processor - Predicted next action ‘utter_ask_continue’ with prob 0.58. 2019-06-14 20:16:14 DEBUG Do you want to continue? rasa_core.processor - Action ‘utter_ask_continue’ ended with events ‘[]’ 2019-06-14 20:16:14 DEBUG rasa_core.processor - Bot utterance ‘BotUttered(text: Do you want to continue?, data: { “elements”: null, “buttons”: null, “attachment”: null })’ 2019-06-14 20:16:14 DEBUG rasa_core.policies.memoization - Current tracker state [{‘intent_greet’: 1.0, ‘prev_action_login’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘prev_action_listen’: 1.0}, {‘intent_fund_transfer’: 1.0, ‘active_form_bank_form’: 1.0, ‘prev_bank_form’: 1.0}, {‘active_form_bank_form’: 1.0, ‘prev_action_listen’: 1.0, ‘intent_stop’: 1.0}, {‘active_form_bank_form’: 1.0, ‘intent_stop’: 1.0, ‘prev_utter_ask_continue’: 1.0}] 2019-06-14 20:16:14 DEBUG rasa_core.policies.memoization - There is a memorised next action ‘0’ 2019-06-14 20:16:14 DEBUG rasa_core.policies.form_policy - There is an active form ‘bank_form’ 2019-06-14 20:16:14 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_MemoizationPolicy 2019-06-14 20:16:14 DEBUG rasa_core.processor - Predicted next action ‘action_listen’ with prob 1.00. 2019-06-14 20:16:14 DEBUG rasa_core.processor - Action ‘action_listen’ ended with events ‘[]’ 127.0.0.1 - - [2019-06-14 20:16:14] “POST /webhooks/rest/webhook?stream=true&token= HTTP/1.1” 200 192 1.160284 Your input -> no

Kindly review the line where the log says

Predicted next action ‘bank_form’ with prob 1.00.

I will try to make keras policy little more deep(layer). Might be that could help.

Have you managed to resolve the issue ? I have a similar problem , Keras is predicting the form even it has been disabled and is not following the story.

I added one more layer of LSTM (i.e. stacked LSTM ) in keras policy. It somewhat solved the issue for me.

How have you done this, i have the same problem but have not found out how to configure this.

If you use self.from_text() in actions.py, you should write like this: “email”: self.from_text(not_intent = “deny”). If so, when the intent “deny” is detected, it will not be taken as a form object and stop the form. Let me know if this works!

1 Like

did you resolve this issue?. can you please share solution to resolve this. in my case, deny is detected but action_deactivate_form is not called. instead it is predicting previous entity.

Thank you so much. It resolved my problem of deactivating form when a session is restarted. :slight_smile:

please try restarting the whole session!

Thanks @minnie for your reply and sorry for delay. i used not_intent=“deny” and now deny intent is detected.but now i am getting message as Failed to extract slot. in stories.md > deny, i have action_deactivate_form but don’t know if it is called.

I think I can help with that if you show me some screenshots or samples you used in your form.

I’m experiencing the same behavior. If a user triggers the cancel intent before the form is completed then i get proper text uttered back but the action server throws the error: Failed to extract slot new_project_name with action create_project_form

Any help is much appreciated!! File snippets below.

stories.md

## create project happy
* create_project
  - utter_get_project
  - create_project_form
  - form{"name": "create_project_form"}
  - form{"name": null}

## create project cancelled
* create_project
  - utter_get_project
  - create_project_form
  - form{"name": "create_project_form"}
* cancel
  - utter_cancel
  - action_deactivate_form
  - form{"name": null}

CreateProjectForm.py

class CreateProjectForm(FormAction):
    """Form for creating a new project"""
    def __init__(self):
        self.db = DatabaseClient()
        self.teams = Teams()

    def name(self) -> Text:
        """Unique identifier of the form"""

        return "create_project_form"

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""

        return ["new_project_name"]

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        """A dictionary to map required slots to
            - an extracted entity
            - intent: value pairs
            - a whole message
            or a list of them, where a first match will be picked"""
        return {
            "new_project_name": self.from_text(not_intent=['cancel'])
        }

    def current_projects(self, id: Text) -> List[Text]:
        """Current user projects"""
        return self.db.getProjects(id)

    def validate_new_project_name(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        """Validate project name"""
        # value = tracker.latest_message['text'].strip()
        person_id = tracker.sender_id if tracker.get_latest_input_channel() != "webexteams" else 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS82YWNiMWJiOS1iYjYzLTRmOTktYTQxMC1mMDZiYjU1MjMzYTE'
        if not value:
            dispatcher.utter_message(json_message=dict(
                markdown=elicit_project_name
            ))
            return {"new_project_name": None}
        elif value.lower() in [ project.lower() for project in self.current_projects(person_id) ]:
            dispatcher.utter_message(json_message=dict(
                markdown=project_name_in_use
            ))
            return {"new_project_name": None}
        else:
            return {"new_project_name": value}

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        """Define what the form has to do
            after all required slots are filled"""
        success = self.db.addProject(tracker.get_slot('current_user_personid'), project_name=tracker.get_slot("new_project_name"))
        if success:
            dispatcher.utter_message(json_message=dict(
                markdown=self.teams.renderMarkdown(
                    message=add_project_successful,
                    extra_vars=dict(
                        project_name=tracker.get_slot("new_project_name")
                    )
                )
            ))
            return [
                SlotSet("current_project", tracker.get_slot("new_project_name")),
                SlotSet("new_project_name", None)
            ]
        else:
            dispatcher.utter_message(json_message=dict(
                markdown=self.teams.renderMarkdown(
                    message=add_project_error                    
                )
            ))
            return [
                SlotSet("current_project", None),
                SlotSet("new_project_name", None)
            ]

bump

How did you do it? Can you post the code block

Would also appreciate if someone has an answer to this.

1.To deactivate a form you can fill all the slots with a invalid value like AZBNJGHJB2323JNKK like this otherwise you can use the secrets library to generate unque IDs and use that ID as a INVALID value. In submit method you can check If value is INVALID ,If it is invalid then you can just return empty list or do some followup events. And the form get deactivated. 2. Second way self.deactivate() which doesn’t worked for me.

In slot mapping, you have add something like: self.from_text(not_intent = “deny”) so that when a deny intent is detected it executes self.deactivate(). Hope that helps.