Mark it shipped when the warehouse says so, partial shipments with Zapier, HubSpot and WhatsApp

Mark it shipped when the warehouse says so, partial shipments with Zapier, HubSpot and WhatsApp

This article was drafted with AI help and reviewed by the author. A lot of stores send the "your order has shipped" message when the order is released to the warehouse. That is the moment the store stops waiting. It is not the moment a box leaves the building. The warehouse management system (WMS) is the only system that knows what really shipped. It knows which lines went out, how many boxes there were, and which item was not on the shelf. So the shipment confirmation from the WMS should drive two things: the status your team sees in HubSpot, and the message your customer gets on WhatsApp. This post walks through a Zap that does that. It focuses on the cases that break simple flows: partial shipments, several packages, and short picks. The JavaScript is an illustrative Code by Zapier step. It was syntax-checked and run locally against sample payloads. It has not been run in a live Zap or production-tested. The problem A simple Zap looks like this. Shipment webhook arrives. Find the deal. Set it to "Shipped". Send the customer a tracking message. That works for an order with one line and one box. It goes wrong in three common cases. Partial shipment. Two of three items ship today. The third ships next week. The simple Zap tells the customer the order shipped. A week later they get a second "your order shipped" message and wonder what happened. Several packages. The WMS sends one confirmation with three tracking numbers. A Zap that loops per package sends three WhatsApp messages in a row. Short pick. The picker could not find one unit. The warehouse closes that line short. The customer never hears about it until they open the box. Each case needs the Zap to know more than "a shipment happened". It needs to know where the whole order stands after this shipment. Agree on the payload first Before you build anything, ask what the WMS actually sends. The fields below are an example contract, not a specific vendor's format. Map your own fields onto the same ideas. ``json { "order_id": "1001", "shipment_id": "SH-88213", "shipped_at": "2026-11-20T10:42:00Z", "lines": [ { "line_id": "1", "sku": "MUG-RED", "ordered_qty": 3, "shipped_qty_to_date": 2, "shipped_qty_this_shipment": 2, "cancelled_qty": 0 }, { "line_id": "2", "sku": "COASTER-4", "ordered_qty": 1, "shipped_qty_to_date": 1, "shipped_qty_this_shipment": 1, "cancelled_qty": 0 } ], "packages": [ { "tracking_number": "1Z999AA10123456784", "carrier": "UPS" }, { "tracking_number": "1Z999AA10123456795", "carrier": "UPS" } ] } `` Two fields do most of the work. shipped_qty_to_date is the running total for the line. It lets the Zap decide if the order is complete without remembering earlier shipments. cancelled_qty is what the warehouse closed and will not ship. A short pick shows up here. Some WMS platforms only send what shipped in this one shipment. If yours does, keep a running total per order line in a Zapier Table first, and feed the totals into the Code step. Do not guess completeness from a single shipment. The Zap, step by step Webhooks by Zapier, Catch Raw Hook. Official Zapier docs say Catch Raw Hook gives you the unparsed body and the headers, up to 2 MB. You need the raw body to check a signature. Code by Zapier. Verify the signature, check the quantities add up, and work out the order status. Code below. Filter. Continue only when accepted is yes. Duplicate check. Look up dedupe_key in a Zapier Table. If a row exists, stop. HubSpot. Find the deal by your order id property and update the fulfillment properties. Paths. Pick a WhatsApp template based on whatsapp_template, and send it only when should_notify is yes. Zapier Table. Write the dedupe_key row with the HubSpot and WhatsApp results. There is one detail about step 1 that changes how you think about failures. Official docs say Zapier answers the webhook with a 200 response. So the WMS sees success as soon as Zapier receives the request. If step 5 fails later, the WMS will not resend. Your Zap History and an error handler are now the retry queue. Treat them that way. The Code step Official docs say Code by Zapier runs Node.js 22, reads mapped fields from inputData, and returns an object. The standard Node.js library is available, so crypto can check an HMAC signature. Map these Input Data keys: rawBody from the raw hook body, signature from the signature header your WMS sends, and secret from a value only you know. The header name and the signing scheme are vendor-specific. Check your WMS docs. The sample assumes a hex SHA-256 HMAC of the raw body, with an optional sha256= prefix. ```javascript const crypto = require("crypto") function verifySignature(rawBody, signatureHeader, secret) { if (!secret) throw new Error("WMSWEBHOOKSECRET is not set") const expected = crypto.createHmac("sha256", secret).update(rawBody, "utf8").digest("hex") const given = String(signatureHeader || "").replace(/^sha256=/, "") const a = Buffer.from(expected, "hex") const b = Buffer.from(given, "hex") return a.length === b.length && crypto.timingSafeEqual(a, b) } function planShipmentUpdate(inputData) { const raw = String(inputData.rawBody || "") if (!verifySignature(raw, inputData.signature, inputData.secret)) { return { accepted: "no", reason: "bad_signature" } } const msg = JSON.parse(raw) const lines = Array.isArray(msg.lines) ? msg.lines : [] const packages = Array.isArray(msg.packages) ? msg.packages : [] if (!msg.shipmentid || !msg.orderid || lines.length === 0) { throw new Error("Shipment confirmation is missing shipmentid, orderid or lines") } let ordered = 0 let shippedTotal = 0 let shippedNow = 0 let closedShort = 0 const shortSkus = [] for (const line of lines) { const o = Number(line.orderedqty) const s = Number(line.shippedqtytodate) const n = Number(line.shippedqtythisshipment) const c = Number(line.cancelledqty || 0) if (![o, s, n, c].every(Number.isInteger) || s > o || n > s || s + c > o) { throw new Error(Line ${line.line_id} has quantities that do not add up) } ordered += o shippedTotal += s shippedNow += n closedShort += c if (c > 0) shortSkus.push(line.sku) } const open = ordered - shippedTotal - closedShort let status if (open > 0) status = "partiallyshipped" else if (closedShort > 0) status = "shippedwithshort" else status = "shippedcomplete" const tracking = packages .map(p => String(p.tracking_number || "").trim()) .filter(Boolean) let template = "ordershipped" if (status === "partiallyshipped") template = "orderpartiallyshipped" if (status === "shippedwithshort") template = "ordershippeditem_unavailable" return { accepted: "yes", dedupekey: ${msg.order_id}:${msg.shipment_id}, orderid: String(msg.orderid), shipmentid: String(msg.shipmentid), fulfillmentstatus: status, unitsordered: ordered, unitsshippedtodate: shippedTotal, unitsinthisshipment: shippedNow, unitsstillopen: open, unitsclosedshort: closedShort, shortskus: shortSkus.join(", "), packagecount: packages.length, trackingnumbers: tracking.join(", "), shouldnotify: shippedNow > 0 || closedShort > 0 ? "yes" : "no", whatsapptemplate: template } } return planShipmentUpdate(inputData) ``` A few choices in there are deliberate. The step throws when quantities do not add up. A line that shipped more than was ordered is a data problem. It should show up as an errored run, not as a cheerful message to the customer. All tracking numbers come back as one comma-separated field. One shipment means one message, however many boxes there are. If you return an array of objects instead, official docs say later steps run once per object, which is exactly the three-messages-in-a-row problem. dedupe_key is order plus shipment. It is not the tracking number. A carrier can reuse a label, and one shipment can have several labels. Duplicates without Storage by Zapier Storage by Zapier looks like the obvious place to remember which shipments you already handled. Its official limits make it a poor fit here. Keys can be up to 32 characters. One account holds up to 500 keys. Keys are deleted after two months of inactivity. A busy store passes 500 shipments quickly, and an order id plus a shipment id can be longer than 32 characters. A Zapier Table, a Google Sheet, or a small database row per dedupe_key works better. Look it up right after the Filter. If you find it, stop. Write it after the HubSpot update, with a column for the WhatsApp result. What to write in HubSpot Create a few custom deal properties and own them from this Zap only. For example: fulfillment_status: a dropdown with released, partially_shipped, shipped_with_short, shipped_complete units_shipped_to_date and units_still_open: numbers tracking_numbers and last_shipment_id: text short_skus: text, so the support team can see what will not arrive The release step can set released. Only this Zap can move the deal past it. That one rule stops the most visible bug, a tracking email for an order still on the shelf. Update HubSpot before you message the customer. If the WhatsApp send fails, the deal is still correct and someone can follow up. If the HubSpot update fails, stop. A customer who replies "where is the rest of my order?" should reach an agent who sees the same picture. What to say on WhatsApp Business-initiated WhatsApp messages outside a customer service window need an approved template. Shipping updates fit the utility category. Official Meta guidelines list order updates, tracking details, and backordered items as utility examples. Official guidelines also say a template that mixes an order update with a promotion counts as marketing. So keep the discount code out of the shipping template. Meta can also re-categorize a template if its content does not match its category. Three templates cover the cases in this post. The names are placeholders. Create them in WhatsApp Manager and wait for approval. order_shipped: the whole order is on its way, with the tracking numbers. order_partially_shipped: part of the order is on its way, the rest will follow, with tracking for this part. order_shipped_item_unavailable: what shipped, what could not be sent, and who will contact them about it. Do not promise a refund amount or a date in the short-pick template unless the store has already decided it. The warehouse knows the item was not there. It does not know what the store will offer. Limitations The payload is an example contract. Real WMS platforms name and nest these fields differently, and some do not send running totals. The signature check assumes an HMAC of the raw body. Confirm the scheme your WMS uses. If it has no signing option, keep the hook URL private and add another check you control. The Code step was syntax-checked and run against sample data in Node.js. It was not run inside Zapier or against HubSpot or WhatsApp. The HubSpot property names and template names are placeholders. Returns, cancellations after release, and substitutions are out of scope. Each one needs its own status and its own message. Takeaways Only the WMS shipment confirmation should move an order past "released". Decide completeness from running totals per line, not from one shipment. One shipment, one message, with every tracking number in it. Treat a short pick as its own status and its own template. Dedupe on order plus shipment, in a table that will not hit Storage by Zapier limits. Update HubSpot first. Message the customer second. Keep promotions out of utility templates. The wider design questions, such as who owns stock numbers and how inventory and returns flow back, are covered in this WMS integration playbook if you want the full picture around this one flow. References Trigger Zap workflows from webhooks Use JavaScript code in Zap workflows Save and retrieve data with Storage by Zapier WhatsApp template categorization

Original Source

Read the full article at Dev →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.