How to Send New Shopify Orders to Slack With a Webhook
webhooks nov 24, 2026

How to Send New Shopify Orders to Slack With a Webhook

Get a Slack alert for every new Shopify order using Shopify Flow or a free Cloudflare Worker relay — step-by-step setup, code included.

/blog/how-to-send-new-shopify-orders-to-slack-with-a-webhook

Header image: a new Shopify order, a signature check, and a Slack channel post. Graphic: Ctrl Alt Orion.

You can get a Slack message in a channel every time a new order lands in Shopify. Shopify will not post that message by itself. Its order webhook sends raw JSON, and Slack’s incoming webhook expects a different JSON shape, so something in the middle has to translate. That middle step is either Shopify Flow, on the Grow plan and above, or a small Cloudflare Worker on the free tier. This guide walks through both, then covers registering the webhook, testing it, and keeping the URL from being abused.

If “webhook” is a new word, read what a webhook is and how it connects tools without Zapier fees first. The short version: one app pushes data to a URL you control when something happens, with no polling and no per-task fee. If “payload” and “endpoint” are the fuzzy part, the plain-English explainer on APIs covers the vocabulary used below.

Step 1: Create a Slack app and get a webhook URL

Slack’s incoming webhooks belong to a custom Slack app. You build the app once.

  1. Open api.slack.com/apps and click Create New App. Select Pick features, then Continue. Name it something like “Shopify Order Alerts” and choose the workspace.
  2. Open Incoming Webhooks and switch Activate Incoming Webhooks on.
  3. Click Add New Webhook to Workspace.
  4. Pick the channel that should receive order alerts, such as #orders or #sales-alerts, then click Authorize. A private channel only appears here if you are already in it.
  5. Copy the URL under Webhook URLs for Your Workspace. Slack’s example looks like https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX.

Treat that URL like a password. Anyone who has it can post to the channel, and Slack revokes webhook URLs it finds in public repos. One app and one URL is enough for this setup.

Step 2: Understand why you need a relay

Shopify’s webhook describes the order: customer, line items, totals, shipping. Slack’s webhook wants a small JSON object, roughly:

{
  "text": "New order #1001 — $84.50 from Jane Doe"
}

Shopify does not send that shape. Slack answers a malformed body with invalid_payload and does not post the message. The order has to pass through a translator that:

  1. Receives Shopify’s raw JSON.
  2. Checks the signature so a stranger cannot post fake orders into the channel.
  3. Pulls out the fields you care about.
  4. Posts those fields to the Slack URL in Slack’s format.

Two realistic translators, depending on the Shopify plan:

Shopify Flow on Grow and above posts straight to Slack; a Cloudflare Worker on any plan checks the HMAC signature and then posts

Shopify Flow skips the extra server. A Worker is the route on Basic, and the route that checks Shopify’s signature itself. Graphic: Ctrl Alt Orion.

advertisement

Option A: Shopify Flow (no code, if the plan includes the action)

Shopify Flow is a free app on Basic, Grow, Advanced, and Plus. Install it from the Shopify App Store, then open it from the admin. Most of Flow is available on every one of those plans. The Send HTTP request action, which is what posts to Slack, is not. Shopify’s action reference limits it to the Plus, Advanced, or Grow plans. A Basic store can still automate inside Shopify. It cannot call Slack from Flow. Use the Worker below instead.

On an eligible plan:

  1. In Flow, click Create workflow.
  2. Choose the Order created trigger. That fires when a customer places an order, and when a draft order is marked paid and becomes an order.
  3. Add the Send HTTP request action.
  4. Configure it:
    • HTTP method: POST
    • URL: the Slack webhook URL. Prefer a Flow secret ({{ secrets.slack_webhook }}) so the URL is redacted from workflow logs. Staff need the Manage connections and secrets permission to create a secret and to turn on a workflow that uses one.
    • Headers: key Content-Type, value application/json
    • Body: Slack’s JSON, with Flow’s Liquid variables. Flow reads the GraphQL Admin API, so the names are camel case. order.totalPrice is not a field. The total lives on order.totalPriceSet:
{
  "text": "New order {{ order.name }} — {{ order.totalPriceSet.shopMoney.amount }} {{ order.totalPriceSet.shopMoney.currencyCode }} from {{ order.customer.displayName }}"
}
  1. On On client error (4XX response) and On server error (5XX or 429 response), choose Retry if you want Flow to keep trying. That retry window is up to 24 hours. It is a setting, not the default behavior of every workflow.
  2. Turn the workflow on. Place a test order (see Step 4) and confirm the message lands in Slack.

{{ order.name }} is the order name shown in the admin, such as #1001. displayName is the customer’s name, falling back to email or phone when the name is empty. A guest checkout can leave order.customer empty, so the name slot may render blank. A quotation mark inside a customer name will also break hand-typed JSON. Use Add a variable under the body field if you want Flow to insert the path for you, and keep the message to fields that do not contain quotes.

Flow waits a maximum of 30 seconds for a response code. It treats 2xx and 3xx as success. Slack returns 200 when the message posts, so that match is fine. The advantage is that nothing extra is hosted, and Flow is already inside Shopify, so you are not verifying a signature yourself. The disadvantage is the plan gate, and templating gets fiddly once you want line items or conditions.

Option B: A Cloudflare Worker (free tier)

A Worker is the route when Flow’s HTTP action is missing, and it is also the route when you want the signature check in your own code. The Workers Free plan includes 100,000 requests a day, resetting at midnight UTC. Order alerts will not approach that. The same plan caps CPU time at 10 milliseconds per request. Waiting on the Slack fetch does not count toward CPU time, and the work below is a signature, a JSON parse, and one outbound POST.

Set up the Worker

  1. Create a free Cloudflare account and open Workers & Pages.
  2. Create a Worker and name it something like shopify-slack-relay.
  3. Replace the starter script with the code below.
  4. Add SLACK_WEBHOOK_URL and SHOPIFY_WEBHOOK_SECRET as encrypted secrets. Do not paste them into the script. The dashboard stores them with the Worker’s variables; wrangler secret put does the same from a terminal.
  5. Deploy, and copy the *.workers.dev URL.

The code

export default {
  async fetch(request, env) {
    if (request.method !== "POST") {
      return new Response("Method not allowed", { status: 405 });
    }

    const raw = await request.text();
    const header = request.headers.get("X-Shopify-Hmac-SHA256");
    if (!header || !env.SHOPIFY_WEBHOOK_SECRET || !env.SLACK_WEBHOOK_URL) {
      return new Response("Invalid signature", { status: 401 });
    }

    const key = await crypto.subtle.importKey(
      "raw",
      new TextEncoder().encode(env.SHOPIFY_WEBHOOK_SECRET),
      { name: "HMAC", hash: "SHA-256" },
      false,
      ["sign"]
    );
    const mac = await crypto.subtle.sign(
      "HMAC",
      key,
      new TextEncoder().encode(raw)
    );
    const digest = btoa(String.fromCharCode(...new Uint8Array(mac)));
    if (!timingSafeEqual(digest, header)) {
      return new Response("Invalid signature", { status: 401 });
    }

    let order;
    try {
      order = JSON.parse(raw);
    } catch {
      return new Response("Bad payload", { status: 400 });
    }

    const items = (order.line_items || [])
      .map((item) => `${item.quantity}x ${item.title}`)
      .join(", ");
    const customer = order.customer
      ? `${order.customer.first_name || ""} ${order.customer.last_name || ""}`.trim()
      : "Guest";

    const message = {
      text: `New order ${order.name}`,
      blocks: [
        {
          type: "section",
          text: {
            type: "mrkdwn",
            text: `*New order ${order.name}*\n*Total:* $${Number(order.total_price).toFixed(2)} ${order.currency || ""}\n*Customer:* ${customer || "Guest"}\n*Items:* ${items}`
          }
        }
      ]
    };

    let slackRes;
    try {
      slackRes = await fetch(env.SLACK_WEBHOOK_URL, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(message)
      });
    } catch {
      return new Response("Slack error", { status: 502 });
    }

    return new Response(slackRes.ok ? "OK" : "Slack error", {
      status: slackRes.ok ? 200 : 502
    });
  }
};

function timingSafeEqual(a, b) {
  if (a.length !== b.length) return false;
  let out = 0;
  for (let i = 0; i < a.length; i++) out |= a.charCodeAt(i) ^ b.charCodeAt(i);
  return out === 0;
}

The header Shopify sends is X-Shopify-Hmac-SHA256: a base64 HMAC-SHA256 of the raw body. The code recomputes that digest and rejects a mismatch. Compute it from the raw text, before JSON.parse. The secret has to be the one that signed this subscription. For a webhook you create under Settings > Notifications > Webhooks, that is the store-specific signing value on that page. Shopify’s help center describes it as an ID of letters and numbers unique to the store. It is not the API secret of a custom app. App subscriptions, created in an app config or with the Admin API, are signed with the app’s client secret instead, which is what Shopify’s developer docs tell you to use for those deliveries.

Admin webhooks send the order as REST-shaped JSON: name, total_price, currency, line_items, customer. That is what the Worker reads. Flow’s Liquid names above are the GraphQL names, and they are a different shape. Do not mix the two.

Step 3: Register the webhook in Shopify

Skip this step if you used Flow. Flow’s Order created trigger runs inside Shopify and does not need a notification webhook.

For the Worker, follow Shopify’s admin webhook steps:

  1. In the Shopify admin, go to Settings > Notifications.
  2. Click Webhooks.
  3. Click Create webhook.
  4. Set:
    • Event: Order creation. You cannot change the event after saving. Order payment and Order update are different events and will either miss new orders or fire again on later edits.
    • Format: JSON
    • URL: the Worker’s https://shopify-slack-relay.your-subdomain.workers.dev address
    • Webhook API version: the latest dated version in the menu, not Unstable, so the field names stay put
  5. Click Save.

Shopify will not deliver to localhost, to a URL ending in internal, to the store’s own domain, or to a myshopify.com address. A workers.dev URL is outside that list.

Copy the signing ID from the Webhooks page into the Worker’s SHOPIFY_WEBHOOK_SECRET secret, then redeploy or save the secret before the first real order. Rotating that value breaks every webhook on the page that uses it, so rotate it when you suspect a leak, not as a routine click.

Step 4: Test end to end

  1. On the Webhooks page, open the row menu and click Send test. Shopify’s help center describes this as a check that the event reaches the URL. The body is a sample, so treat it as a smoke test. A sample that fails the signature check means the secret is wrong. A sample that reaches Slack means the relay is wired.
  2. Then place an order. Shopify’s current test-order help covers two clean options: a payment gateway in test mode (Shopify Payments test mode, or the Test payment gateway), or a real order you immediately cancel and refund. Test mode stops real customers from checking out until you turn it off. A real charge can leave payment-provider fees behind after the refund. Turn test mode off as soon as the Slack message shows up.
  3. The formatted message should land in the channel within a second or two.
  4. If nothing arrives, open the Worker’s logs in the Cloudflare dashboard and send the test notification again. A test-mode order is the confirmation that a real orders/create payload works. The test button alone is not that confirmation.

Handling retries and duplicates

Shopify retries a delivery when your endpoint returns anything outside the 200 range, including a redirect, or when it does not answer. Shopify’s developer docs set that at 8 retries over the next 4 hours, with a one-second connection timeout and a five-second limit for the whole request. The Worker above waits for Slack before it answers, which is what you want — a 200 before Slack accepts the message would drop the alert — and Slack normally answers well inside five seconds. A 502 while Slack is down asks Shopify to retry, so expect a possible duplicate once Slack recovers.

The admin help center adds two practical consequences for a webhook created on the Notifications page. A destination that repeatedly returns a non-200 is deleted from the admin. The failure email to the store owner is sent only when an app or a custom app created the webhook, not when you created it by hand. A broken Worker can disappear from the Webhooks list without a warning email. Fix it or delete it. Do not leave it returning errors.

Two defenses, in order:

  • Return 200 only after Slack accepts the message. That is what the code does. A Slack outage produces retries, which is the right failure.
  • Ignore a delivery you have already posted. Each delivery carries X-Shopify-Webhook-Id. Store that ID for a few hours (Cloudflare KV is enough) and skip the Slack post when you have seen it. The same merchant action can also arrive twice under two subscriptions; those share X-Shopify-Event-Id and have different webhook IDs. For a small store, a duplicate message is a nuisance. Add the ID check when it stops being one.

Keeping it secure

  • Never paste the Slack webhook URL into a repo, a screenshot, or Slack itself. If it leaks, revoke it in the Slack app settings and add a new webhook to the channel.
  • Keep the HMAC check. Deleting it to “get a message through” leaves the Worker URL open to anyone who can guess or find it.
  • Use the signing secret that matches how the webhook was created. The Notifications page secret for a webhook you added there. The app client secret only for subscriptions that app created.
  • Restrict the Worker to POST. The code returns 405 for anything else.
  • Rotate both secrets when someone with access leaves, or when a laptop that held them is lost. Regenerating the Shopify signing value and the Slack URL each takes under a minute, and then every integration using the old Shopify value has to be updated.

Failure modes worth knowing in advance

  • Posting Shopify’s JSON straight at Slack. Slack returns invalid_payload. That is the usual first failure, and it is why the relay exists.
  • Using a webhook URL copied from a tutorial. Each workspace gets its own. A copied URL posts into someone else’s channel, or nowhere.
  • Skipping X-Shopify-Hmac-SHA256. The endpoint then accepts forged orders.
  • Using the app API secret for an admin webhook, or the other way around. The signature will never match, and every delivery returns 401 until the secret is the one that signed it.
  • Subscribing to the wrong event. Order creation is the new-order alert. Order payment and Order update fire on different moments.
  • Leaving the API version on Unstable. Field names can move. Pick the latest dated version in the dropdown.
  • Putting the Slack URL in the Worker source. Use an encrypted secret. The same idea applies in Flow: store the URL as a secret so run logs do not keep it.
  • A Worker that keeps returning 500. Shopify retries, then removes the admin webhook, and does not email you about a webhook you created by hand.

Sources

9 refs
  1. Shopify Help: Creating webhookshelp.shopify.com
  2. Shopify Help: Shopify Flow, including which plans include Send HTTP requesthelp.shopify.com
  3. Shopify Help: Send HTTP requesthelp.shopify.com
  4. Shopify Help: Order created triggerhelp.shopify.com
  5. Shopify Help: Liquid variables in Flowhelp.shopify.com
  6. Shopify.dev: Verify webhook deliveriesshopify.dev
  7. Shopify Help: Processing a test orderhelp.shopify.com
  8. Slack: Sending messages using incoming webhooksdocs.slack.dev
  9. Cloudflare Workers: Limitsdevelopers.cloudflare.com

← All articles

comments

loading comments…

^ consulting ⌥ building ⌘ shipping