New Feature! Webhooks!

We’re rolling out a new feature for all everybody today Webhooks!

You can now trigger HTTP and HTTPS web requests to any server online with nothing more than

Spark.publish("Hello World!");

You can setup webhooks to listen for events from your devices, and immediately trigger powerful side-effects anywhere online! You can also now securely retrieve data from HTTPS sites, and take advantage of your already encrypted session with the cloud.

Thank you to the over 100 beta testers, and to everyone who’s helped make this possible, yay!

Learn more here:
http://docs.spark.io/webhooks/

This is just the first of a ton of new features I’m really excited about launching this year, enjoy! :slight_smile:

Also, if you are interested in using cellular connectivity in your projects, checkout the Electron! Over 3000 of you have already backed and unlocked a free month of data, woot!

Thanks,
David

19 Likes

Here’s your first tutorial :smile:

BTW, I am super excited about Webhooks!

6 Likes

This is extremely exciting! I’ve been patiently waiting for Webhooks!

Thanks for your hard work/efforts!

Carsten

Really, really cool!

The examples (and BDub’s example above) all show replacing a single JSON or form field; what if I want / need to replace multiple fields? It doesn’t look like I can really set more than one field given the template syntax… am I wrong?

Thanks!

In the "json" parameter, dont pass in a complete json body like this:

{"type": "note", "title": "Note Title", "body": "Note Body"}

You would just pass in key:value:

"json":
{
"type": "note",
"title": "Note Title",
"body": "Note Body"
},

If that makes any since? Here is how to pass in multiple json values formatted:

I was able to make it work with pushbullet (I guess basically the same as PushOver).

For anyone asking, here is the json file I used:

{
"eventName": "pushbullet",
"url": "https://api.pushbullet.com/v2/pushes",
"requestType": "POST",
"headers": {
"Authorization": "Bearer xxx",
"Content-Type": "application/json"
},
"json":
{
{"type": "note", "title": "Note Title", "body": "Note Body"}
},
"mydevices": true
}

Replace xxx with your Access Token found under your Account Settings.

It works really well and super fast. Great work!

Carsten

2 Likes

I understand that, my question is if it is possible to customize more than one field in the JSON that is posted as part of the webhook. Using your example, what if you want to customize both the “title” and the “body” sections of the event that your webhook as part of your publish event? This doesn’t seem possible at the moment.

Not a huge deal, just something to keep in mind when integrating!

Hi @hoxworth,

Good question! A few people have asked for this feature since we launched, and it’s interesting, I think I can make it work. :slight_smile: I’ll add it to my backlog and build it when I get a chance.

Thanks!
David

In the Librato example the event name is “librato_”, but when Spark.publish is called librato_A0 is called.
Is this a mistake, is there some regex magic going on or am I missing something?

Edit:
Also, I have a couple more questions about webhooks would this be the appropriate place to discuss them?

I am new to this stuff, so maybe a silly question:

What do webhooks offer that is superior to using the REST API for a website?

Thanks

Hi @electronut

Webhooks can do HTTPS TLS/SSL whereas the Spark core cannot do that directly.

So webhooks can act as a trusted intermediary similar to what IFTTT can be but with more flexibility.

3 Likes

In addition to @bko’s response about the benefits of HTTPS, Webhooks also offer the ability to perform event driven web requests, so the rest of your code can spend more time doing other tasks, instead of waiting for the internet to reply. When the reply comes back, your Spark.subscribe() event handler can process the results.

Webhooks are like sending a text message while playing some video games and then getting a text message back. VS an HTTP Client which is more like putting down the game controller… picking up the phone… placing a phone call… having a conversation… ending the call… hanging up the phone and then playing video games again :slight_smile:

7 Likes

this is a big plus, nice when you don't need to wait for a response!

great new capabilities just keep rolling out, both on the hardware side and the firmware side!

2 Likes

Hi @mnova,

Good Question!, the webhook eventName acts as a prefix filter, so any events starting with the event name you specify will be included, so “temperature/” will grab any event in the form “temperature/kitchen”, “temperature/basement”, etc, etc. :slight_smile:

Thanks,
David

@Dave When creating a webhook from cloud api im getting a “Timed out” as the response.

Im sending access_token,event,url and deviceid as x-www-form-urlencoded values to the endpoint https://api.spark.io/v1/webhooks

Is there anything im missing?

I can successfully list my webhooks and delete them but I cant seem to create any

Hey @Devin , thanks for bringing this up and sorry for the troubles–I’m seeing this issue too. We are looking into it, will report back when we know more.

Thanks,

-joe

Thanks @jgoggins for the feedback!

Hey All,

I’m seeing this issue also and am looking into it now, I’ll post updates when I have them.

Thanks!
David

Hey Guys,

I think this was an issue with webhooks keeping a heartbeat alive internally, I’m setting up an alert to detect this and looking into a more full code fix. But it should be working again for now in the meantime.

Thanks,
David

1 Like

I am still seeing this issue…