Send Notification step
Post a message to Slack or Microsoft Teams from a Glue job.
The Send Notification step posts a message to a Slack channel or a Microsoft Teams channel through an incoming webhook. Use it to tell your team about big sales, failed syncs or anything else worth a heads-up.
Set it up
| In the app | data field | What it does |
|---|---|---|
| Channel | channel | Slack (the default) or Microsoft Teams. |
| Webhook URL | webhook_url | The channel's incoming webhook address. It must be https. Liquid works, so keep it in private data and use {{ slack_url }}. |
| Title (optional) | title | A heading, like Order {{ order_number }} needs attention. |
| Message | message | The text, like Order {{ order_number }} failed to sync: {{ error }}. |
| Fail on bad response code | fail_bad_status | Stops the job if Slack or Teams returns an error. When it's off, a failure is only logged. |
| Response variable | response_variable | Saves {status, ok}. |
In Slack, the title shows in bold above the message. In Teams, the message is sent as a card with the title as its heading.
Treat the webhook URL like a passwordAnyone with the URL can post to your channel. Store it in private data rather than typing it into the step. The editor keeps it hidden until you select Show.
How it behaves
- Notifications usually shouldn't stop a job. Leave Fail on bad response code off unless the message is the whole point of the job.
- Retries skip it at the top level. A top-level notification that was already sent isn't sent again when the job is retried. Inside an If Condition or Loop it is.
Example 1: Tell the team about a big sale
Trigger: System Hook, Create Sale.
-
API Request: Get Private Data, Key
slack_sales, Response variableslack_res. -
Script: Read the sale
var sale = JSON.parse($.default); $.sale = sale; $.slack_url = JSON.parse($.slack_res.body).slack_sales.trim(); -
Script: Build the message
$.is_large = $.sale.total_price >= 1000; $.note = "Receipt " + $.sale.receipt_number + " at store " + $.sale.store_id; -
If Condition: If the sale is large, Condition
$.is_large === true. -
Send Notification: Send a Slack message, nested under THEN: Channel Slack, Webhook URL
{{ slack_url }}, TitleBig sale: {{ sale.total_price | currency: "AUD" }}, Message{{ note }}.
Example 2: Shout when a sync fails, then stop
Trigger: Scheduled.
- API Request: Get Private Data, Key
orders_api, Response variabletoken_res. - Script: Build the request, which sets
$.headersand$.slack_url. - REST Request: Get orders, Fail on bad response code off, Response variable
orders_res. - Script: Read the response:
$.pull_failed = $.orders_res.status !== 200; - If Condition: If the pull failed, Condition
$.pull_failed === true. Under THEN:- Send Notification: Send a Slack message, Message
Order pull failed with status {{ orders_res.status }}. - Stop Job: Stop with an error, Status Error, Message
Order pull failed. See Stop Job.
- Send Notification: Send a Slack message, Message
Updated about 23 hours ago
