Pass the value explicitly when calling the template

Hi,

I am trying to pass a value from custom action to a template’s variable. I got an error as " Failed to fill utterance template ‘value from custom action is {my_variable}’. Tried to replace ‘my_variable’ but could not find a value for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template."

action.py

class ActionCustom(Action):

  def name(self):

    return "utter_template"

  def run(self, dispatcher, tracker, domain):

  # send utter default template to user
      dispatcher.utter_template("utter_template", tracker, my_variable="hello world")
  # ... other code
     return []

NLU

intent:template

  • template
  • temp

stories

template

  • template
    • utter_template

and my domain

intents:

  • greet
  • template

templates: utter_template:

  • text: value from custom action is {my_variable}

actions:

  • utter_template
1 Like

Hello, Same problem for me. Please someone have an issue for this ?

number_of_guests=5 is_even=“even”

dispatcher.utter_template(“utter_even_noteven”, tracker, number_of_guests=nb_guest, even=is_even)

I also tried to method which is not deprecated :


dispatcher.utter_message(template=“utter_even_noteven”, number_of_guests=nb_guest, even=is_even)

text: ‘You will be {number_of_guests} in total and its {is_even}.’ There is my utter definition :

My bot print this : “You will be {number_of_guests} in total and its {even}.”

Looks like utter_template does not fill kwargs of utter_template method with var betweeen {} in the template.

Anyone have an idea ?

Thanks !

I am also facing the same issue. In my case, I’m picking a UserName from a DataFrame and want to display it in the utter_response, but it’s not working. I guess we have to define the custom action, but I don’t want to do that. Just for displaying some static value, why we need to create custom action.

Any help?