MBillau
MBillau

Reputation: 5376

How can I set up a webhook or subscription from Presence Insights?

I have been using IBM's Presence Insights to gather indoor location based information. How can I get Presence Insights to send me updates about location events that are important to me? I would like to perform some action when, for example, a mobile devices enters my "entrance" zone.

Upvotes: 0

Views: 356

Answers (2)

timd
timd

Reputation: 376

The idea of Subscriptions is to allow any events that are detected and passed into Presence Insights, to also be shared with additional applications, i.e. A marketing / offer engine, or system to create Mobile Push marketing messages as examples. The data that get passed out of Presence Insights includes the device id, location, and any additional device information that has been included in the device registration document. Again, this could include a phone number, loyalty card number, or any info you wish, which can be both encrypted or not. The Doc' s detail how to set up a Subscription event; Management -> Subscriptions -> Create a Subscription via button -> Set the URL you wish the info to be passed on to { this would be your application } -> then select the location you wish to trigger Subscription event, and event type. ( i.e. You select a complete floor or site, and when an event happens at that site or floor, and subscription event gets created and forwarded out of PI). You can then also focus the event, so may be only when in a zone or such.

Its hard to show an example, but when we do demos, one of the applications that very easy to setup and configure to receive these Subscription events, and then perform some action is the Open Source package 'Node-Red' (nodered.org) which is also available in Bluemix (https://console.ng.bluemix.net/catalog/starters/node-red-starter/). You then create a flow such as ..

Picture of Node-red flow

Upvotes: 1

MBillau
MBillau

Reputation: 5376

You can set up Subscriptions to get an HTTPS POST every time a certain exit/enter/dwell event happens in a zone, group of zones, tag, or group of tags. You will need to provide a callback URL to Presence Insights that will be the endpoint that receives the POST.

You can create a subscription pretty easily within the Presence Insights UI:

  1. Ensure you have a site configured with a floor map, zones, and beacons/sensors in place.
  2. Click on "Management" heading
  3. Click on "Subscriptions" subheading
  4. Click on the blue "Create Subscription" button on the right. Fill in the popup:
    • The "Webhook URL" is the HTTP endpoint owned by you that will receive the POSTed event from PI. (More on this later.)
    • Check the boxes for the different events you are interested in (Enter, Dwell, Exit, Timeout)
    • Username and Password are BASIC AUTH credentials for your "Webhook URL" above.
    • Select the site name/tag that you are interested in with the dropdowns.
    • Select a zone tag. You can tag multiple zones with the same tag, or have unique tags for each zone, or a combination of both.
    • Ensure that "Active" is checked. If you want to disable this Subscription at any point, you can simple uncheck the Active button.

Regarding a Webhook URL - this generally requires a server. You can mock up an endpoint very quickly using Node.js, or my personal favorite, NodeRED. We have example NodeRED flows out there already, see this tutorial: https://github.com/presence-insights/pi-sample-NodeRED/tree/master/Eventing

Upvotes: 1

Related Questions