Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slots not resetting with action_deactivation_loop #8079

Closed
travelmail26 opened this issue Mar 1, 2021 · 6 comments
Closed

Slots not resetting with action_deactivation_loop #8079

travelmail26 opened this issue Mar 1, 2021 · 6 comments
Assignees
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/training-data Issues focused around Rasa training data (stories, NLU, domain, etc.) effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@travelmail26
Copy link

Rasa version:
Rasa Version : 2.2.9
Rasa SDK Version : 2.2.0
Rasa X Version : None
Python Version : 3.8.1
Operating System : macOS-10.14.6-x86_64-i386-64bit

Issue:
Slots are not resetting after form de-activation is called. I was told to create a ticket in this forum thread

Stories solution:

  • story: User stops health_form
    steps:
    • active_loop: health_form
    • intent: flush_slots
    • action: action_flush_slots
    • action: utter_start_over
    • action: utter_greet
    • action: action_deactivate_loop
    • active_loop: null

description
Because action_deactivation_loop dosen't reset the slots, I added a custom action with the trigger

class ActionFlushSlots(Action):
    
    def name(self) -> Text:
        return "action_flush_slots"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        slots = []
        for key, value in tracker.current_slot_values().items():
            if value is not None:
                slots.append(SlotSet(key=key, value=None))

        return slots
@travelmail26 travelmail26 added area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. labels Mar 1, 2021
@sara-tagger
Copy link
Collaborator

Thanks for the issue, @ArjaanBuijk will get back to you about it soon!

You may find help in the docs and the forum, too 🤗

@TyDunn TyDunn added the area:rasa-oss/training-data Issues focused around Rasa training data (stories, NLU, domain, etc.) label Apr 16, 2021
@joejuzl joejuzl added the effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. label Apr 16, 2021
@wochinge
Copy link
Contributor

@travelmail26 What's the complete stack trace?
And what are you trying to do when?

@ancalita
Copy link
Member

ancalita commented May 7, 2021

Hi @travelmail26 In absence of the complete stack trace, I've replicated the InvalidRule behaviour you described in the forum post - this I gathered is owed to the fact that action_deactivate_loop was placed outside of an active form because the health form was already deactivated via active_loop: null in the example you provided in the forum post:

- rule: Submit form
  condition:
    # Condition that form is active.
    - active_loop: health_form
  steps:
  - action: health_form
  - active_loop: null
    # The action we want to run when the form is submitted.
  - action: action_submit_results
  - action: utter_slots_values
  - action: action_deactivate_loop
  - active_loop: null

I also agree with @wochinge that the correct way currently to reset the slots is via custom action because action_deactivate_loop has the same function as active_loop: null to inactivate/ exit the form and is best used to handle unhappy form paths.

The solution I see here is for us to update docs so that it's clear what's the recommended route for resetting slots using AllSlotsResetevent returned by a custom action after form submission. Would that work?

@shaqing
Copy link

shaqing commented May 7, 2021

in order to use function"SLotSet()",which lib should i import?

@ancalita
Copy link
Member

ancalita commented May 7, 2021

in order to use function"SLotSet()",which lib should i import?

SlotSet is not a function, is an object. You can import SlotSet in your actions.py like so:
from rasa_sdk.events import SlotSet
More information is available here.

@ancalita
Copy link
Member

The docs were updated as part of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/training-data Issues focused around Rasa training data (stories, NLU, domain, etc.) effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

7 participants