Using dispatcher utter_template ended with exception

rasa-core

(Leonardo C.) #1

Hello everyone, I’m having an exception while executing dispatcher.utter_template(“utter_ack_eventdate”, tracker) from a custom action. This is what I get:

  File "/rasa_core/trackers.py", line 305, in update
    raise ValueError("event to log must be an instance "
ValueError: event to log must be an instance of a subclass of Event.

This is my utter template in the domain file:

utter_ack_eventdate: - text: “The event {event} will be on {date}”

This is my action method:

def run(self, dispatcher, tracker, domain):
    match = tracker.get_slot("date")
    matches = tracker.get_slot("matching_events")

    if match:
        dispatcher.utter_template("utter_ack_eventdate", tracker)
 
    elif matches:
        suggestions = [{'title': event, 'payload': "/query_event{\"event\": \"%s\""} for event in matches]
        dispatcher.utter_button_message("  ",suggestions)

    return []

Any idea?


(Akela Drissner) #2

Can you post the full error trace?


(Leonardo C.) #3

Here it is:

when is the enrollment?

C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\sklearn\preprocessing\label.py:151: DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use array.size > 0 to check that an array is not empty.

  if diff:
2018-08-29 15:16:20 ERROR    rasa_core.processor  - Encountered an exception while running action 'action_suggest'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2018-08-29 15:16:20 ERROR    rasa_core.processor  - event to log must be an instance of a subclass of Event.
Traceback (most recent call last):
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\processor.py", line 302, in _run_action
    events = action.run(dispatcher, tracker, self.domain)
  File "C:\Users\Leonardo\Documents\GitHub\starter-pack\actions.py", line 69, in run
    dispatcher.utter_template("utter_suggestions", tracker)
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\dispatcher.py", line 122, in utter_template
    message = self.retrieve_template(template, filled_slots, **kwargs)
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\dispatcher.py", line 157, in retrieve_template
    return self._fill_template_text(r, filled_slots, **kwargs)
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\dispatcher.py", line 136, in _fill_template_text
    template_vars = self._template_variables(filled_slots, kwargs)
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\dispatcher.py", line 132, in _template_variables
    template_vars.update(kwargs.items())
  File "C:\Users\Leonardo\Anaconda3\envs\BotProject\lib\site-packages\rasa_core\trackers.py", line 305, in update
    raise ValueError("event to log must be an instance "
ValueError: event to log must be an instance of a subclass of Event.

I edited my custom action to fill the template variables but it is the same even with no-variables templates.

    def run(self, dispatcher, tracker, domain):
    match = tracker.get_slot("date")
    matches = tracker.get_slot("matching_events")

    if match:
        dispatcher.utter_template("utter_ack_eventdate", tracker, event=tracker.get_slot('event'), 
        date=match)
        
    elif matches:
        dispatcher.utter_template("utter_suggestions", tracker)
        suggestions = [{'title': event, 'payload': "/query_event{\"event\": \"%s\""} for event in matches]
        dispatcher.utter_button_message("Quizás quisiste decir: ", suggestions)

    return []

(Akela Drissner) #4

Can you post your domain file please? Also which Core version are you using?


(Leonardo C.) #5

My rasa core version is 0.9.7

intents:

  • greet
  • thank
  • bye
  • deny
  • affirm
  • informar
  • pedir_info
  • ofrecer_info
  • query_date
  • query_event
  • query_process
  • sorry

entities:

  • event
  • date

slots:

event:

type: unfeaturized

date:

type: unfeaturized

matching_events:

type: list

username:

type: unfeaturized
initial_value: "human"

templates:

utter_greet:

  • text: “Hello {username}! I’m the register’s Bot, Tell me something you want to know.”

utter_thank: - “You’re Welcome!”

utter_bye:

  • text: “Adios {username}.”
  • text: “¡Bye-bye {username}!”
  • text: “¡Hasta luego {username}!”
  • text: “Hasta pronto, gracias por tu visita {username}!”

utter_sorry:

  • text: “Lo siento pero por el momento no puedo ayudarte.”

utter_date:

  • “You have one incoming event: Prematricula”

utter_did_that_help:

  • text: “¿Te sirvió de ayuda mi respuesta?”

utter_happy:

  • text: “Great!”
  • text: “Me alegra escuchar eso!”

utter_goodbye:

  • text: “Bye”
  • text: “Hasta luego!”
  • text: “Adios!”

utter_ack_eventdate:

  • text: “The {event} will be on {date}”

utter_ask_username:

  • text: “¿Hola, para conocernos mejor, Cuál es tu nombre?”

utter_another_question:

  • text: “Tienes otra pregunta {username}?”
  • text: “Necesitas saber algo mas {username}?”

utter_suggestions:

  • text: “Creo que no entendí bien, quisiste decir:”
  • text: “Por favor podrías ser mas especifico? intenta con:”

utter_default:

  • text: “Lo siento, no entendí tu pregunta, intenta con otra”

actions:

  • utter_greet
  • utter_thank
  • utter_bye
  • utter_sorry
  • utter_date
  • utter_did_that_help
  • utter_happy
  • utter_ack_eventdate
  • utter_goodbye
  • utter_another_question
  • utter_ask_username
  • utter_default
  • utter_suggestions
  • actions.ActionShowEventResults
  • actions.ActionlookforEvent

(Akela Drissner) #6

Could you upgrade to a newer version, e.g. 0.10.4 or 0.11.2 to see if this issue persists?


(Leonardo C.) #7

I have upgraded to 0.11 and this resolved the issue. The utter_template() I was using is the one from the 0.10 version which is required to have the tracker as a second argument.

Thank you for helping!