Setting up a Webhook and calling it from Arduino code

I created a Web API server. I can use the program POSTMAN to create a POST and see that the new data is in my SQL database.

In POSTMAN, I can click on “code button” to get the request that POSTMAN sent to my Web API. (In my example I have changed the url)
POST /api/trails HTTP/1.1
Host: www.someurl.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 87abdc11-a625-4510-b6d8-bdc073fdd27c

{
“trailDateTime”: “2018-09-08T00:00:00”,
“trailId”: 1,
“traillName”: “Holo Trail”,
“trailBike”: false,
“trailLatitude”: 41.888552,
“trailLongitude”: -87.635437,
“trailElevation”: 200.0
}
I went into my Hologram Dashboard and setup a WebHook. I took a screen shot of my WebHook and will add here as a photo.

In the Hologram Dashboard, I called the webhook – myTrail

I have looked through the Community forums and through the Hologram docs to see if I could find an Arduino example of how to call the webhook and add the appropriate json data. Is there an webhook example in the docs for Arudino code?

(Note - I have a SIM808 and an Arduino UNO. I have downloaded the arduino library Hologram-SIM and have successful run the Kitchen sink example program.)

(Addition
After posting, I did find a webpage - Step by step example

In the above webpage, his Hologram webhook is called Ubidots Route, but in his code I don’t see where he does anything to call that route. He just has the following code.
/* Send JSON data to Hologram’s Cloud */
Hologram.send(payload);

How does his program know to use the correct route?

Routes are triggered by incoming messages to the Hologram data engine (either REST or socket message) that have a topic in the list of topics for the route. When you create a route you first select the topics to associate with that route (next to the large purple “IN” text). Any incoming message with one of these topics will trigger the route.

Note some topics are automatically added to every message received by hollogram such as “any message received from REST” (_RESTAPI_), “any message received from Socket” (_SOCKETAPI_), “any message from Device 12345” (_DEVICE_12345_), etc. You can also specify custom topics to send with a message in Hologram’s SDK or using their API’s directly.

So to trigger your route, you first would need to associate a topic with the route during route creation and then on your arduino make sure to send the corresponding topic with the message if you are using a custom topic.

If you are using an arduino with SIM808 you are likely going to use the hologram socket API. So the easiest way is to add the topic “_SOCKETAPI_” to the webhook route you created and send the required JSON package to the hologram socket API. This will then trigger the route as you want.

I hope that helps.

1 Like

Andrew, thanks for your reply.

I went into my Hologram Dashboard

Clicked on my Device Pilot(08655)

Then clicked on routes

Then clicked on Configure

Is my Route Name Pilot (08655) (as I have circled)?

Also I went into the documentation for configuring routes

In the documentation, where does the names _JsonString, _Device_10464 or _SocketAPI come from? Also is it possible to create your own custom Topic names – in my case I have a api to log gps trail coordinates, so it would be nice if the topic was _GPS_Coordinates_Log

Is my Route Name Pilot (08655) ?
No “Pilot (08655)” is a topic. This topic is associated with all data coming from this device (simcard ending in 08655) It is automatically added to messages. This means data from any other device will not trigger this route. Your route name is “myTrail”

Where does the name JsonString, … come from?
checkout https://hologram.io/docs/reference/cloud/data-router scroll half way down to “System Topics” this describes the automic topics hologram creates.

is it possible to create your own Topics?
Yes in your screenshot with the green circled box “Pilot …” to the right click “edit” and where it says “search by topic name” type in your new topic and hit enter. In the image below “new_custom_topic2” is the topic I am about to create. the two green boxes at the bottom are topics already applied to the route including “new_custom_topic” which I previously created. The blue “combined-4g” are just holograms suggested topics based on recent activity.

Note to use custom topics you will need to edit your code on the device sending messages to add the custom topic name to your payload. You can checkout holograms SDK for how to do this.

1 Like

Andrew, thanks very much for your reply.

Good catch on the first question - I meant to ask "is my Route Topic Pilot (08655)…but you gave a perfect answer.

I did go back in to create my own Topic…I called it myTrailsAPI. So now as I start to play with my arduino code, from the “Hologram SIMCOM Arduino Helper Library” I will use the command - Hologram.send(data, “myTrailsAPI”) ;

John

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.