Microsoft Teams notifications from MAU Caching Server

Back in February I wrote about Automating MAU Caching Server with Slack Notifications and it has been working great. Earlier this week a request was made on Github to add support for sending notifications to Microsoft Teams.

We don’t use Teams here at work but a quick search showed it supports messages via an incoming webhook, just like Slack, so I decided it give it a try. It didn’t take long to adjust the code and after realizing I could create a Teams workspace for free I got it tested in short order.

Paul Bowden merged my pull request so if you’d like to take advantage just grab version 2.6 of the MAUCacheAdmin script. If you are interested in the details read on.

There is only one section of code you need to configure to get the notifications working. Unlike Slack, I wasn’t able to find any documentation about customizing the name and icon used inside the script, so those will need to be customized inside Teams when creating the webhook.

Enable the notifications and enter your complete Teams Webhook URL. This is the only section you need to modify.

# Variables for Microsoft Teams Notifications
TEAMS_NOTIFY=false
TEAMS_WEBHOOK_URL="https://outlook.office.com/webhook/<COMPLETE URL HERE>"

The code that triggers the notification can be edited if you’d like to change formatting options like bolding or italicizing text. Teams also supports a post title that isn’t available for Slack.

TeamsNotify () {
# Send Alert to Teams Webhook in Global Variable when Package is Downloaded
	if [ $TEAMS_NOTIFY == true ]; then
		echo "New Package Detected: $PACKAGE"
		curl -H 'Content-type: application/json' -d '{"text":"New Package Downloaded: '"$PACKAGE"'"}' $TEAMS_WEBHOOK_URL
	fi
}

My previous post about Slack notifications contains a sample LaunchDaemon if you need it.

Let me know if you have have any questions or stop by the #microsoft-autoupdate channel in the MacAdmins Slack.

1 comment on “Microsoft Teams notifications from MAU Caching Server

  1. Pingback: Weekly News Summary for Admins — 2019-07-05 – Scripting OS X

Leave a Reply

Your email address will not be published. Required fields are marked *