Webhook without a URL?


#1

We have a project with a couple of constants that we would prefer to not have in our code - it makes it easier for us to share the code with other organizations. It also makes it easier for us to change those constants in all of our devices without having to reflash the code OTA. Imagine that these constants were the login credentials to some service. We could put them in our code, but what if our service provider changes the credentials on some regular basis?

Our thought was to put the constants in the return template of a webhook. When our firmware starts up it will Publish to trigger the webhook and retrieve these constants for use.

It works well except that the webhook has to have a URL configured. If I put in google.com the process works, but it would be nice if I didn’t have to do that.

If I could configure a webhook without a URL, then I could call it to retrieve these constants from the Particle cloud without having to tickle google.com.

Jim


#2

A setup function which stores the value in EEPROM would be my first way to go with that.

A webhook will always try to hit a server and never just report back on its own.
However, you can have a dynamic URL sent from your device as event value.


#3

We don’t want to store these values on the devices, we want them to be ephemeral.

Thanks for the confirmation on the webhook. We’ve set it up to hit google.com each time. That isn’t ideal, but it will work for us.

I still like the idea of an enhancement to webhooks that don’t hit a URL.


#4

This contradicts that tho’

Constants by definition are not ephemeral but you currently use them.

However, if you needed them to vanish after a power down, you can just store them in RAM :wink:

How would that scale for multiple sets of constants?
You’d typically store your individual sets somewhere and hit that source for the desired info.


#5

Sorry for the imprecise semantics; I’ll try simpler terms.

We do not want these values to remain on these devices through a reset.

We do not want these values to be in the code for our firmware.

We would like our devices to retrieve them from a cloud source. We are using a webhook today, and that webhook uses google.com as the URL. We wish there was an enhancement to webhooks that would work without requiring a URL.

In terms of scaling, we store the values in a JSON string in the webhook response template. Seems like that will work for our needs.

I agree that one would typically store the individual sets somewhere. I’d like to store them in a webhook in the Particle cloud and hit that as the source for this desired info.


#6

This would mean you’d require a dedicated webhook definition for each set of devices while they all would listen to the same event name.
This would require a separate account “owning” that webhook and all the devices of that group.
While this is possible, it doesn’t seem very scalable IMO.


#7

Hi Jim,
if I needed to do something like what you describe, I would give it a shot at using the device notes. You can access them via the rest API, and perhaps one can configure a webhook to hit them and get values even per device, if needed:
https://docs.particle.io/reference/device-cloud/api/#add-device-notes

You get the notes of each device with a get request to the device info API, I believe.
Good luck!


#8

Thanks for the idea. We’ll have about 50 units so keeping the device notes up to date would work, but be a burden.

I’m not sure about scruffR’s issue on scalability. We do intend to have a separate account own the devices, but even within that account there will be two groups of devices. We’ll have two webhooks, one for each group of devices. Seems like it’s going to scale just fine. If some issue develops I’ll report on it to this thread.

Would still like the enhancement of not needing a URL on a webhook.


#9

Feels more like you’re using the webhook as a hack for cloud storage, which is really not what they’re made for. They made to hit a URL.

What you actually want is cloud-based configuration storage which you can query on boot. A ‘virtual twin’ if you will.

Is that a better way to describe it?


#10

@Moors7 You are exactly right! I think this would be an easy addition to the webhook infrastructure. Could be valuable for a lot of projects.
Jim


#11

So I use a solution based on particle cloud and thingsboard.io - this allows me to retrieve attributes from the thingsboard profile for the device and in that i store all sorts of config variables to do just what you need - it uses mqtt. My setup gets device site name, time zone offset, lat, lon etc and can be updated manually or from an api call from another system - I find it compliments the particle cloud well - plus you can also visualise data on dashboard if you need to. SO now I have a device management path (particle cloud) and a data management path (thingsboard) that can operate somewhat independently of each other.


#12

Thanks. I’ll look into it. I was hoping to keep it all in the Particle.io solution.
Jim


#13

oh, in that case, you can just use the notes of one device to control all of them. I can even be one test device.
Anyhow, this would be another hack. Good luck!