Using Particle Webhooks with YAAS PubSub

The hybris YAAS cloud services, soon in public beta, make it really easy to incorporate commerce features into your applications. One of the core services, that developers may use, is the PubSub Service. It is essentially a queue that you can put messages into and someone else can pop the queue to get events out. We thought it would be cool to use the Particle WebHook system to directly fire events into the hybris YAAS PubSub Queue. To make it a bit more visual, we bought a big, blue, push button and 3D-printed a humongous case for it ­čÖé

IMG_20150731_133629 IMG_20150731_133646

So what needs to be done?

First, we setup a Particle Photon and flashed some custom firmware onto it. We also wired the button and the LED within the button. Whenever you press the button, we send out a button_pressed event via the Spark.publish() function and blink the LED:

At this point, we’re already able to see the events that we publish via the Particle Dashboard.

Screen Shot 2015-07-31 at 2.29.59 PM

Next, we need to create a webhook that publishes the events into a YAAS PubSub Queue. Below is the webhooks.json file that defines the webhook. We use the particle-cli to activate it:

particle webhook create button_webhook.json

One thing to note: to publish an event, you need a Bearer token. We’ve used a little node.js script for that and added the token to the webhook definition like above.

And that’s it. When you press the button, the button_pressed event triggers the webhook and creates a new item in the PubSub publish queue. How to verify? For example via curl:

Et voila, done. We’ve created a simple IoT button that publishes an event to the PubSub queue. From there any subscriber can wire it up with the world.


Tell us what you think: