See llms.txt for all machine-readable content.

Back to Templates

Check supplier order confirmations against POs with Claude, Gmail and Data Tables

Quick overview

This workflow reads supplier order confirmations from Gmail (including PDF attachments) or a webhook, extracts line details with Anthropic Claude, compares them to purchase orders in an n8n Data Table, then marks the PO confirmed, routes it to Slack for review, or drafts a buyer-approved chase email in Gmail.

How it works

  1. Triggers when you manually run a test batch, when a labeled email arrives in Gmail (optionally extracting PDF text), or when an external system posts a confirmation to a webhook.
  2. Normalizes the incoming document, detects suspected prompt-injection text, extracts the PO number, and loads the matching purchase order from either built-in sample data (test) or the n8n Data Table purchase_orders (live).
  3. Sends the confirmation text and PO line references to Anthropic Claude Haiku to extract the supplier-stated quantities, prices, currencies, and delivery dates without exposing ordered values.
  4. Compares Claude’s extracted values against the PO using your tolerance and delivery policies, then has Anthropic Claude Sonnet re-read any non-matching or unclear confirmations and routes disagreements to manual review.
  5. For confirmed matches in live mode, updates the PO row in the Data Table as confirmed, and for review cases posts a message to a Slack channel.
  6. For mismatches, generates a short chase email draft with Anthropic Claude, validates that all numbers in the draft come from the detected differences, requests buyer approval via Gmail, and then creates a reply draft in the supplier’s Gmail thread.
  7. Runs a daily schedule to find open POs older than three days in the Data Table, creates a Gmail reminder draft to the supplier, and marks the PO as reminded.

Setup

  1. Add your Anthropic (Claude) credentials and select the desired models in the three Anthropic nodes (Haiku read, Sonnet second read, and Haiku drafting).
  2. Create an n8n Data Table named purchase_orders with columns like po_no, supplier, supplier_email, lang, lines_json, status, ordered_at, and confirmed_at, and ensure lines_json contains the ordered line items as JSON.
  3. Connect your Gmail account, set the Gmail trigger label query (for example label:order-confirmations), and update the buyer approval recipient address used for the Gmail approval step.
  4. Connect your Slack account and set the target channel (for example #purchasing-review) for review notifications and error alerts.
  5. If using the webhook intake, copy the workflow webhook URL for the order-confirmation path and configure your ERP or upstream system to POST confirmations to it, then adjust the policy values in the Settings step (PO pattern, price tolerance, currency, signature) before activating.