Intent_scripts with if-statements

See my next post below. There were some errors in this text.

There are not many examples of inteny_scripts. Apparently there are only few people who use Rhasspy.
I just can’t get it done. But maybe it can’t be done this way at all.
I want to be able to ask Rhasspy what time the next train goes in a certain direction. Now there is an easy solution for that, which I have also worked out by writing a separate intent for each direction.
But I would like to do it in a more elegant and generic way. Also because I want to make other more complicated intents.

I added this sentence to Rhasspy:

[GetTrain]
      How late leaves the train to ( berlin | hamburg){direction}

This is the intent_script I created for Hassio (which doesn’t work)
Does anyone know how to do it?

GetTrain: 
     speech:
       text: This is a test
     action:
       service: persistent_notification.create
       data_template: >-
         {% if is_state('direction') , 'hamburg' %}
          message: The train leaves at {{states('sensor.hamburg')}} to Hamburg
         {% else is_state('direction') , 'berlin' %}}
            message: The train leaves at {{states('sensor.berlin')}} to Berlin
         {% endif %}