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
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:
from rasa_sdk import Action
from rasa_sdk.events import Restarted
def run(self, dispatcher, tracker, domain):
# Your action logic here
# Reset the tracker
# Return Restarted event to clear the conversation state
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.