Webhook Response Topic

I have a problem just like described in this post, but it doesn't look like a solution was ever reached. It's been a few years so I thought I'd try again.
I have several devices which all use a webhook which accepts a variable location from the publish event. I'd like to return this data with a custom hook response that looks like hook-response/location so that any device set to that region can get the data, and the other devices can ignore it. However, I don't want to use the device ID here since any other devices would ignore it even if set to the same region. Is there a convienient way to pass the provided location back into the hook response?

Hi and welcome to the community!

It sounds like this can help you:

Cheers

Thank you for the suggestion. This looks very promising, but I don't see an example in the docs on how to use Logic Beta to change a webhook response. Do you know of an example that might steer me in the right direction?

The hook response topic is just an event name, so the normal rules apply: it's a prefix, and any device that subscribes to the event prefix will receive it.

So all you need to do is insert your region identifier instead of the Device ID in the hook response and any device that is interested in it can subsctibe to that region's hook response topic.

Thank you for the response. That's exactly what I am trying to do, but the API i'm using does not respond with the region identifier. Is it possible to insert it into the hook response based on what I send? The closest I've found is using {{PARTICLE_EVENT_VALUE}}, which gives me "hook-response/{"Region":"Northeast"}/0". It's close, but I'd really like it to be "hook-response/Northeast/0". {{PARTICLE_EVENT_VALUE.Region}} should work, but it returns a blank space "hook-response//0"

I am sending this string "{ "Region": "northeast"}" as the data payload in the request. I have tried {{{PARTICLE_EVENT_VALUE}}}, {{{PARTICLE_EVENT_VALUE.Region}}}, and {{{Region}}}, but as described above the first once gives more than I want and the other two return nothing at all.

Unfortunately there is no good solution to this, other than using multiple webhooks, probably one per region.

The reason it doesn't work is that mustache templates in the hook-response look at the response data from the webhook, not the original request, so unless you have the ability to copy the region into the response, there's no good way to handle that.

Okay, thank you!