Subscribe to a Webhook response triggered by a specific device

Hi @jlkalberer, I love the responseTopic feature. Here is how it goes:

On your webhook:

{
	"event": "get_location",
	"url": "https://neutrinoapi.com/ip-info",
	"requestType": "POST",
	"query": {
		"ip": "{{myIP}}",
		"mode": "json"
	},
	"responseTopic": "hook-response/get_location_{{SPARK_CORE_ID}}",
	"json": null,
	"auth": null,
	"mydevices": true
}

On your firmware:

Particle.subscribe(String("hook-response/get_location_" + System.deviceID()), locationHandler, MY_DEVICES); 

Particle.publish("get_location", "{\"myIP\":\"" + myIP + "\"}", 60, PRIVATE);

You can deploy this firmware to all your Photons. Only when the hook is responding to that specific Photon’s call, that device’s locationHandler will be call.

Hope this helps.

1 Like