Send Slack messages from a Jamf Pro policy with an incoming webhook

A small Jamf Pro script that posts a formatted Slack message from any policy using an incoming webhook: a title, two message lines and a coloured status bar.

jamf-pro-slack-notification.sh sends a formatted Slack message from a Jamf Pro policy. It is part of Mac Admins Toolkit. A typical use is to add it at the start and end of a provisioning workflow, so a channel sees “Workflow Started” and “Workflow Completed” for each Mac.

The message has a title, two free-text lines and a coloured bar down the side. The first line can insert the Mac’s serial number for you.

Requirements

  • A Jamf Pro policy to run it
  • A Slack app with an incoming webhook
  • Tools that ship with macOS: /bin/bash, /usr/bin/curl, /usr/sbin/ioreg and /usr/bin/awk

There are no third-party dependencies. The script runs unattended and does not need a logged-in user. It is developed with macOS 15, macOS 26 and macOS 27 in mind, and has not been validated on every release.

Slack setup

Follow Slack’s incoming webhook guide to create a Slack app, enable incoming webhooks and choose the channel.

Slack’s documentation is clear that an app’s incoming webhook cannot override the channel, username or icon. Those always come from the Slack app’s configuration. So the destination channel is decided when you create the webhook, not by the script.

Jamf Pro parameters

Upload the script to Jamf Pro and label the parameters on the script’s Options tab, so whoever builds the policy sees field names instead of “Parameter 4”.

Parameter Label Default Description
4 Slack Title Provisioning The top line of the message
5 Message Line 1 SERIALNUMBER Free text. Type SERIALNUMBER to insert the Mac’s serial number
6 Slack Color #008000 The side bar colour, as a #RRGGBB hex value
7 Message Line 2 Workflow Started Free text
8 Slack Webhook URL None Slack or GovSlack incoming webhook URL

An empty parameter uses its default.

The colour must be a hex value. The script rejects anything else. Pick values that match your own convention, for example green for success, orange for a warning and red for a failure.

How the message is built

The body uses Block Kit. The two message lines are a section block nested inside an attachments entry, so that the entry’s color field draws the side bar. Slack’s migration guide says color is the one attachment field without a block alternative, and suggests placing blocks inside an attachment if you want to keep the bar. That is what the script does.

Quotes, backslashes, tabs and line breaks in the parameter values are escaped before the JSON is sent.

Exit codes

  • 0: Slack accepted the message and returned ok.
  • 1: a setting was invalid, the network request failed, or Slack returned something unexpected.

The request has a 10-second connection timeout and a 30-second overall timeout.

Treat the webhook URL as a secret

Slack says the webhook URL contains a secret, and that it actively searches out and revokes leaked secrets.

  • Supply the URL at runtime through parameter 8, and leave HARDCODED_SLACK_WEBHOOK_URL empty in anything you commit to Git.
  • Restrict who can see the Jamf script and policy. Jamf parameters are not a secret-management system.
  • Never copy the URL into logs, tickets or documentation.
  • If it is exposed, revoke or rotate it in Slack. Removing it from the latest file does not remove it from Git history.

Get it

The script and README are in Jamf-Pro-Slack-Notifications. Test it with a non-production Slack channel before you add it to a production policy.