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

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.

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:
Ensure you have a site configured with a floor map, zones, and beacons/sensors in place.
Click on "Management" heading
Click on "Subscriptions" subheading
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

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

Related

How do I get GraphQL to get live/new data from database without polling?

I have a backend running GraphQL, MongoDB + Mongoose, and Apollo. This application has functionality for user accounts and a friends list. Each user can login to their account and see a list of friends with their current 'status'; If a friend changes their status, I need that change to be reflected on the user's side. An example of this is like facebook's "green dot" on messenger that tells you when one of your friends is online using the application.
I have been searching documentation for GraphQL and have been suggested either Subscriptions or Live Queries. Subscriptions seem to be the majority of suggestions from what I understand, live queries are not officially part of GraphQL or were dropped.
Does anyone have a solution to getting "live" data with GraphQL/MongoDB that doesn't involve polling for this scenario?
You already seem to have your answer: subscriptions!
Using your example, consider two users - mikep17 and mcy. You are mikep17, logged into your application and viewing your list of friends and their statuses. I am your friend, and I log in as you are viewing this list, and you want to see that in your application's UI.
On the frontend, in your application's instance, your application will execute a subscription to some event. Let's call it friendStatusChange. Now your application is "listening" for that event in order to respond accordingly. Let's assume that when your application receives the event, it can parse out the information that "I" (mcy) have changed from offline => online and then use that to add the "green dot" next to my username.
On the backend, your GraphQL server will have code that handles your user functionality - logging in, logging out, etc. It will need to be enhanced to hook into these actions and "publish" the friendStatusChange event as applicable.
Now, instead of your client constantly asking (polling) "did a friend's status change? how about now? now?", it can just listen and wait for your server to tap it on the shoulder and say "hey buddy, your friend mcy's status changed".

Action with different fulfilment URL based on user's location

I work for a company that is building a Google Action which will be available in AU, NZ & UK. Depending on the location of the user, the fulfilment URL needs to be different as each country has its own APIs, etc.
We could achieve this easily by deploying three separate apps, restricted to their particular country, each having their own fulfilment URL. However, if my understanding is correct, they would all have different invocation names which is not ideal.
Another way we could potentially achieve this is by making the user choose which market they want (AU, NZ, UK) on the account linking page and then use the APIs for that market. However it doesn't seem to be a great UX.
Ultimately the key goals we're trying to achieve are
Users in AU, NZ & UK can all invoke the Google Action by saying "Ok Google, Open App", rather than "Ok Google, Open App NZ", "Ok Google, Open App UK", etc.
Users don't have to choose market (AU, NZ, UK) they belong to - it happens automatically
We can use the correct API based on the market the user belongs to.
There is no way to have different fulfillment URLs for the same Action.
You also have a slight issue when getting their location - you need to request it explicitly from them. Once you have this, however, you can store it (with their permission) to use it again in future requests, so you only have to do it once.
You will need to check to make sure it is one of the locations you serve, and you may want to allow them to change it (what if someone from the UK is traveling to AU?).

How to disable email notifications in bluemix devops services track & plan

Working with the 'Track & Plan' feature of the IBM Bluemix DevOps Services generates a lot of email notifications to my co-workers and me. For example, notifications are sent out for each work item creation, modification or assignment. As the number of such mails is overwhelming, I would like to deactivate them.
If I had full access to the underlying RTC instance I would go about this as outlined in the RTC Knowledge Center - Configuring notifications in the web client.
So far I haven't been able to find a comparable configuration page in the version hosted on DevOps Services. Also, the Bluemix DevOps Services Documentation (e.g. Track and plan) didn't yield any hints in that direction.
Is there a way to disable these notifications either completely or at least partly? If so, how?
You can disable email notifications by following the instructions here:
https://developer.ibm.com/answers/questions/185255/configuring-track-plan-email-notifications.html
Find your name on a full page workitem and click on it (could be in created by, subscribed, mentioned in a comment, ...)
You'll land in a page that has your profile and some license information...ignore that. Take the URL from the browser window and paste it into a text editor or some text buffer somewhere. e.g. https://hub.jazz.net/jts08/admin#action=com.ibm.team.repository.viewUserProfile⁢emId=_yyeAwKGKEeSa6LqyswPPCA
Go back to the Track&Plan view click on "Track & Plan" drop down and select the "Project Dashboard". You should now have a URL that looks like: https://hub.jazz.net/ccm08/web/projects/dleroux%20%7C%20TestNewSprint#action=com.ibm.team.dashboard.viewDashboard
Take the action portion from URL in 2 and replace the action portion of the url in 3 giving you something like: https://hub.jazz.net/ccm08/web/projects/dleroux%20%7C%20TestNewSprint#action=com.ibm.team.repository.viewUserProfile⁢emId=_yyeAwKGKEeSa6LqyswPPCA
Navigate to the URL...select "Mail configuration"

how do i track a users activity online

We are building a system that seeks to calculate and score the value of information and users of information - based on the interaction between the two.
To do this, we need to track and measure these interactions. We are working on different ways - from connecting your social services and monitoring them (hard to scale and requires very patient users happy to connect services) to explicit tracking having a bookmarklet ala digg that user can trigger whenever she is on a piece of information (basically, content) that she wants included in her score.
What we'd really like is a tool that could do something like;
monitor all activity of a person across all networks (read, watch, comment, post, tweet, author, etc) and actively sit in the users browser and 'listen and report' back to HQ anytime a defined activity takes place.
Suggestions?
If you want to monitor the Social network activities for ex. Facebook, you need to take the authentication from the user like read/friends list etc. and fetch the updates from facebook with in specific interval of time and report same to HQ.
The same thing you need to report for other networking sites.
Each network sites may have different APIs you need collect and take the permission of the users (like signin).
Hope it helps.

Using GA Data Export API to Get All UA's

I am using the GA Data Export API to interact with Google Analytics and I'm making a lot of progress, I am using this URL Endpoint initially to pull all the profiles under an account:
https://www.google.com/analytics/feeds/accounts/default
This URL retrieves each GA ID (profile) and each UA. One thing I've realized is one account can contain multiple UAs and when this happens, this request pulls all profiles. We have a client who has about 115 profiles under like 10 different UAs, and the request takes about 30 seconds for the initial request (and then I believe it must be cached, because it speeds up considerably after this, but then the next day the same thing occurs).
Is there a way to get a list of UA's without pulling the profiles? This way I can query the UA specifically for the profiles instead of pulling each one.
Any advice on this would be really helpful!
Thanks
UPDATE: Here's some documentation on the specific call I am using right now:
http://code.google.com/apis/analytics/docs/gdata/gdataReferenceAccountFeed.html
UPDATE 1: I have found some interesting information in the docs
Once your application has verified
that the user has Analytics access,
its next step is to find out which
Analytics accounts the user has access
to. Remember, users can have access to
many different accounts, and within
them, many different profiles. For
this reason, your application cannot
access any report information without
first requesting the list of accounts
available to the user. The resulting
accounts feed returns that list, but
most importantly, the list also
contains the account profiles that the
user can view.
So this means that you have to use the default accounts call to get these back? Surely, somebody has had this issue before?
So apparently, you can query the account if you know the UA-ID, however there is no way to get back a list of only UA IDs.
One way you can do it is have the user enter their own UA ID instead of having them choose one; not as user-friendly as it could be but better than making the user wait 30 seconds!