Drawing a blank: can we invoke a service from a sensor template state

I just realized I’m not sure how to do that or if it’s even possible or if it’s a dumb question. I should know this… :man_facepalming:t2:
EDIT: I can think of a very roundabout way where I have an automation that populates a hidden input_xxx which is then read by the template sensor state but I def don’t want to do that.

Not really sure what the use case is, but a template sensor is just a sensor and you can make an automation react to that as with all sensors.

I think I figured it out, or at least partly.
Template sensors can have an action section as well!
So you can do something like

- trigger:
     ...
  action:
    - service: blah
       ...
      response_variable: response
  sensor:
    - unique_id: "..."
      ...
      state: >-
         {{ ...use the response somehow... }}