DEV Community

Munavar Sahad
Munavar Sahad

Posted on

Sending Shopify order updates to WhatsApp with n8n and the Cloud API

For many stores in the UAE, "where is my order?" arrives on WhatsApp, not email. The fix is not a chatbot. It is sending the right utility message at the right moment, automatically, and keeping a person on the other end for real questions.

This is the pattern I use: Shopify webhook -> n8n -> WhatsApp Cloud API, with verification, logging and retries. No magic, just plumbing that does not break at 2 AM.

What you need first

  • A Shopify store where you can create webhooks (Settings -> Notifications -> Webhooks, or via the Admin API).
  • An n8n instance (cloud or self-hosted).
  • A WhatsApp Business Platform account with a phone number ID and a permanent access token.
  • At least one approved utility template, for example order_confirmed with variables for the customer name and order number.
  • Opt-in. Meta says you can only message WhatsApp users who have opted in to hear from you. Collect it at checkout and store it on the customer or order.

Step 1: Receive the webhook in n8n

Create a workflow that starts with a Webhook node (POST). In Shopify, point the orders/create topic at that URL. Add orders/fulfilled later for shipping updates.

Step 2: Verify it really came from Shopify

Shopify signs every webhook with an X-Shopify-Hmac-Sha256 header: a base64 HMAC-SHA256 of the raw request body, using your app's client secret. Verify it before you do anything else. In an n8n Code node:

const crypto = require('crypto');
const secret = $env.SHOPIFY_WEBHOOK_SECRET;
// Requires "Raw body" enabled on the Webhook node
const raw = Buffer.from($input.first().binary.data.data, 'base64');
const expected = crypto.createHmac('sha256', secret).update(raw).digest('base64');
const received = $input.first().json.headers['x-shopify-hmac-sha256'];
if (!received || !crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(received))) {
  throw new Error('Invalid Shopify HMAC');
}
return $input.all();
Enter fullscreen mode Exit fullscreen mode

Enable "Raw body" on the Webhook node so you hash the exact bytes Shopify sent. Re-serialised JSON will not match the signature.

Step 3: Check opt-in and normalise the phone number

Skip the order if the customer has not opted in. Then normalise the number to E.164 without the plus sign, for example 9715XXXXXXXX for a UAE mobile. Numbers typed as 05X XXX XXXX are the most common reason sends fail.

Step 4: Send the template through the Cloud API

Use an HTTP Request node:

  • Method: POST
  • URL: https://graph.facebook.com/<api-version>/<PHONE_NUMBER_ID>/messages
  • Header: Authorization: Bearer <token> (store it as an n8n credential, never in the workflow)
  • Body:
{
  "messaging_product": "whatsapp",
  "to": "{{ $json.phone }}",
  "type": "template",
  "template": {
    "name": "order_confirmed",
    "language": { "code": "en" },
    "components": [
      {
        "type": "body",
        "parameters": [
          { "type": "text", "text": "{{ $json.first_name }}" },
          { "type": "text", "text": "{{ $json.order_name }}" }
        ]
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

If you serve Arabic-speaking customers, create an Arabic version of the same template and choose the language code from the customer's locale.

Step 5: Log every send, retry failures

Write the order ID, template name, the message ID the API returns, and the status into a table (Postgres, Google Sheets, Airtable, whatever you already use). Turn on "Retry on fail" on the HTTP node with a short backoff, and send anything that still fails to an error workflow that alerts a human.

Then subscribe to the WhatsApp status webhooks (sent, delivered, read, failed) and update the same row. That table becomes your answer to "did the customer get the message?"

Pricing notes that change the design

Meta's WhatsApp Business Platform pricing page is worth reading before you build:

  • Since 1 July 2025, Meta charges per delivered message, by category (marketing, utility, authentication, service) and by the recipient's country code. Messages from customers to you are not charged.
  • From 1 October 2026, service messages and utility messages sent inside an open customer service window are charged again, and each business phone number gets 1,000 free service messages per month.
  • Replies from a Click to WhatsApp ad open a free entry point window of up to 7 days.

Practical effect: keep utility templates short and factual, do not send three messages where one will do, and do not dress up marketing as utility. Meta decides the category, and it will recategorise.

What I would automate first

  1. Order confirmed
  2. Cash on delivery confirmation (a big one in the UAE)
  3. Shipped, with the tracking link
  4. Out for delivery
  5. A handoff to a real inbox for anything the customer replies with

Marketing messages, such as abandoned cart reminders, come after these are stable, and only for customers who opted in.


I write about this in more depth, including the UAE-specific pricing and opt-in rules, in WhatsApp automation for UAE eCommerce stores: a practical setup. If you want this built for your store, see WhatsApp automation in Dubai or my n8n automation work.

Top comments (0)