Webhooks examples?


#1

Sorry, I am a bit lost trying to figure out the REST API and WebHooks. I am trying to figure out how to get my data from the Dash to Thingspeak for further processing. Any hints further hints or examples you can give?

I can update my ThingSpeak channel using this URL:

GET https://api.thingspeak.com/update?api_key=HEREISTHEAPIKEY&field1=WHATEVERVALUE

I have the Dash writing my data to a comma delimited list and I just can’t seem to figure out how that is supposed to go into the WebHooks routing rule or how you can select the data.

Thanks!


Webhooks Data Storage
#2

We need to fix the docs on this stuff.

Try this:

Advanced Webhook App
URL: https://api.thingspeak.com/update?api_key=HEREISTHEAPIKEY&field1=<<decdata>>
Payload: _NONE_


#3

Cool - yes that works for getting a single reading over to ThingSpeak successfully. How would I upload multiple readings over? The usual way with the ThingSpeak API is appending:

&field1=XXX&field2=YYY&field3=ZZZ

How could I tell the WebHooks API to populate the values above for XXX, YYY & ZZZ or should I just have the Konekt Arduino sketch send over that string?

Thanks!!


#4

Ah ok, for now you might just need to put it in the sketch as our cloud is only able to put your data into the URL.

However, one idea we had was to be able to parse JSON coming in from the device and be able to pull specific fields. For example you could have the device send:

{
"field1":"TestValue1",
"field2":"TestValue2"
}

And then in the webhook you could put ?field1=<<data.field1>>&field2=<<data.field2>>

Does this seem like it would be helpful? We can probably implement it this week.


#5

I will try putting it in the sketch and see how that works out, but it seems to me like I would be sending quite a bit of “extra data” over the data connection that isn’t required. In other words:

“&field1=28&field2=120&field3=500”

This would be 32 characters. Sending the data comma delimited would be:

“28,120,500”

Just 10 characters. Forming up the JSON seems to me would use even more characters up, but I assume would be easier to parse once it’s received? Not sure how this would impact the data usage of the device since I know there is a lot of overhead with each packet anyway.

I would suggest in the WebHooks interface some way to specify a delimiting character in a string received and then a way to assign that delimited value a name and a way to form that up into the string to be sent to the API. I could draw something up later on if this if you like.

For me, something prebuilt to accommodate ThingSpeak would be helpful since I do a lot of work on that platform, but I know there are a lot of other IoT cloud providers out there.

  • Chris

#6

It works like a charm! I have the sketch sending out the whole string of the fields + values and they are showing up correctly in ThingSpeak!

I am concerned that sending the full string over now shows as 44 bytes of data used, while sending over just a single three digit numerical value was only 4 bytes.

I also see an issue with editing the WebHooks, but I will create a separate topic for this.


#7

I am a fellow enthusiastic user of Thingspeak, so any further development for Konekt - Thingspeak integration / playing nicely would indeed be welcome.


#8

Yeah I think we’ll probably be doing a dedicated Thingspeak integration in the near future


#9

I have been able to successfully make this work with sensor data being relayed from the Dash to the Konekt Cloud to ThingSpeak. I will try to write up a tutorial on my blog and post it to the Projects section. Pretty easy now that I have all the bits working.

Reuben - one thing I see is that when I go to edit the WebHook, I can’t see the previously entered URL & Payload values. They still seem to be there and active, but if I want to change anything I need to re-enter them. I see this on both Firefox and Chrome.


#10

I noticed that as well – it finally appears after you wait / kick it a few times / refresh, etc. It will come up if you fiddle with the webhook screen, but ya, it’s definitely cranky… :smirk:


#11

Sounds like a bug in the dashboard. I’m seeing that too. We’ll file a task to get that fixed.


#12

Did something change this afternoon? Seems like my Webhook stopped sending data on to ThingSpeak around 2PM Eastern.


#13

One of our databases went down earlier. We’re working to bring things back up. All of your messages should show up once that happens.


#14

Thanks. I’ve shut down my Dash for now and I’ll restart tomorrow and see how it goes.


#15

Oh, everything is back up, btw. Sorry for not posting sooner.


#16

Working now! Thanks!


Outbound SMS via either api?
#18

Hey Reuben, I just bought my first Dash. Have you implemented the ability to send JSON from the device via webhook? Thanks


#19

We still have JSON support on the roadmap and currently only support sending strings. Although you can send a string which looks like a JSON object and it should be parsed correctly. If you are having troubles, make a seperate forum post and I can help you get it figured out.


#20

Ok. Thanks, I have not got it in yet, but that was the main functionality I was needing. I will open a thread once it comes in!