Put it in a script on its own, and call the script from your other scripts/automations. You can use a field to pass data.
For example, this creates a voice assistant response to the question “Where’s my phone/keys/watch?” The field is tts_sentence.
action:
- variables:
last_seen: "{{ device }}_last_seen"
- choose:
- conditions: "{{ states(device) in ('unavailable', 'unknown') }}"
sequence:
- action: script.tts_response
data:
tts_sentence: >-
{% if device == "sensor.keys_tag_area" %}
Last time I saw them, they were in the {{ states(last_seen) }}. I don't know where they are now.
{% else %}
Last time I saw it, it was in the {{ states(last_seen) }}. I don't know where it is now.
{% endif %}
- conditions: "{{ has_value(device) }}"
sequence:
- action: script.tts_response
data:
tts_sentence: >-
{% if device == "sensor.keys_tag_area" %}
They're in the {{ states(device) }}
{% else %}
It's in the {{ states(device) }}
{% endif %}