Setting up IFTT webhooks

So I’m trying to get webhooks working to get information to Home assistant from IFTTT
I got the webhook deliverying data to the server but I can’t seem to get it to parse the data correcly.

I used the template provided at https://www.home-assistant.io/integrations/ifttt/ to create my webhook and Automation.
IFTTT Webhook

URL: https://MYDOMAIN.duckdns.org/api/webhook/LONG-API-TOKEN
Method: POST
Content type: Application/Json
Body: { “action”: “call_service”, “service”: “script.turn_on”, “entity_id”: “script.1579661587176” }

I pasted the following into the /config/automations.yaml (not sure this is where this is even suppose to go but it’s the only place I wasn’t getting a syntax error from the file editor)

- id: '1579661379561'
  alias: Webhooks
  trigger:
  - event_data:
      action: call_service
    event_type: ifttt_webhook_received
    platform: event
  condition: []
  action:
  - data_template:
    entity_id: '{{ trigger.event.data.entity_id }}'
    service_template: '{{ trigger.event.data.service }}'

When I could not get the above to work I tried creating the automation through the UI but couldn’t get all the syntax correct. I instead created a very simple automation that ignored all Body data from the post and just looked for a webhook received.

I was able to trigger the script with the following automation, but as you can see it ignores all data passed in body so any webhook will trigger the script which is not desired behavior but does it confirm that the server is receiving the post from the webhook and the issue is likely in the syntax/setup of my automation. Any guidance would be helpful.

- id: '1589415747273'
  alias: Test Webhooks
  description: ''
  trigger:
  - event_data: {}
    event_type: ifttt_webhook_received
    platform: event
  condition: []
  action:
  - data: {}
    service: script.1579661587176

You have the indentation a little wrong. Try:

- id: '1579661379561'
  alias: Webhooks
  trigger:
  - event_data:
      action: call_service
    event_type: ifttt_webhook_received
    platform: event
  condition: []
  action:
  - data_template:
      entity_id: '{{ trigger.event.data.entity_id }}'
    service_template: '{{ trigger.event.data.service }}'

Oh wow. :man_facepalming: Well that did it. I guess I was close at least. This kind ot stuff is probably why I did not get into programming.

Thanks for your help.

1 Like