Reponding to myself for others facing similar same problem.
I used trigger.data.payload instead trigger.query.payload.
From what I’ve read and seen you cannot parse the json string to a json object by using the tosjon filter. You need to “parse” the json string by yourself doing splits and replaces until you get your desired data.
In my case:
{% set action = trigger.data.payload.split(",")[3].replace("]","").replace("}","").split(":")[1].replace("\"","").split("#") %}
{{ action[0] } # This is the service name
{% set action = trigger.data.payload.split(",")[3].replace("]","").replace("}","").split(":")[1].replace("\"","").split("#") %}
{{ action[1] }} # This is the entity_id
Also,
worth pointing out that the data which is sent via a post is available as trigger.data but the query strings are simply available using the objects.
For example, if you send this query string to your instance: curl -X POST https://myhomeassistantaddress.duckdns.org/api/webhook/beaver?message=oh%20yes
Then you can create an automation with a trigger which is a webhook with the ID of beaver and then get the results like this:
- id: '1603620844963'
alias: MS Flow - Announce Anything
description: Webhook which takes a string to say a phrase
trigger:
- platform: webhook
webhook_id: beaver
condition: []
action:
- service: notify.alexa_media_office_show
data_template:
data:
method: speak
type: announce
message: 'Message from MS Flow is {{ trigger.query.message }}'
title: 'Beaver came in '
Now you have an end point for an external system to send any announcement, if it knows the secret Webhook ID.