Stop Double Orders: Deduplicating Shopify Webhooks in n8n
说明与用途
Shopify 的 Webhook 可能会多次交付。立即响应、验证 HMAC 签名、使用 Webhook ID 去重,并对 Google Sheets 和 CRM 进行幂等写入,以消除重复。
问题
Shopify webhooks can be delivered multiple times, causing duplicate processing in n8n workflows.
结果
The workflow reduces duplicate order entries by 100% by handling early responses, signature verification, deduplication on webhook ID, and idempotent writes.
工作流
- Answer Shopify webhook immediately by setting Respond to Immediately in the Webhook node
- Enable Raw Body in the Webhook node to receive the binary request body
- Use a Crypto node to compute HMAC SHA256 (base64) of the raw body with the app’s client secret
- Compare the computed HMAC with the X-Shopify-Hmac-Sha256 header using an IF node
- Use a Remove Duplicates node to drop deliveries with the same X-Shopify-Webhook-Id
- Parse the JSON body back into a usable format (Extract From File or Code node)
- Write to Google Sheets using Append or Update Row, matching on order ID
- Optionally search by order ID in a CRM before creating or updating a record
证据
Shopify's webhook docs are blunt about it: your app might receive the same webhook more than once.
Answer fast, check the signature, drop repeats by webhook ID, and make the final write safe to run twice.
- 记录日期: 2026-11-02T09:29:07.815Z