Confirming that a webhook succeeded

Hi,

From what I can see, this is what happens when a webhook succeeds. Didn’t find it in the docs. I hope it will be helpful. I also created a pull request to update the docs.

Confirming that a webhook succeeded

You will know that your webhook succeeded if you see the following pattern on your event stream (using Particle CLI command particle subscribe mine):

{"name":"name_of_my_event","data":"data_sent_with_event","ttl":"60","published_at":"2016-04-16T13:37:08.728Z","coreid":"1234567890987654321"}
{"hook-sent/name":"name_of_my_event","data":"undefined","ttl":"60","published_at":"2016-04-16T13:37:08.743Z","coreid":"particle-internal"}
{"name":"hook-response/name_of_my_event/0","data":"ok","ttl":"60","published_at":"2016-04-16T13:37:08.755Z","coreid":"particle-internal"}

Explanation:

  • The first line is logged when you call Particle.publish() in your firmware.
  • The second line (hook-sent) confirms that the Particle cloud was able to reach the endoint URL of the webhook
  • The third line (hook-response) means that a response was received. The event handler attached by the Particle.subscribe() function in your firmware should be called.
1 Like

Just as a side note, the /0 doesn’t need to be added to your subscribe.

Furthermore it shouldn’t be included in the filter since you might even get multiple responses with .../1, .../2, … which you probably want to handle too.

1 Like