We use cookies to understand how you use our site and improve your experience. Privacy Policy

Back to Blog
Automation Workflows

Tag WooCommerce Orders with Claude in n8n

n8n
n8n Resources Team
July 6, 2026

Ready to automate?

Browse 5,000+ copy-paste n8n workflow templates.

The Order Queue Problem

Every WooCommerce store eventually runs into the same friction. Orders arrive and they all look the same in the queue: a number, a total, a name. But a $1,200 wholesale order from a reseller, a $12 digital download, and a $90 international shipment with customs requirements are not the same thing — they need different handling from the moment they're placed.

Most store owners deal with this by manually scanning the queue each morning and adding tags or notes before passing orders to fulfillment. Some build elaborate manual SOP documents. Others just accept that things occasionally fall through the cracks.

The cleaner solution is to classify orders automatically at the moment they land. With n8n and the Anthropic Claude API, you can build a workflow that reads every new order, evaluates the customer data, product mix, shipping method, and order value, and then tags the order in WooCommerce before anyone on your team touches it.

What This Workflow Does

On every new WooCommerce order, this workflow:

  1. Fetches the full order record from the WooCommerce REST API
  2. Compiles a structured order summary and sends it to Claude for classification
  3. Extracts Claude's classification response — order type, priority, and any flags
  4. Routes the order: high-value orders trigger a Discord alert, international orders get a compliance note, wholesale orders get tagged for warehouse routing

Every order is classified and annotated before it reaches your fulfillment team.

Before You Start

You will need:

  • An n8n instance (cloud or self-hosted)
  • WooCommerce with REST API credentials enabled — WooCommerce → Settings → Advanced → REST API
  • An Anthropic API key from console.anthropic.com
  • A Discord server channel webhook URL for high-priority order alerts (optional but recommended)

Example n8n Workflow: WooCommerce Order Classification

Step 1: Webhook Trigger — Capture New Orders

Add a Webhook node to your workflow. Set the HTTP method to POST and copy the generated URL. In your WooCommerce admin, navigate to WooCommerce → Settings → Advanced → Webhooks and create a new webhook for the "Order created" event, pointing to your n8n URL. Enable the secret field to verify payloads.

When a customer completes checkout, WooCommerce posts the full order payload to n8n in real time.

Step 2: HTTP Request Node — Fetch the Full Order

The WooCommerce webhook payload contains the order ID but sometimes omits extended line item metadata. Add an HTTP Request node to fetch the complete order record:

  • Method: GET
  • URL: https://yourstore.com/wp-json/wc/v3/orders/{{ $json.id }}
  • Authentication: Basic Auth using your WooCommerce consumer key and consumer secret

This guarantees you have the full order including product categories, tax lines, shipping zone, and customer purchase history flags.

Step 3: Set Node — Build the Classification Prompt

Add a Set node to assemble the order data into a clean text block. Pull these fields: order total, currency, customer country, shipping method name, line item names and quantities, and whether the customer email appears more than once in your order history (the WooCommerce API returns customer_id which you can use as a repeat-customer signal).

Write these into a single string value that will become the user message to Claude. End the prompt with a clear instruction: return only a JSON object with three fields — type (values: retail, wholesale, digital, international), priority (values: standard, high), and flag (any compliance or fulfillment note, or null).

Step 4: HTTP Request Node — Call the Anthropic Claude API

Add a second HTTP Request node with the following configuration:

  • Method: POST
  • URL: https://api.anthropic.com/v1/messages
  • Headers: x-api-key: [your Anthropic API key], anthropic-version: 2023-06-01, Content-Type: application/json
  • Body (raw JSON):
{
  "model": "claude-haiku-4-5-20251001",
  "max_tokens": 256,
  "system": "You are an order classification system. Analyze each WooCommerce order and return only valid JSON with fields: type, priority, flag. No explanation.",
  "messages": [
    { "role": "user", "content": "{{ $json.orderSummary }}" }
  ]
}

Use claude-haiku-4-5-20251001 here — it processes classifications in under 300 milliseconds and costs roughly $0.0004 per order. For a store doing 100 orders per day, monthly API cost is under $1.50. If you need more nuanced classification for high-SKU catalogs, swap in claude-sonnet-5 for more analytical depth.

Step 5: Code Node — Parse Claude's Response

Add a Code node to extract the JSON object from Claude's response. The API returns the classification inside content[0].text. Use a simple JSON.parse() call to get the structured object:

const text = $input.first().json.content[0].text;
return [{ json: JSON.parse(text) }];

This gives you clean type, priority, and flag values for the Switch node.

Step 6: Switch Node — Route by Order Type

Add a Switch node with rules matching on the type field from Claude's output:

  • wholesale: Branch to an HTTP Request node calling the WooCommerce REST API to add the wholesale tag and create an order note with the flag value. Then send an internal email via your SMTP or Resend credentials.
  • international: Branch to an HTTP Request node adding an international tag and a WooCommerce order note flagging customs documentation requirements.
  • digital: Branch to whatever license delivery system you use (a webhook, a Lemon Squeezy API call, or a direct email trigger).
  • retail + priority: high: Branch to an HTTP Request node that fires a Discord webhook.

Step 7: Discord Webhook — Alert on High-Priority Orders

For high-value retail orders (those Claude returns with priority: high), add an HTTP Request node pointed at your Discord channel webhook URL:

  • Method: POST
  • Body: a Discord embed payload with the order number, customer name, total value, and a direct link to the WooCommerce order admin page

Discord embed messages use an embeds array with title, description, color (an integer like 3447003 for blue), and fields for line items. Your team gets a formatted card in Discord within seconds of the order being placed.

Step 8: HTTP Request Node — Write the Tag Back to WooCommerce

For each branch that adds a tag, finish with an HTTP Request node calling the WooCommerce PATCH endpoint:

  • Method: PUT
  • URL: https://yourstore.com/wp-json/wc/v3/orders/{{ $json.id }}
  • Body: { "tags": ["{{ $json.type }}"], "meta_data": [{ "key": "_n8n_classified", "value": "true" }] }

The _n8n_classified metadata key lets you filter your order list and audit classification coverage.

Practical Benefits

Once deployed, this workflow changes how your team interacts with the order queue. Wholesale orders arrive already tagged so your warehouse coordinator doesn't have to open them to decide routing. International orders surface compliance flags without a manual lookup. High-value orders notify your team in real time rather than at the next daily review.

Accuracy is tunable: if Claude misclassifies edge cases, refine the system prompt and the output schema. The Code node makes it easy to iterate without touching the rest of the workflow. Most teams get to reliable classification within a few days of watching real orders flow through.

For additional n8n workflow templates covering WooCommerce, order processing, and AI-powered routing patterns, visit n8nresources.dev/templates. If you want to extend this workflow into a multi-step AI agent — for example, auto-responding to customers or triggering fulfillment APIs — the AI agents use case page has templates purpose-built for agentic n8n workflows. For alternative AI providers, the same HTTP Request pattern works with OpenAI integrations by swapping the endpoint and request schema.

Enjoyed this article?

Share it with others who might find it useful