Trigger based template sensor to store global variables

@TheFes Thanks for this, I thought it would solve my scripting issue. I have concurrent automations needing to stash some text for another related automation. I therefore wanted the keys to be dynamic, however when I tried using this with dynamic variable names I found that it didn’t pass validation on startup.

Errors such as:

value should be a string for dictionary value @ data['actions'][0]['parallel'][0][0]['sequence'][3]['action']. Got None

and

invalid key: "{'review_id': None}"

Example:

variables:
  review_id: "{{ trigger.payload_json['after']['id'] }}"
actions:
  - event: set_variable
    event_data:
      key: {{ review_id }}
      value: "{{ wait.trigger.payload_json['description'] }}"
      set_timestamp: false

I tried single and double quoting the expression.
Does anyone know another way?

Thanks