0

Hi I'm trying to set some message to be uttered when the user restart the conversation. I have asked in Rasa Forum and tried to change the code. But it returned this error

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

This is the code that I wrote:

class ActionRestarted(Action):
""" This is for restarting the chat"""

def name(self) -> Text:
    return "action_restart"

async def run(
        self,
        tracker: Tracker,
        dispatcher: CollectingDispatcher,
        domain: Dict[Text, Any],) -> List[Event]:
    from rasa.core.events import Restarted

    # only utter the template if it is available
    evts = await super().run(tracker, domain, dispatcher.utter_message("Restarted"))
    return evts + [Restarted()]

Feel free to point out my mistake and correct them thank you

1 Answers1

1

You are trying to pass the return value of utter_message as the dispatcher parameter of super.run(), where it expects a CollectingDispatcher object.

You can just call utter_message from your run method.

async def run(
        self,
        tracker: Tracker,
        dispatcher: CollectingDispatcher,
        domain: Dict[Text, Any],) -> List[Event]:
    from rasa.core.events import Restarted

    dispatcher.utter_message("Restarted")
    return [Restarted()]
Visvamba Nathan
  • 135
  • 1
  • 6
  • Hi I have tried your solution but it gave me this error *File "C:\EDARAN_FAQ_CHATBOT\actions.py", line 82, in run dispatcher.utter_message("Restarted") AttributeError: 'Tracker' object has no attribute 'utter_message'* – Muhamad Asyraf Othman Sep 07 '20 at 08:37
  • Tracker doesnt have a `utter_message` but the dispatcher has. your code most likely has a typo. – Thusitha Sep 14 '20 at 08:54