See llms.txt for all machine-readable content.

Back to Templates

Route idempotent order webhooks to HubSpot and Slack with Data Tables logging

Quick overview

This workflow receives order webhooks, claims each event ID in an n8n Data Table to ensure idempotent processing, routes order.created and order.refunded events to HubSpot and Slack, logs every attempt, and posts error alerts to a dedicated Slack channel.

How it works

  1. Receives a POST webhook request and extracts the event ID, event type, and order/customer fields from the JSON payload.
  2. Looks up the event ID in an n8n Data Table and either claims it as received, re-claims it if it is stale/previously failed, or immediately returns HTTP 200 for duplicates.
  3. Returns HTTP 200 Accepted for newly claimed events and optionally stops processing if holdProcessing is enabled.
  4. For order.created events, upserts the buyer as a HubSpot contact with an order note and posts an order summary to a Slack report channel.
  5. For order.refunded events, upserts (or creates) the buyer as a HubSpot contact with a refund note and posts a refund notice to the Slack report channel.
  6. Marks the event as done or ignored in the Data Table, writes an attempt log row, and sends a Slack alert with the failed step and error details if any step fails.

Setup

  1. Create two n8n Data Tables named webhook_events (eventId, eventType, status, note, receivedAt) and webhook_attempts (eventId, eventType, outcome, failedStep, errorMessage, startedAt, finishedAt).
  2. Add a HubSpot private app token credential and confirm the HubSpot contact property used for notes matches the hubspotNoteProperty setting (default: message).
  3. Add a Slack credential and ensure the Slack channels referenced in Settings (orders-report and automation-alerts) exist or update them to your channel names.
  4. Update the Settings values to match your webhook payload paths (id, type, and data.* fields), staleness window, and webhook path, then copy the webhook URL into your webhook provider and send a test event before activating.

Requirements

  • n8n with Data Tables, a HubSpot private app token and a Slack workspace with two channels (one for reports, one for alerts)

Customization

  • The event id, event type and order field paths are set in the Settings node, so it works with any provider that posts JSON. Add your own event types as new Switch outputs.

Additional info

Limits: lookup and claim are two steps, not one atomic write, so two copies arriving at the same moment can both be claimed. The HTTP 200 reply goes out before processing, so a failed event is processed again only when the same id is delivered again. There is no webhook authentication by default; add header authentication on the Webhook node before going live. Tested on n8n 2.35.5.