In this article, we’ll cover how to use Zapier to connect data from your Jamf Account to a Google sheet. Once you build a WebHooks receiver in Zapier, you don’t have to use Google as the third party service that your WebHook triggers. You could use any other service that Zapier integrates as well, including Mailchimp, WordPress, Shopify, Todoist, ZenDesk, SurveyMonkey, Freshdesk, Quickbooks, Basecamp, and about 1,200 other solutions. In other words, you can link a WebHook from Jamf Pro into pretty much any automated service that you can think of!
So what’s a WebHook? A WebHook is an HTTP callback, or an HTTP POST that is fired when an event happens. The goal of WebHooks is that they are simple event notifications, typically sending a small amount of json to a destination web server that’s then ; a simple event-notification via HTTP POST. A web application listening for that event will then receive the WebHooks and perform a task in the background. Zapier is a great little tool that connects web apps. For modern software apps, most of this is done via acting as a WebHooks receiver and sending an API call to another tool.
To follow along with this article, you will need a Zapier account, Jamf account and a Google account. Since we’ll be using Zapier to connect Jamf Pro and Google.
Google Sheet Setup
- Signup/Login to your google account at https://docs.google.com/spreadsheets.
- Create new spreadsheet.
- Add any column names of fields you will want to store on your google sheet about your device—i.e. Date, Group, Name, Mac Address, IP Address, Make, Model, etc. We will use these columns in the Zap to map our data to the correct column.
Zapier Setup
- Signup/Login to your Zapier account at https://zapier.com
- Click “Make a Zap!” button in top right-hand corner.
- You will start my setting up the webhook for catching the smart group change.
Catching Smart Group Membership Change Zap
- Name your Zap
- Add Note (optional) – Optionally it might be good to add some details about what you zap does. You can do this by clicking the link “Add Note” under the name.
- Example Note:Catches POST from Smart Group Change Zap and gets the Id of the computer added and/or removed from the group, to get all the computer details and save to Google Sheet.
- Setup your trigger step. Choose Webhooks under Built-In Apps.
- Select Catch Hook.
- Continue pass the “Pick Off a Child Key” as there is nothing specific we need to select off the hook.
- Zapier will provide an URL to send requests to. This URL will need to be copied and pasted in your webhook settings in Jamf.
- Open up a new window to begin setup of Jamf webhook, leave this zap open as you will return to it.
Jamf Setup of Webhook
- After copying the URL from the zap. Open up a new window and login to your Jamf account.
- Click the cog in the top right corner and go to your settings.
- Under Global Management click on the Webhooks icon.
- Click “New” button.
- Add a Display Name.
- Check “Enabled”.
- Paste the URL from the previous zap to the Webhook URL input.
- Set Authentication Type to “None”
- Fill in your preferred connection and read timeout
- Set Content Type to “JSON”
- Select the Webhook event from the dropdown – Set to “SmartGroupComputerMembershipChange”
- Set up the target smart computer group. You can select a group or apply to all groups.
- Save and return to your Zapier window with your previous zap.
Catching Smart Group Membership Change Zap (continued)
- After completing setup of Jamf webhook. Click “Ok, I did this” to begin a test and pull in a test sample. Then return to your Jamf window and trigger the webhook. The webhook can be triggered in two ways.
- Trigger the webhook by going to Computers – > Search Inventory -> (Select a computer) -> Edit -> Update site to a new site that is in a different computer group and Save
- Trigger the webhook by going to Computers -> Smart Computer Groups – > (Select a Group) -> Update site to a new site that is in a different computer group and Save.
- If the event is triggered correctly you will see a test result/message like below:
- Next setup an action step. Select Code under Built-In Apps.
- Select “Run Javascript”
- Use the following Input Data Parameters
- eventName : Select “Event Name” from Field Options
- addedComputers: Select “Event Group Added Device Ids” from Field Options
- removedComputers: Select “Event Group Removed Device Ids” from Field Options
- In the code section. Copy and paste the following code:
** The highlighted url will be replaced by another url in a later zap.
var added = [];
var removed = [];
if(inputData.addedComputers) {
added = inputData.addedComputers.split(',');
}
if(inputData.removedComputers) {
removed = inputData.removedComputers.split(',');
}
var otherZapURL = "https://hooks.zapier.com/hooks/catch/3491337/wk7qh8/";
for(var i = 0; i< added.length; i++) {
var addedBody = JSON.stringify({
computer: added[i],
status: "added",
eventname:inputData.eventName
});
await fetch(otherZapURL, {method:'POST', body:addedBody});
}
for(var i = 0; i< removed.length; i++) {
var removedBody = JSON.stringify({
computer: removed[i],
status: "removed",
eventname:inputData.eventName
});
await fetch(otherZapURL, {method:'POST', body:removedBody});
}
return [{status: 'ok'}];
- This zap is done.
Saving Computer Details to Google Sheet
- Start a new zap.
- Add Note (optional) – Optionally it might be good to add some details about what you zap does. You can do this by clicking the link “Add Note” under the name.
- Example Note:Catches POST from Smart Group Change Zap and gets the Id of the computer added and/or removed from the group, to get all the computer details and save to Google Sheet.
- Setup your trigger step. Choose Webhooks under Built-In Apps.
- Select Catch Hook.
- Continue pass the “Pick Off a Child Key” as there is nothing specific we need to select off the hook.
- Zapier will provide an URL to send requests to. This URL will need to be copied and pasted in your previous zap in the code section where the highlighted url was listed.
- Setup an action step. Select Webhooks under “Built-In Apps”
- Select “GET” action type.
- Fill in the following input:
- URL : Copy and Paste https://kryptedjamf.jamfcloud.com/JSSResource/computers/id/(replace your kryptedjamf.jamfcloud.com with your role)
- Select “Computer” from field options
- See below as sample:
- URL : Copy and Paste https://kryptedjamf.jamfcloud.com/JSSResource/computers/id/(replace your kryptedjamf.jamfcloud.com with your role)
- Query String Params – leave blank
- Send As JSON – Select Yes
- JSON key – enter “json”
- Unflatten – Select Yes
- Basic Auth –separate your username and password with a pipe character
- i.e. USERNAME|PASSWORD
- Headers – leave blank
- Continue to through to Test Step and make sure data was received about the computer.
- If successful, continue to add a third action step by clicking the plus icon under you previous step and selection Action.
- Search for Google sheets in Search for Apps.
- Select Google Sheets and select the action type “Create Spreadsheet Row”.
- Connect your Google Account you used to create your Google sheet in the previous steps. See Google Sheets Setup section earlier in this document.
- Select Spreadsheet you set up under Spreadsheet input.
- Select the worksheet that has your columns names.
- After the worksheet is selected, each column will appear as an input option to map fields to. You will need to map each column to the appropriate field by selecting the field from the field options menu to the right of the input.
- After you’ve finished the mapping, select Continue to Test the step. If the test was successful, you should see your new record on your google sheet.
- Turn both of your zaps on and you are ready to automatically record all your smart group changes!
This was written for a specific use case, but because it’s useful for a number of apps and many of those can be hooked to other apps providing a nearly infinite number of use cases to link Jamf Pro Smart Group changes (one of the most valuable things that Jamf does) to other solutions!