🔬 Route legal-for-trade scale calibration outcomes with OpenAI and Google

⚡ 1 views · 🔬 Document Extraction & Analysis

Description

Quick overview

This workflow receives scale calibration results via webhook, calculates NIST Handbook 44-style tolerance deviations, uses OpenAI to classify each device outcome, and routes compliant, out-of-tolerance, condemned, and invalid submissions to Google Drive, Gmail, HTTP state registry endpoints, and Google Sheets with a consolidated audit log.

How it works

  1. Receives a POST webhook submission containing a visit ID, technician details, and an array of device calibration readings.
  2. Splits the payload into one item per device and calculates deviation percent, a tolerance band by device class, and a numeric status hint.
  3. Validates required fields and appends malformed readings to an “Invalid Submissions” tab in Google Sheets.
  4. Sends valid readings (including deviation math and technician notes) to an OpenAI text classifier to choose compliant, out_of_tolerance_fail, or condemned.
  5. For compliant devices, stores a certificate file in Google Drive and files a certification update to the state registry via HTTP.
  6. For out-of-tolerance devices, sends an urgent Gmail alert to the owner and opens a compliance case in Google Sheets.
  7. For condemned devices, submits a decommission notice to the state registry via HTTP and logs the decommission record in Google Sheets, then merges all outcomes and appends one consolidated audit-log row per visit in Google Sheets.

Setup

  1. Create credentials for Google Sheets, Google Drive, Gmail, OpenAI, and an HTTP header-auth/API key for your state weights-and-measures registry endpoints.
  2. Update the webhook URL in your technician mobile app or source system to POST to this workflow’s production webhook path.
  3. Replace the placeholder state registry API URLs and ensure the request bodies match your jurisdiction’s required fields.
  4. Set the Google Drive destination folder and confirm the Google Sheets document and tab names (Invalid Submissions, Compliance Cases, Decommissioned Devices, Consolidated Audit Log).
  5. Update the Gmail recipient address (and any CC/BCC requirements) for out-of-tolerance notifications and run a test submission with multiple readings to validate each branch.

Requirements

Customization

Additional info

Resilience & Retries: Every storage, notification, HTTP, and AI node includes continueRegularOutput with 3 retries on a 2-second backoff to prevent dropped visit data during temporary API drops.

Filing Endpoints: The state registry URLs are placeholders. In states without public REST APIs for weights and measures, swap the HTTP nodes for direct email submissions or scheduled batch exports.

Cost Footprint: Evaluates one lightweight classification call (gpt-4.1-mini) per tested scale—processing a 10-device site visit costs less than a penny in API usage.

đź”— Nodes Used

Google Sheets, HTTP Request, Webhook, Google Drive, Gmail, OpenAI Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup