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 []
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 []
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.