JSON WebHook Clarification

I have the following webhook running in the cloud.

{
  "event": "{{SPARK_EVENT_NAME}}",
  "data": "{{SPARK_EVENT_VALUE}}",
  "published_at": "{{SPARK_PUBLISHED_AT}}",
  "coreid": "{{SPARK_CORE_ID}}"
}

I was hoping to replace SPARK_CORE_ID with the name of the device instead. I was hoping someone could point me to the right place where I can find this in the documentation? I’ve had trouble locating it.

Thank you!

@knoose, thanks for @Moors7 who pointed me in the right direction (even though I seemed to be looking the wrong way anyway!), you can get the device name into a string and then use that to pass the the device name to the webhook.

https://docs.particle.io/reference/firmware/photon/#get-device-name

3 Likes

So the only was is to publish the name? There’s nothing like SPARK_CORE_DEVICE_NAME that I can use instead? I’d rather not send multiple messages when the ID itself is already being transmitted in a publish message.

The device name is not present on the device but only in the cloud.
So when publishing from the device, there is no native way to embed the name in the publish message.

That’s fine about it not being on the physical device. To clarify my question, once my particle.publish() message gets to the cloud and my webhook is activated, is there any way to use the Device Name instead of the Device ID? It would be much clearer in my DB to have the Device Name. Otherwise I will need to create a lookup table in my DB.

AFAIK there is no itermediate processing of the published event between publishing device and the actual webhook processing which would “inject” the device name and as such there is now way (yet).

1 Like

Thank you! I hope that’s something they’re working on but I’ll make use of the IDs for now.

@jeiden will be able to confirm for you!

Hey @knoose – the only variables currently available are documented here:

https://docs.particle.io/guide/tools-and-features/webhooks/#webhook-variables

Device name is not currently available