Conditional attributes on data_template (IFTTT integration)

Hello,
I’ve searched the community for similar questions, I found, but with no real solutions to my problem… So here it goes:

I’ve set up the ifttt integration as described here https://www.home-assistant.io/integrations/ifttt/

The automation works perfectly on the .turn_on service.

However for the .set_value service, that requires a ‘value’ attribute, I need to add

data_template:
  entity_id: '{{ trigger.event.data.entity_id }}'
  value: '{{ trigger.event.data.value }}'
service_template: '{{ trigger.event.data.service }}'

By adding the ‘value’ attribute the .turn_on service will not work as it does not expect a value attribute.

I’ve tried:

data_template:
  entity_id: '{{ trigger.event.data.entity_id }}'
  {% if trigger.event.data.value %}
  value: '{{ trigger.event.data.value }}'
  {% else %}
service_template: '{{ trigger.event.data.service }}'

But it gives an error (Message malformed: required key not provided @ data[‘action’][0][‘delay’]
)

Any idea on how can I make the ‘value’ attribute conditional?