Particle product hook response events are delivering through my personal account?

Having some really unusual behavior I can’t find any answers to.

I’ve created a product on particle that makes use of a webhook integration. When I publish from my electron to the event name of my integration, it does what’s expected and forwards some arbitrary web request I’ve set to my server.

My server responds, and all is well - I see the response come back in the integration’s history.

The problem is… If I’m watching the product events, I’m not seeing any hook-response or hook-sent events. I’ve tried looking at both the global product events from the left sidebar, and the device specific product events and no hook-response events or hook-sent events anyways… I thought this was really weird… so I did some searching and couldn’t find others having this issue either.

I then looked at events for my personal account / personal device… and lo and behold my product specific hook-response and hook-sent events are being delivered there but not to my actual product’s events. Why is this? No product publish events that triggered the resulting hook-response events are being delivered to my personal account’s events… just the hook response / hook sent event… Everything else is in the product’s events as it should be.

We’ve set the correct product ID in our firmware, we subscribed to these hook-response events but our electron assigned to our product running our product firmware is never receiving them.

I can’t find anyone else on the forums who’s had this issue either. So what’s going on?

Have you created the integration/webhook inside the respective product?<yourProduct>/integrations

The reason is that product events are essentially unidirectional, from devices to the cloud. They allow a device claimed by a product customer to send events that can be caught by the product event stream, typically by a webhook or SSE (server-sent events).

The webhook response events, typically hook-response and hook-error are not product events, so they don’t show up in the product event stream. They’re also not originated by a device, so they don’t show up in the device event stream.

Sending a private event to a device requires a private event for the device owner, not a product event. For a product with two-legged shadow customers, the product can impersonate to send these events, but it requires a customer-scoped access token, not a generic product bearer token.

In order to get the hook-response and hook-error events back to the device, they’re sent back to the customer that originated the event that triggered the webhook. It will always be a customer-scoped event, not a product-scoped event.

I see, so how does my electron receive the hook response then?

I’ve tried PUBLIC, ALL_DEVICES and more in combination with publish/subscribe in our firmware and I’m still not seeing any of our subscribe handlers being called. I’ve tried all variations of the event name subscribed too - including following the webhook document’s example specific to products and my subscribe handler is still not being called:

These devices are all registered to the product if it helps to know. The webhook integration has been created at the product level as well.

The correct subscription handler scope for hook response is MY_DEVICES. The others will not work.

The Test button in the console will only test the webhook, it won’t test the response handler. The reason is that it doesn’t know which customer account to use to send the response to.

The best way to troubleshoot this is to use the Particle CLI. Log into the same account that the Electron is claimed to and use the particle publish CLI command to try sending the request and also the response to help isolate the problem. Be sure to add --private.

We have been using MY_DEVICES in the subscription handler scope. The device has not been seeing hook-response events.