Conditional template vars

In my dialogs, I’m trying to tie back to previous parts of the conversation to make things feel more natural. In some cases, I can just refer to a slot in the template, but in other cases, I need to transform that slot value into something more human.

In concept, I want to do something like:

utter_blah:
  - text: That's the color of a forest.
      slot: {"color":"green"}
  - text: That is the color of a fire engine
      slot: {"color":"red"}

Since I don’t think anything like that is possible, I’m setting specific slots (e.g., “slot_utter_blah”) when I’m, say, setting the “color” slot and then I just have:

 utter_blah:
  - text: {slot_utter_blah}

But it’s kind of a drag to have to manage all that.

I guess the other approach is to have utter_blah_green and utter_blah_red and then create a bunch of stories with a featurized slot (“color”). But that seems like overkill for this common task.

Is there an idiomatic way to do this?

@mmm3bbb slots are designed to be used as placeholders in templates or as conditions in stories. Since your use case requires them to be used as conditions, you will have to go for creating a featurized slot approach.

Thanks @dakshvar22. In almost all cases, slot values are set/validated by code, so I can simply set the value of the “utter” slot there and that way I only have one utter template for all values (e.g., when I set/validate “color”, I then also set the value of slot_utter_blah). Otherwise, I have to create stories with all the variants of the utter slot value for every “conditional template” I have… and managing stories is already getting hard for me.

Yes, you could do that if the slot setting and templates are very straight forward.