WS1 UEM Event Notifications

Overview

Several years ago I gave a presentation at the old AirWatch Connect Conference about automating your AirWatch deployment. As AirWatch evolved into Workspace One UEM, there has been a big effort to imporove the API functionality of the tool, to make it easier to integrate into your existing enterprise apps, and bulild additional workflows. This post will focus on a particular feature in the UEM console - Event Notifications. 

In this walkthough we will use a couple of services to build a workflow that when a device enrolls, an Event notification is fired to a web service, that will process the event, and respond by calling the UEM api for adding a device tag. In practice, this enroll+tag workflow probably isnt something that would be deployed in a production environmnet, but builds the foundation to easy expand on. 

Event Notifications

Event Notifications in Workspace One UEM allow the UEM console to send a notification of an event in the UEM console, such as a device enrollment, unenrollment, compliance status change, etc.. to another service via http methods. 

The VMware documentation for this feature can he found here

Prep work

As mentioned in the intro, we are going to be using several services to build our end to end service. What is cool about this, is that we will get some exposure to some pretty neat tech that I generally don't touch on a day to day basis - things like node.js, serverless, API scripting, 

To follow this guide step by step we will need the follwing. If your just using this as a reference, adjust based on your development environment:

Once we have those 3 things - were ready to build our workflow 

 

Pipedream configuration

The first thing we have to do is get logged into pipedream and create a new event source

Head over to pipedream.com and if you dont have an account already, hit Get Started, if you have an account log in.


 console.log('Everything is awesome.');

Workspace One UEM configuration

Now that we have the service, we want to receive our UEM event notifications, let’s get UEM configured to send it some data. 

Building our app

Now that we finished enrolling our device into our UEM console, an Event notification should have been fired and a message received in our pipedream app. Let’s head over there to check it out. 

OK - so don’t be overwhelmed, we will break this down but here is the code we are going to use in our node.js workflow step. 


const axios = require("axios")

// Make an HTTP POST request using axios

const resp = await axios({

 method: "POST",

 url: `https://as1.awmdm.com/API/mdm/tags/TagID/adddevices`, //This is your UEM API URL, replace {TagID} with the correct tag id

 data: {

   "BulkValues": {

               "Value": [

                   steps.trigger.event.body.DeviceId //this is the variable that will grab the device ID send in the Event notification if you followed step by step, this shoudl be correct, if not update to your value

               ]

           }

 },

 headers: { //the headers to send in the post to the UEM API

 'aw-tenant-code': 'UemApiKey', //API key from UEM console - !! DO NOT HARD CODE THESE IN THE FINAL CODE this is educational only!! 

 'Accept' : 'application/json',

 'Content-Type' : 'application/json'  },

       auth: {

       username: 'UemApiAdminUser', //UEM Admin user with API Access - !! DO NOT HARD CODE THESE IN THE FINAL CODE this is educational only!!

       password: 'UemApiAdminUserPassword' //UEM Admin User password - !! DO NOT HARD CODE THESE IN THE FINAL CODE this is educational only!!

}})

// Retrieve just the data from the response

const { data } = resp

// export this data for use in a future step

// https://docs.pipedream.com/workflows/steps/#step-exports

this.data = data

OK So what are we looking at the first line is telling node to load the axios http library, this allows us to send a POST http method to our UEM endpoint

Verify

OK so quick recap, at this point we have configued UEM to send a notification from the UEM system to pipedream every-time a device enrolls. That notification contains a number of pieces of device information. Once the notification hits our pipedream endpoint, it moves into the node.js code and gets the deviceID of the device that just enrolled. Once it does that it sends a command back to the UEM console to apply the "pipedream" device tag to the device that just enrolled. 

Let's test it out! 

Have Fun!

OK so as I mentioned just adding a tag on enrollment alone probably isnt much value - but if you got more complex with your node application code, you could apply tags based on a bunch of different things, or differnt UEM events as well. Rather than pointing back at UEM maybe your node code goes to a totally different system! There are tons of options and I would love to hear what you come up with!