Run script based on value of variable x

How may I write the below properly? I will send a REST event to HA and would like to run a script and select the outcome based on the value of a variable passed on to it. BTW, I still have yet to figure out how to write the REST as well.

light_scene:
  sequence:
    data_template:
      entity_id: >-
        {% if variable x = blue %}
          trigger ifttt recipe b
        {% elif variable x = green %}
          trigger ifttt recipe c
        {% elif variable x = orange %}
          trigger ifttt recipe d
        {% elif variable x = purple %}
          trigger ifttt recipe e
        {% else %}
          script.noop
        {% endif %}

Paste this into the Template Editor and experiment with it:

        {% set x = 'orange' %}
        {% set values = {'blue':'trigger ifttt recipe b', 
                         'green':'trigger ifttt recipe c', 
                         'orange':'trigger ifttt recipe d', 
                         'purple':'trigger ifttt recipe e'} %}
        {{ values[x] if x in values.keys() else 'script.noop' }}

Thank you. Below is what I have so far for the script. The data template code works, except I’m not certain how I enter ({% set x = ‘blue’ %}) into the rest url/call it. Also, please help fill in the blanks, or make code changes.

light scene:
  sequence:
  - service: 
    data_template:
      {% set values = {
         'blue':'[{ "service": "ifttt.trigger", "data": { "event": "living_room_shelf_lamp_blue" }}]', 
         'green':'[{ "service": "ifttt.trigger", "data": { "event": "living_room_shelf_lamp_green" }}]', 
         'orange':'[{ "service": "ifttt.trigger", "data": { "event": "living_room_shelf_lamp_orange" }}]',
         'purple':'[{ "service": "ifttt.trigger", "data": { "event": "living_room_shelf_lamp_purple" }}]',
         'red':'[{ "service": "ifttt.trigger", "data": { "event": "living_room_shelf_lamp_red" }}]'} %}
       {{ values[x] if x in values.keys() else 'script.lights' }}

In the Template Editor. I’d be gobsmacked to learn that works where you intend to use it.

You can template the value that is assigned to an option. For example, here I’m assigning the desired service to the service_template option:

  - service_template: >
      light.turn_{{ trigger.to_state.state }}

What you can’t do is use templates to define options (like what your template is doing with service: and data: and event:).

Seeing what I’m attempting to accomplish here, how may my script be structured?

Edit: I discovered LIFX scenes can be called directly from within HA, such as…

- service: scene.turn_on
  entity_id: scene.goodnight

Not sure this changes the setup I would like. I would call the respective LIFX service instead of IFTTT.