Question About Script Return Values

This is one of those things I never really dove deep into when it was released but as I systematically try to redo my system I wanted to learn and implement return values more.

My question is about the “response_variable”. Is it required that this is actually a variable or can it be templated? If I return one of the script variables it works fine, I get a result, but if I template the response variable I get an empty value:

    - stop:
      response_variable: >-
        {% set secure = true %}
        {% set message = "Hello World" %}

        {{
          {
            'secure': secure,
            'message': message
          }
        }}

However, this works fine (response is a script variable):

    - stop:
      response_variable: response

I’m thinking the answer to this is “no, you cannot template the response” but I thought I would just confirm.

I think you have to set it up as a variable first.

...
  - variables:
      data: |
        {% set secure = true %}
        {% set message = "Hello World" %}
        {{ { "secure": secure,
            "message": message } }}
  - stop: Respond with variable
    response_variable: data
1 Like

I have, and that works, I was wondering if you could just template it and it seem perhaps that’s not a current capability.