# How to prevent null value in utterance template?

**URL:** <https://forum.rasa.com/t/how-to-prevent-null-value-in-utterance-template/12823>\
**Category:** Rasa Open Source\
**Created:** [July 11, 2019, 4:12pm UTC](https://forum.rasa.com/t/how-to-prevent-null-value-in-utterance-template/12823 "2019-07-11T16:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![twittmin](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/twittmin/32/2091_2.png) [@twittmin](https://forum.rasa.com/u/twittmin)\
**Post date:** [July 11, 2019, 4:12pm UTC](https://forum.rasa.com/t/how-to-prevent-null-value-in-utterance-template/12823/1 "2019-07-11T16:12:57Z")

</div>

```
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.

---

<div class="post-metadata">

**Author:** ![sihsob](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sihsob](https://forum.rasa.com/u/sihsob)\
**Post date:** [July 11, 2019, 5:33pm UTC](https://forum.rasa.com/t/how-to-prevent-null-value-in-utterance-template/12823/2 "2019-07-11T17:33:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![twittmin](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/twittmin/32/2091_2.png) [@twittmin](https://forum.rasa.com/u/twittmin)\
**Post date:** [July 13, 2019, 1:58am UTC](https://forum.rasa.com/t/how-to-prevent-null-value-in-utterance-template/12823/3 "2019-07-13T01:58:32Z")

</div>

That’s true, thanks @sihsob
