[SOLVED] Calling Particle Function from Ubidots webhook

I’m trying to call a Particle function on a specific device from a particle webhook event.

I have it working following this tutorial:

I can use the API from the following like:
https://docs.particle.io/reference/device-cloud/api/#call-a-function

This syntax will be:
https://api.particle.io/v1/devices/device-id/function-name

This works fine as well. The problem is that I have to hard code the device id. I can’t use the variable device label that you can use in the body.

Yes, the device can subscribe to the event the Ubidots webhook uses. But if we have many devices, they will ALL get the same message.

Ubidots has the ability to have the Ubidots device label in the Body of the webhook, but I don’t see a way to do it in the URL where it needs to be.

So if I make a device type in Ubidots to auto make events for variables, I need to be able to make the device id variable in the URL.

How do I do this?

Thanks,
Matt

Hello @guitardenver,

Unfortunately, that is not possible at the moment so you have to perform the ID assignment process manually.

I consider that adding a bookmark to be able to assign device and variable labels within the URL field can be very useful in this case. I will pass this information to our PM for further releases. Thank you!

Greetings,
Maria H.

Maria,

Thank you so much for your reply.

Would you be able to suggest an alternative method to send data to a specific Particle device? Without this, it is a big scaleability issue. I would have to create all the events for every device manually instead of utilizing the power of device types that automagically does everything for you on first connect. Unless i’m missing something.

Just throwing out ideas:

  1. Can an Ubidots webhook trigger a Particle webook that calls the particle function? So the particle webhook would parse the body of the Ubidots webhook to get the device label/device ID and put it in the URL. If particle can do that.
  2. Can an Ubidots event trigger an Ubifunction? The Ubifunction would get the device label/id of the device it was triggered from and form the correct Particle API?

@guitardenver,

You’ve come to good conclusions, the appropriate alternative is #2. The UbiFunction will be in charge of structuring the parameters received as required by Particle APÏ, and at the same time will be in charge of handling the requests to its services. Then, from a Webhook event you have to activate the configured UbiFunction.

Cheers,
Maria H.