TypeError: Object of type UserUtteranceReverted is not JSON serializable

Hi I am having following error when creating a custom action in which I want to incorporate UserUtteranceReverted. My actions.py file looks like this

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
from rasa_core.events import UserUtteranceReverted

class ActionCheckingSlotsADD(Action):
    def name(self):
        return "action_checkingslots_add"

    def run(self, dispatcher, tracker, domain):
        a_action = tracker.get_slot('action')
        date = tracker.get_slot('date')
        duration = tracker.get_slot('duration') 
        if a_action is None:
            dispatcher.utter_message("""Sadly I could not unterstand the action you were trying to initiate. 
                Could you please rephrase your request. 
                Example I want to activate data roaming 
                on the 5th of August 2018 for a duration of 8 days""")
            return [UserUtteranceReverted()]
        if date is None:
            dispatcher.utter_message("""Sadly I could not understand the entered date. 
                Please retry your request with a valid date. 
                Example DD.MM.YYYY or 5th of August 2018""")
            return [UserUtteranceReverted()]	
        if duration is None:
            dispatcher.utter_message("""Sadly I could not find a valid duration. 
                Could you please retry your request with a valid duration. 
                Example 5 days or 4 weeks etc.""")
            return [UserUtteranceReverted()]
        else: 
	    dispatcher.utter_template("utter_action_date_duration", tracker, action=a_action, date=date, duration=duration)
            return[]

. TypeError: Object of type UserUtteranceReverted is not JSON serializable Thank you!

1 Like

import all events fromrasa_core_sdk:

from rasa_core_sdk.events import UserUtteranceReverted
4 Likes

Thank you so much. That resolved everything