How to prevent null value in utterance template?

(mcm) #1
templates:
  utter_greet:
  - text: "Hey, {name}. How are you?"

For this example, or the following user supplied variables:

dispatcher.utter_template("utter_default", tracker, my_variable="my text")

If the variable is None, the utterance will contains a ‘None’ value, which is bad. How to prevent this and make sure that only when the template variable is not None, then its value will be filled; otherwise, it shouldn’t, since a “None” doesn’t look good in the output.

(sihsob) #2

I assume you’re dispatching it from a custom action? If so, you could just check before if the variable is None and either set it to whatever default value you want or return a different message.

(mcm) #3

That’s true, thanks @sihsob