Anyone have any experience using Jamf webhooks in conjunction with Power Automate (flow)?

dmitchell
Contributor

I am trying to use Jamf webhooks to post to Slack and MS Teams. Basically I have the webhook post to my flow URL, which then goes to a Slack post with whatever I data I want from the response. All I get back to Slack is est Webhook1581022285529151SmartGroupComputerMembershipChange

But I am telling it to post the computer name, serial, and model. I know there is probably something I am missing and I know Slack is weird in the way it parses info. Any ideas?

8 REPLIES 8

nelsoni
Contributor III

I literally just got done making this work using this very method, I found that you need to add additional API calls back to jamf to fill in the missing info for the smartgroup Webhook.

To clarify, I attempted the same thing you did and researched that you need to perform more actions to fill in the webhook. I have not actually gotten the smartgroup webhook to work, but have the computer added, DEP added and computer inventory webhook working using power automate.

dmitchell
Contributor

@nelsoni The initial response should contain the jssID so I should be able to at least grab that and use the Jamf API to grab the info I want about the machine?

nelsoni
Contributor III

From what I read that should be all you need to do. as to how to add that to your flow I do not know. I would assume you just add an additional HTTP action once the webhook comes in to call back to your Jamf instance and then once you have the info, trigger the final HTTP step in your flow.

geoffreykobrien
Contributor

Did you ever get this working? I can't even get jamf to post to the "When a HTTP request is received" but can see the data when I use https://webhook.site

nelsoni
Contributor III

I have this fully working with three different smart group webhooks calling to Power automate, parsing the received JSON and sending an HTTP action to a teams channel

Edit: I checked my setup and remembered that the webhook URL that power automate provides has incorrect characters within it. you will need to remove each "%2F" in the URL with "/" and then it should work.

geoffreykobrien
Contributor

removed as I was testing with the wrong event, it's working now, thanks for your help!

nelsoni
Contributor III

Wanted to post an update,

I have been able to make a script that will post a fully customizable Adaptive card to teams.

Here is the template for it

#!/bin/sh   
# Get the serial number
SerialNumber=$(ioreg -c "IOPlatformExpertDevice" | awk -F '"' '/IOPlatformSerialNumber/ {print $4}')

#get IP address of machine
IP_ADDR=$(curl -s ifconfig.co)

# get machine name
MachineID=$(hostname)

############################
# Enter desired data below #
############################

# Webhook URLs 
# Channel name 
WEBHOOK_URL="WEBHOOK URL goes here"

# Post Title
TITLE="Test Post"

# Post Text
# Steve Jobs Deal With It  ![Deal with it](https://media.giphy.com/media/TfelnmQ8VU3K/giphy.gif)
# AltImageText="Alt Image Text Here"
# ImageURL="\n
![$AltImageText](image_url_here)"
TextToPost="Just a test post."

IMAGE="https://media.giphy.com/media/TfelnmQ8VU3K/giphy.gif"

# Convert formating.
JSON='{
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "version": "1.3",
            "content": {
                "type": "AdaptiveCard",
                "body": [
                    {
            "type": "TextBlock",
            "size": "large",
            "weight": "Bolder",
            "text": "'"$TITLE"'"
        },
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "default",
            "text": "'"$TextToPost"'",
            "wrap": true
        },
        {
            "type": "FactSet",
            "facts": [
                {
                    "title": "Serial Number:",
                    "value": "'"$SerialNumber"'"
                },
                {
                    "title": "IP Address:",
                    "value": "'"$IP_ADDR"'"
                },
                {
                    "title": "Mac Address:",
                    "value": "68:5B:35:BB:A1:B0"
                },
                {
                    "title": "Where you at:",
                    "value": "Dempsey"
                }
            ]
        },
        {
            "type": "Image",
            "url": "'"$IMAGE"'"
        }
    ],
    "actions": [
        {
            "type": "Action.OpenUrl",
            "title": "View in The Jamf",
            "url": "Jamf URL"
                    }
                ]
            }
        }
    ]
}'

# Post to Microsoft Teams.
curl -H "Content-Type: application/json" -d "${JSON}" "${WEBHOOK_URL}"

exit 0

I had great experience with this script, but also took this to some sys admins colleagues of mine and reworked it more to fit our environmment.

It made it possible for me to make some more variables and apply them across the board for notifications.