Clearing all the context in RASA

Hello, I have bulit a customer support chat bot to resolve a particular issue. I noticed a strange problem-

All my stories gets correctly evaluated when I start the rasa shell and my intents mapping happen to proper custom actions… All Good.

Now in the same RASA Shell, I repeat the same story and this time the results are all messed up and it can not even detect the intents correctly. I have to restart my rasa shell every time I have to execute a new story.

This tells me that there is some tracker status and after the end of a conversation, there has to be a way to clear to start a new conversation. What is the issue here? How do I use the same RASA shell to execute multiple discrete stories. Is there something that I need to do programmatically to clear the conversation context for a fresh start ? Please guide

Are you using featurized slots - influence_conversation: true (this is the default for slots)?

I am not sure if you followed my question. Or I failed to understand the recommendation.

All I wanted to know is a programmatic way to clear the entire conversation state in RASA so that it does not conflict with the next conversation story

The issue you’re facing with Rasa Shell can be resolved by resetting the conversation state between each story execution. The conversation state is stored in the tracker, and you can clear it programmatically to start a new conversation with a fresh context.

To clear the conversation state in Rasa Shell, you can use the /restart command. Simply enter /restart in the Rasa Shell, and it will reset the conversation and clear the tracker. This allows you to start a new conversation without any carry-over from the previous one.

Alternatively, if you want to clear the conversation state programmatically within your chatbot code, you can use the tracker.reset() method. This method resets the tracker, clears all stored events, and starts a fresh conversation. You can call this method at the beginning of each story execution to ensure a clean context.

Here’s an example of how you can use tracker.reset() in your custom actions:

Code : from rasa_sdk import Action from import Restarted

class YourCustomAction(Action): def name(self): return “your_custom_action_name”

def run(self, dispatcher, tracker, domain):
    # Your action logic here

    # Reset the tracker

    # Return Restarted event to clear the conversation state
    return [Restarted()]

By calling tracker.reset() and returning the Restarted() event, you can ensure that the conversation state is cleared and ready for a new conversation.

Remember to include the Restarted() event in your domain file under the events section.

With these approaches, you should be able to execute multiple discrete stories in the same Rasa Shell without any interference or carry-over from previous conversations.

Thanks a lot for the detailed response.


I just happen to see after executing that there are no method like reset() under tracker

AttributeError: ‘Tracker’ object has no attribute ‘reset’

Is this part of any new RASA version?