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 appdata fieldWhat it does
ChannelchannelSlack (the default) or Microsoft Teams.
Webhook URLwebhook_urlThe channel's incoming webhook address. It must be https. Liquid works, so keep it in private data and use {{ slack_url }}.
Title (optional)titleA heading, like Order {{ order_number }} needs attention.
MessagemessageThe text, like Order {{ order_number }} failed to sync: {{ error }}.
Fail on bad response codefail_bad_statusStops the job if Slack or Teams returns an error. When it's off, a failure is only logged.
Response variableresponse_variableSaves {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 password

Anyone 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.

  1. API Request: Get Private Data, Key slack_sales, Response variable slack_res.

  2. Script: Read the sale

    var sale = JSON.parse($.default);
    $.sale = sale;
    $.slack_url = JSON.parse($.slack_res.body).slack_sales.trim();
  3. Script: Build the message

    $.is_large = $.sale.total_price >= 1000;
    $.note = "Receipt " + $.sale.receipt_number + " at store " + $.sale.store_id;
  4. If Condition: If the sale is large, Condition $.is_large === true.

  5. Send Notification: Send a Slack message, nested under THEN: Channel Slack, Webhook URL {{ slack_url }}, Title Big sale: {{ sale.total_price | currency: "AUD" }}, Message {{ note }}.

Example 2: Shout when a sync fails, then stop

Trigger: Scheduled.

  1. API Request: Get Private Data, Key orders_api, Response variable token_res.
  2. Script: Build the request, which sets $.headers and $.slack_url.
  3. REST Request: Get orders, Fail on bad response code off, Response variable orders_res.
  4. Script: Read the response: $.pull_failed = $.orders_res.status !== 200;
  5. If Condition: If the pull failed, Condition $.pull_failed === true. Under THEN:
    1. Send Notification: Send a Slack message, Message Order pull failed with status {{ orders_res.status }}.
    2. Stop Job: Stop with an error, Status Error, Message Order pull failed. See Stop Job.

← All Glue step guides


Did this page help you?