Getting data from webhooks message

Hi, I’m messing around with webhooks at the moment, trying something I thought would be simple :slight_smile: - it probably is, however, I’m probably more simple.

So, I’m getting a notification from MicroBadger when a docker image is updated and trying (for now) just to write the text of that notification as a persistent notification in HA.

For testing MicroBadger sends the following:

{ “text”:“Hi, it’s MicroBadger, sending you a test notification for marthoc/deconz ttps://microbadger.com/images/marthoc/deconz”,“new_tags”:,“image_name”:“marthoc/deconz”,“changed_tags”:,“deleted_tags”: }

I’m certainly getting something (via HAC) 'cos my automation is triggering.

- id: '1549193268012'
  alias: New Docker Image
  trigger:
  - platform: webhook
    webhook_id: microbadger_notify
  condition: []
  action:
  - data:
      message: '{{ trigger.json.text }}'
    service: persistent_notification.create

The info on nabucasa says “Form data or JSON data sent to the webhook endpoint will be available to templates in your automation as trigger.data or trigger.json

All that happens is I get a notification of ‘{{ trigger.json.text }}’ instead of the message text.

What am I missing?

thanks in advance …

In your action, you must use data_template whenever templates are used. See the docs for more info.

1 Like

Excellent, that works.

Thanks

Sorry to re-open an old post, but can someone please elaborate on how exactly to obtain the data from the ‘payload’ from a Webhook? I’ve looked at the documents and lots & lots of Google searches, and i’m not really understanding.

I’m using a system called Losant (www.losant.com) which allows me to set up an integration with Amazon Alexa. When I say a given trigger phrase, the Losant system runs a ‘workflow’. Part of that workflow is an ‘HTTP Request’ which basically allows a webhook call.

The webhook i’ve created is to a Home Assistant trigger. The trigger works. But what I want is to be able to pass one or more parameters from the Losant HTTP Request into Home Assistant.

I don’t quite understand if Losant is passing an entire ‘payload’ as a JSON or as a data form, or if I have to add parameters to the webhook URL. Whatever works is fine as all i want is to pass a single number value (which will be used to identify the TV channel I want my LG TV to change to).

How exactly do i access the parameters in Home Assistant? I’ve looked at the documents on ‘templates’ and i dont really understand what they are or do.

All i want, is to pass a single number (number or text) from Losant, into Home Assistant, but i’m not understanding how that works.

Came across your post. One way I looked at the payload for the webhook was to use https://webhook.site

You’d be provided with a custom webhook link that you would send your webhook payload to.
It would then be able to show the payload that was sent.

Nifty to figure out what was in the payload.

1 Like

Thanks for the suggestion. I did try using that webook site which was helpful only in reaching the conclusion that the data I was expecting to be there wasn’t. So I ended up abandoning that approach and instead used the age old method of concatenating strings to form a parameterized URL.