Rasa: RASA | Slots | How to reset Slots in between the conversation?

Created on 25 Dec 2018  Â·  8Comments  Â·  Source: RasaHQ/rasa

Rasa Core version:0.12.1

Python version: 3.6.5

Operating system (windows, osx, ...):Win7

Issue:I have created a weather bot. Here first time the location(Chico) assign to the stot properly and the result showing as expected.

As per the story the bot will ask to the user for the weather continuously.
So in same conversation, I asked the weather for another place(Irish Town), but the result is showing with previous Slot value (Chico). Please see the attached image to get more details about the issue.

Also please find the attached stories and Domain…

here my question is, how can I reset the slot value in between the conversation?

Thanks in Advance, EB

slot issue

bot_stories.txt

weather_domain.txt

Most helpful comment

Hi @EliBruce,

Try resetting the slot after

    - utter_any_other_query
* ans_yes

You can do this by making an action_reset_slot which simply fills the slot with None, i.e. it looks like:

class ResetSlot(Action):

    def name(self):
        return "action_reset_slot"

    def run(self, dispatcher, tracker, domain):
        return [SlotSet("Location", None)]

Lemme know if this solves the problem

All 8 comments

i am also facing same problem

Hi @EliBruce this is completely off topic, but did you connect your bot to the UI yourself? Do you have an open source example I could refer to? I am struggling to move my bot from cmdline using the RestInput. Would be very helpful!

Thanks.

Hi @EliBruce,

Try resetting the slot after

    - utter_any_other_query
* ans_yes

You can do this by making an action_reset_slot which simply fills the slot with None, i.e. it looks like:

class ResetSlot(Action):

    def name(self):
        return "action_reset_slot"

    def run(self, dispatcher, tracker, domain):
        return [SlotSet("Location", None)]

Lemme know if this solves the problem

This issue has been automatically closed because there has been no response to our request for more information from the original author. Without this, we don't have enough information to help you. Please comment below with the requested information if you still need help.

@MetcalfeTom your code work Properly, Thank you so much for give this solution.Its Work great.

Hi @MetcalfeTom

I tried your solution, but my code doesn't run because it doesn't recognize SlotSet. Any suggestions?

Hi @EliBruce

I found a simple solution for this. At the end of your stories, simply include the following

  • action_restart

This is a default action provided by Rasa that resets all the slots and restarts the conversation.

@NavdhaJindal did you import SlotSet?

from rasa_sdk.events import SlotSet
Was this page helpful?
0 / 5 - 0 ratings