n8n for SupplyChain & Logistics SaaS Vendors: 5 Automations for CBP ISF, FDA FSMA, DOT FMCSA, and CTPAT Compliance
If you're running a SaaS platform for supply chain, freight forwarding, customs compliance, or logistics — you're sitting on a compliance stack that can trigger five-figure daily fines with a single late filing. CBP ISF
If you're running a SaaS platform for supply chain, freight forwarding, customs compliance, or logistics — you're sitting on a compliance stack that can trigger five-figure daily fines with a single late filing.
CBP ISF 10+2? $5,000 per violation per day — automatically assessed on late or incorrect filing. DOT PHMSA hazmat incident? 30-minute phone call to the NRC hotline (1-800-424-8802) — the clock starts the moment your driver discovers the incident, not when your compliance team finds out. FDA FSVP records request? 24 hours to produce foreign supplier verification records to CBP or FDA on demand.
These aren't theoretical risks. They're operational realities that supply chain SaaS vendors must build into their customer onboarding, monitoring, and incident response workflows.
Here are 5 production-ready n8n workflows built specifically for supply chain and logistics SaaS vendors — covering CBP ISF, FDA FSMA FSVP, DOT FMCSA, CTPAT, IATA DGR, and FMC OSRA-22.
Why self-hosted n8n for supply chain compliance?
Supply chain data is uniquely sensitive from a regulatory perspective:
| Compliance Issue | Risk if data flows through cloud iPaaS |
|---|---|
| CBP ISF filing data | 19 USC §1484 — entry data is customs-protected, cloud logging = subprocessor question |
| FDA FSVP supplier verification records | 21 CFR §1.502 — must be available to FDA on demand, cloud copies complicate production |
| CTPAT security profile | CBP partnership data — routing through SaaS cloud creates supply chain visibility risk |
| IATA DGR shipment declarations | Dangerous goods data must stay within operator-controlled systems |
| DOT PHMSA incident reports | §171.16 annual report — cloud-generated report lacks §171.15 telephone call audit trail |
| FMC OSRA-22 commercial data | Ocean shipping contracts are competitively sensitive — TPSP subprocessor scope |
Self-hosted n8n keeps your automation layer inside your network boundary — same SOC 2 perimeter as your application servers, not a separate cloud vendor chain.
Workflow 1: Supply Chain Customer Onboarding Drip
What it does: Tier-segmented onboarding email sequence for new supply chain SaaS customers. Injects compliance-specific content based on their regulatory profile (CBP ISF filer, FDA FSVP importer, CTPAT member, IATA DGR carrier, DOT FMCSA regulated).
Customer tiers supported:
-
ENTERPRISE_3PL_PLATFORM— Day 0 flags all applicable clocks -
MIDMARKET_FREIGHT_FORWARDER_SAAS— Day 0 CBP bond and ISF 24h clock -
CUSTOMS_COMPLIANCE_SAAS— Day 0 CBP ISF + FDA FSVP 24h -
WAREHOUSE_MANAGEMENT_SYSTEM_VENDOR— Day 0 DOT HAZMAT training clock -
LAST_MILE_DELIVERY_SAAS— Day 0 DOT FMCSA HOS and ELD mandate -
COLD_CHAIN_LOGISTICS_SAAS— Day 0 FDA FSMA/FSVP + CTPAT security -
AIR_CARGO_DGR_SAAS— Day 0 IATA DGR immediate enforcement reminder
Import JSON:
{"name": "FlowKit \u2014 Supply Chain Onboarding Drip", "nodes": [{"parameters": {"rule": {"interval": [{"field": "cronExpression", "expression": "0 8 * * 1-5"}]}}, "name": "Schedule - Weekdays 8AM", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [250, 300], "id": "w1n1"}, {"parameters": {"operation": "read", "documentId": {"__rl": true, "value": "YOUR_CUSTOMER_SHEET_ID", "mode": "id"}, "sheetName": {"__rl": true, "value": "Customers", "mode": "name"}, "options": {}}, "name": "Google Sheets - Get New Customers", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [470, 300], "id": "w1n2"}, {"parameters": {"jsCode": "const customers = $input.all();\nconst now = new Date();\nconst results = [];\nfor (const item of customers) {\n const d = item.json;\n const created = new Date(d.created_at);\n const daysSince = Math.floor((now - created) / 86400000);\n if (d.onboarding_email_sent) continue;\n const tier = d.tier || 'MIDMARKET_FREIGHT_FORWARDER_SAAS';\n const flags = (d.compliance_flags || '').split(',').map(f => f.trim());\n const hasCBP = flags.includes('CBP_ISF_FILER');\n const hasFSVP = flags.includes('FDA_FSVP_IMPORTER');\n const hasCTPAT = flags.includes('CTPAT_MEMBER');\n const hasDGR = flags.includes('IATA_DGR_APPLICABLE');\n const hasFMCSA = flags.includes('DOT_FMCSA_CARRIER');\n let complianceNote = '';\n if (hasCBP) complianceNote += ' CBP ISF 10+2 requires filing 24h before vessel loading \u2014 $5,000/violation/day.';\n if (hasFSVP) complianceNote += ' FDA FSVP records must be available within 24h of CBP/FDA request (21 CFR \u00a71.502).';\n if (hasCTPAT) complianceNote += ' CTPAT security profile must reflect current supply chain partners.';\n if (hasDGR) complianceNote += ' IATA DGR undeclared dangerous goods = immediate enforcement + $16,000 fine.';\n if (hasFMCSA) complianceNote += ' DOT FMCSA HOS \u00a7395 \u2014 $16,000/violation + OOS order.';\n const tierMsg = {\n 'ENTERPRISE_3PL_PLATFORM': 'enterprise 3PL platform team',\n 'MIDMARKET_FREIGHT_FORWARDER_SAAS': 'freight forwarding SaaS team',\n 'CUSTOMS_COMPLIANCE_SAAS': 'customs compliance SaaS team',\n 'WAREHOUSE_MANAGEMENT_SYSTEM_VENDOR': 'WMS platform team',\n 'LAST_MILE_DELIVERY_SAAS': 'last-mile delivery SaaS team',\n 'COLD_CHAIN_LOGISTICS_SAAS': 'cold chain logistics SaaS team',\n 'AIR_CARGO_DGR_SAAS': 'air cargo & DGR SaaS team'\n }[tier] || 'logistics SaaS team';\n if (daysSince === 0) {\n results.push({\n customer_email: d.email, customer_name: d.name, tier, day: 0,\n subject: `Welcome to FlowKit \u2014 your supply chain automation platform`,\n body: `Hi ${d.name},\\n\\nWelcome to FlowKit \u2014 your n8n automation platform for supply chain compliance.${complianceNote}\\n\\nYour dedicated onboarding guide: https://flowkithq.notion.site/supply-chain\\n\\nTeam FlowKit`\n });\n }\n}\nreturn results.map(r => ({json: r}));"}, "name": "Code - Build Day 0 Emails", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [690, 300], "id": "w1n3"}, {"parameters": {"conditions": {"options": {"caseSensitive": true}, "conditions": [{"id": "c1", "leftValue": "={{ $json.day }}", "rightValue": 0, "operator": {"type": "number", "operation": "equals"}}]}}, "name": "IF - Day 0", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [910, 300], "id": "w1n4"}, {"parameters": {"fromEmail": "[email protected]", "toEmail": "={{ $json.customer_email }}", "subject": "={{ $json.subject }}", "emailType": "text", "message": "={{ $json.body }}"}, "name": "Gmail - Send Day 0 Welcome", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [1130, 200], "id": "w1n5"}, {"parameters": {"operation": "update", "documentId": {"__rl": true, "value": "YOUR_CUSTOMER_SHEET_ID", "mode": "id"}, "sheetName": {"__rl": true, "value": "Customers", "mode": "name"}, "columns": {"mappingMode": "autoMapInputData", "value": {"onboarding_email_sent": true}}, "options": {}}, "name": "Google Sheets - Mark Sent", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [1130, 400], "id": "w1n6"}], "connections": {"Schedule - Weekdays 8AM": {"main": [[{"node": "Google Sheets - Get New Customers", "type": "main", "index": 0}]]}, "Google Sheets - Get New Customers": {"main": [[{"node": "Code - Build Day 0 Emails", "type": "main", "index": 0}]]}, "Code - Build Day 0 Emails": {"main": [[{"node": "IF - Day 0", "type": "main", "index": 0}]]}, "IF - Day 0": {"main": [[{"node": "Gmail - Send Day 0 Welcome", "type": "main", "index": 0}], [{"node": "Google Sheets - Mark Sent", "type": "main", "index": 0}]]}, "Gmail - Send Day 0 Welcome": {"main": [[{"node": "Google Sheets - Mark Sent", "type": "main", "index": 0}]]}}, "active": false, "settings": {}, "versionId": "sc-onboard-v1"}
Workflow 2: Supply Chain API Health Monitor
What it does: Polls 5 critical supply chain compliance API endpoints every 5 minutes. Uses $getWorkflowStaticData to track state — only fires Slack alert on transition from UP to DOWN, suppressing noise on sustained outages.
Endpoints monitored:
-
cbp_isf_api— CBP ISF 19 USC §1484 filing interface — $5k/day late -
fda_fsvp_api— FDA FSVP 21 CFR §1.502 — 24h records request clock -
fmcsa_eld_api— DOT FMCSA ELD 49 CFR §395 — $16k/violation -
ctpat_portal_api— CBP CTPAT partnership portal — suspension if profile stale -
iata_dgr_api— IATA DGR declaration interface — immediate enforcement if down during filing
Import JSON:
{"name": "FlowKit \u2014 Supply Chain API Health Monitor", "nodes": [{"parameters": {"rule": {"interval": [{"field": "cronExpression", "expression": "*/5 * * * *"}]}}, "name": "Schedule - Every 5 Min", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [250, 300], "id": "w2n1"}, {"parameters": {"jsCode": "const endpoints = [\n {name: 'cbp_isf_api', url: process.env.CBP_ISF_API_URL || 'https://api.cbp.example.com/health', label: 'CBP ISF 19 USC \u00a71484 \u2014 $5k/day late filing'},\n {name: 'fda_fsvp_api', url: process.env.FDA_FSVP_API_URL || 'https://api.fsvp.example.com/health', label: 'FDA FSVP 21 CFR \u00a71.502 \u2014 24h records request'},\n {name: 'fmcsa_eld_api', url: process.env.FMCSA_ELD_API_URL || 'https://api.fmcsa.example.com/health', label: 'DOT FMCSA ELD 49 CFR \u00a7395 \u2014 $16k/violation'},\n {name: 'ctpat_portal_api', url: process.env.CTPAT_API_URL || 'https://ctpat.cbp.dhs.gov/api/health', label: 'CTPAT CBP security profile \u2014 suspension risk'},\n {name: 'iata_dgr_api', url: process.env.IATA_DGR_API_URL || 'https://api.iata.example.com/dgr/health', label: 'IATA DGR undeclared goods \u2014 immediate enforcement'}\n];\nreturn endpoints.map(e => ({json: e}));"}, "name": "Code - List Endpoints", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [470, 300], "id": "w2n2"}, {"parameters": {"url": "={{ $json.url }}", "options": {"timeout": 10000, "response": {"response": {"neverError": true}}}}, "name": "HTTP Request - Ping Endpoint", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [690, 300], "id": "w2n3"}, {"parameters": {"jsCode": "const items = $input.all();\nconst state = $getWorkflowStaticData('global');\nif (!state.endpointStatus) state.endpointStatus = {};\nconst alerts = [];\nfor (const item of items) {\n const {name, label} = item.json;\n const statusCode = item.json.statusCode || 0;\n const isUp = statusCode >= 200 && statusCode < 300;\n const prev = state.endpointStatus[name];\n if (!isUp && prev !== 'DOWN') {\n alerts.push({name, label, statusCode, status: 'DOWN'});\n }\n state.endpointStatus[name] = isUp ? 'UP' : 'DOWN';\n}\nreturn alerts.length ? alerts.map(a => ({json: a})) : [{json: {skip: true}}];"}, "name": "Code - Detect New Failures", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [910, 300], "id": "w2n4"}, {"parameters": {"conditions": {"options": {"caseSensitive": true}, "conditions": [{"id": "c1", "leftValue": "={{ $json.skip }}", "rightValue": true, "operator": {"type": "boolean", "operation": "notEquals"}}]}}, "name": "IF - Has Alert", "type": "n8n-nodes-base.if", "typeVersion": 2, "position": [1130, 300], "id": "w2n5"}, {"parameters": {"authentication": "oAuth2", "resource": "channel", "operation": "post", "channelId": "compliance-ops", "text": "=:red_circle: SUPPLY CHAIN API DOWN: {{ $json.name }}\nLabel: {{ $json.label }}\nStatus: {{ $json.statusCode }}\nTime: {{ $now.toISO() }}"}, "name": "Slack - Alert Compliance Ops", "type": "n8n-nodes-base.slack", "typeVersion": 2.2, "position": [1350, 200], "id": "w2n6"}], "connections": {"Schedule - Every 5 Min": {"main": [[{"node": "Code - List Endpoints", "type": "main", "index": 0}]]}, "Code - List Endpoints": {"main": [[{"node": "HTTP Request - Ping Endpoint", "type": "main", "index": 0}]]}, "HTTP Request - Ping Endpoint": {"main": [[{"node": "Code - Detect New Failures", "type": "main", "index": 0}]]}, "Code - Detect New Failures": {"main": [[{"node": "IF - Has Alert", "type": "main", "index": 0}]]}, "IF - Has Alert": {"main": [[{"node": "Slack - Alert Compliance Ops", "type": "main", "index": 0}], []]}}, "active": false, "settings": {}, "versionId": "sc-health-v1"}
Workflow 3: CBP / FDA / DOT / IATA Compliance Deadline Tracker
What it does: Runs weekday mornings against a Google Sheets deadline register. Routes by severity (OVERDUE → CRITICAL → URGENT → WARNING → NOTICE). Sends Slack alerts to #compliance-critical and email to deadline owners. Includes deduplication to prevent repeat alerts on the same open item.
12 deadline types covered:
-
CBP_ISF_ANNUAL_BOND_REVIEW— continuous bond annual review -
FDA_FSVP_SUPPLIER_VERIFICATION_ANNUAL— 21 CFR §1.502 on-site audit -
DOT_FMCSA_DRIVER_QUALIFICATION_FILE— 49 CFR §391.51 annual review -
CTPAT_ANNUAL_SECURITY_REVIEW— suspension if overdue -
IATA_DGR_SHIPPER_CERTIFICATION_RENEWAL— 2yr renewal cycle -
FMC_OSRA22_TARIFF_PUBLICATION— 46 USC §40501 OTI license risk -
DOT_HAZMAT_EMPLOYEE_TRAINING_3YR— 49 CFR §172.704 -
CBP_CUSTOMS_BROKER_LICENSE_TRIENNIAL— 19 USC §1641 -
FDA_PRIOR_NOTICE_SYSTEM_TEST— 21 CFR §1.279 -
SOC2_TYPE2_RENEWAL— enterprise procurement gate -
ISO_28000_SURVEILLANCE_AUDIT— supply chain security standard -
DOT_PHMSA_ANNUAL_INCIDENT_REPORT— 49 CFR §171.16
Import JSON:
{"name": "FlowKit \u2014 Supply Chain Compliance Deadline Tracker", "nodes": [{"parameters": {"rule": {"interval": [{"field": "cronExpression", "expression": "0 8 * * 1-5"}]}}, "name": "Schedule - Weekdays 8AM", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [250, 300], "id": "w3n1"}, {"parameters": {"operation": "read", "documentId": {"__rl": true, "value": "YOUR_DEADLINES_SHEET_ID", "mode": "id"}, "sheetName": {"__rl": true, "value": "Deadlines", "mode": "name"}, "options": {}}, "name": "Google Sheets - Get Deadlines", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [470, 300], "id": "w3n2"}, {"parameters": {"jsCode": "const items = $input.all();\nconst now = new Date();\nconst alerts = [];\nconst DEADLINE_TYPES = {\n 'CBP_ISF_ANNUAL_BOND_REVIEW': 'CBP ISF Continuous Bond Annual Review \u2014 $50k minimum, ISF authority',\n 'FDA_FSVP_SUPPLIER_VERIFICATION_ANNUAL': 'FDA FSVP Annual Supplier Verification \u2014 21 CFR \u00a71.502 on-site audit',\n 'DOT_FMCSA_DRIVER_QUALIFICATION_FILE': 'DOT FMCSA Driver Qualification File \u2014 49 CFR \u00a7391.51 annual review',\n 'CTPAT_ANNUAL_SECURITY_REVIEW': 'CTPAT Annual Security Profile Review \u2014 suspension if overdue',\n 'IATA_DGR_SHIPPER_CERTIFICATION_RENEWAL': 'IATA DGR Shippers Certification \u2014 2yr renewal, undeclared goods = $16k/item',\n 'FMC_OSRA22_TARIFF_PUBLICATION': 'FMC OSRA-22 Tariff Publication \u2014 46 USC \u00a740501 non-filing = OTI license risk',\n 'DOT_HAZMAT_EMPLOYEE_TRAINING_3YR': 'DOT HAZMAT Employee Training \u2014 49 CFR \u00a7172.704 every 3 years',\n 'CBP_CUSTOMS_BROKER_LICENSE_TRIENNIAL': 'CBP Customs Broker License Triennial Fee \u2014 19 USC \u00a71641 suspension if unpaid',\n 'FDA_PRIOR_NOTICE_SYSTEM_TEST': 'FDA Prior Notice Interface Partner Annual Test \u2014 21 CFR \u00a71.279',\n 'SOC2_TYPE2_RENEWAL': 'SOC 2 Type 2 Renewal \u2014 enterprise customer procurement gate',\n 'ISO_28000_SURVEILLANCE_AUDIT': 'ISO 28000 Supply Chain Security Surveillance Audit',\n 'DOT_PHMSA_ANNUAL_INCIDENT_REPORT': 'DOT PHMSA Annual Hazmat Incident Report \u2014 49 CFR \u00a7171.16'\n};\nfor (const item of items) {\n const d = item.json;\n if (!d.deadline_type || !d.due_date || d.resolved === 'true') continue;\n const due = new Date(d.due_date);\n const daysUntil = Math.floor((due - now) / 86400000);\n let severity = null;\n if (daysUntil < 0) severity = 'OVERDUE';\n else if (daysUntil <= 14) severity = 'CRITICAL';\n else if (daysUntil <= 30) severity = 'URGENT';\n else if (daysUntil <= 60) severity = 'WARNING';\n else if (daysUntil <= 90) severity = 'NOTICE';\n if (!severity) continue;\n const desc = DEADLINE_TYPES[d.deadline_type] || d.deadline_type;\n const dedup = `${d.deadline_type}_${d.due_date}_${d.account_id}`;\n if (d.last_alerted === dedup) continue;\n alerts.push({...d, severity, daysUntil, description: desc, dedup_key: dedup});\n}\nreturn alerts.map(a => ({json: a}));"}, "name": "Code - Classify Deadlines", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [690, 300], "id": "w3n3"}, {"parameters": {"rules": {"values": [{"conditions": {"options": {"caseSensitive": true}, "conditions": [{"leftValue": "={{ $json.severity }}", "rightValue": "OVERDUE", "operator": {"type": "string", "operation": "equals"}}]}, "renameOutput": true, "outputKey": "overdue"}, {"conditions": {"options": {"caseSensitive": true}, "conditions": [{"leftValue": "={{ $json.severity }}", "rightValue": "CRITICAL", "operator": {"type": "string", "operation": "equals"}}]}, "renameOutput": true, "outputKey": "critical"}, {"conditions": {"options": {"caseSensitive": true}, "conditions": [{"leftValue": "={{ $json.severity }}", "rightValue": "URGENT", "operator": {"type": "string", "operation": "equals"}}]}, "renameOutput": true, "outputKey": "urgent"}], "fallbackOutput": "extra", "options": {}}}, "name": "Switch - Route by Severity", "type": "n8n-nodes-base.switch", "typeVersion": 3, "position": [910, 300], "id": "w3n4"}, {"parameters": {"authentication": "oAuth2", "resource": "channel", "operation": "post", "channelId": "compliance-critical", "text": "=:rotating_light: {{ $json.severity }} \u2014 {{ $json.deadline_type }}\nAccount: {{ $json.account_id }}\nDue: {{ $json.due_date }} ({{ $json.daysUntil }}d)\nDetail: {{ $json.description }}"}, "name": "Slack - OVERDUE/CRITICAL Alert", "type": "n8n-nodes-base.slack", "typeVersion": 2.2, "position": [1130, 200], "id": "w3n5"}, {"parameters": {"fromEmail": "[email protected]", "toEmail": "={{ $json.owner_email }}", "subject": "=[ACTION REQUIRED] {{ $json.severity }}: {{ $json.deadline_type }} due {{ $json.due_date }}", "emailType": "text", "message": "=Deadline: {{ $json.description }}\nAccount: {{ $json.account_id }}\nDue: {{ $json.due_date }}\nDays remaining: {{ $json.daysUntil }}\n\nPlease action immediately to avoid regulatory penalties."}, "name": "Gmail - Notify Owner", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [1130, 400], "id": "w3n6"}], "connections": {"Schedule - Weekdays 8AM": {"main": [[{"node": "Google Sheets - Get Deadlines", "type": "main", "index": 0}]]}, "Google Sheets - Get Deadlines": {"main": [[{"node": "Code - Classify Deadlines", "type": "main", "index": 0}]]}, "Code - Classify Deadlines": {"main": [[{"node": "Switch - Route by Severity", "type": "main", "index": 0}]]}, "Switch - Route by Severity": {"main": [[{"node": "Slack - OVERDUE/CRITICAL Alert", "type": "main", "index": 0}], [{"node": "Slack - OVERDUE/CRITICAL Alert", "type": "main", "index": 0}], [{"node": "Gmail - Notify Owner", "type": "main", "index": 0}]]}, "Slack - OVERDUE/CRITICAL Alert": {"main": [[{"node": "Gmail - Notify Owner", "type": "main", "index": 0}]]}}, "active": false, "settings": {}, "versionId": "sc-deadline-v1"}
Workflow 4: Supply Chain Incident & CBP Alert Pipeline
What it does: Webhook-triggered incident router. Classifies by type, maps regulatory clock and escalation path, fires Slack + Gmail simultaneously, logs to Google Sheets audit trail, responds 200 OK.
8 incident types with clocks:
-
DOT_PHMSA_HAZMAT_INCIDENT— 30 minutes — §171.15(a) verbal NRC hotline — fastest clock in this stack -
CBP_ISF_LATE_FILING— Immediate — $5,000/violation/day + liquidated damages -
IATA_DGR_UNDECLARED_DANGEROUS_GOODS— Immediate — $16,000 base fine + IATA enforcement -
FDA_FSVP_RECORDS_REQUEST— 24 hours — 21 CFR §1.502(g) produce to FDA/CBP on demand -
DOT_FMCSA_HOS_VIOLATION— 24 hours — $16,000/violation + OOS if egregious -
CTPAT_SECURITY_BREACH— 48 hours — report to CBP CTPAT coordinator -
FMC_DETENTION_DEMURRAGE_DISPUTE— 30 days — 46 USC §41305 complaint + OSRA-22 invoice -
CBP_CUSTOMS_HOLD_CARGO— 24 hours — storage, exam fees, perishable loss risk
Import JSON:
{"name": "FlowKit \u2014 Supply Chain Incident Pipeline", "nodes": [{"parameters": {"httpMethod": "POST", "path": "supply-chain-incident", "responseMode": "lastNode", "options": {}}, "name": "Webhook - Incident Trigger", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [250, 300], "id": "w4n1"}, {"parameters": {"jsCode": "const d = $input.first().json;\nconst incidentMap = {\n 'DOT_PHMSA_HAZMAT_INCIDENT': {severity: 'IMMEDIATE', clock: '30 min DOT \u00a7171.15(a) \u2014 verbal NRC hotline 800-424-8802', escalate: 'DOT NRC + state SERC + EPA if RQ exceeded'},\n 'CBP_ISF_LATE_FILING': {severity: 'IMMEDIATE', clock: '$5,000/violation/day + potential liquidated damages 19 USC \u00a71484', escalate: 'CBP Trade Compliance + customs broker notification'},\n 'IATA_DGR_UNDECLARED_DANGEROUS_GOODS': {severity: 'IMMEDIATE', clock: '$16,000 base fine + IATA DGR enforcement immediate', escalate: 'IATA + airline enforcement + DOT PHMSA if US domestic'},\n 'FDA_FSVP_RECORDS_REQUEST': {severity: 'URGENT', clock: '24 hours \u2014 21 CFR \u00a71.502(g) produce records to FDA/CBP on request', escalate: 'FDA/CBP request response team + FSVP qualified individual'},\n 'DOT_FMCSA_HOS_VIOLATION': {severity: 'URGENT', clock: '24h \u2014 $16,000/violation 49 CFR \u00a7395 + OOS if egregious', escalate: 'Safety officer + driver file review + FMCSA DataQ correction'},\n 'CTPAT_SECURITY_BREACH': {severity: 'URGENT', clock: '48h \u2014 report to CBP CTPAT program coordinator', escalate: 'CBP CTPAT team + supply chain security audit'},\n 'FMC_DETENTION_DEMURRAGE_DISPUTE': {severity: 'HIGH', clock: '30 days \u2014 FMC complaint 46 USC \u00a741305 + OSRA-22 invoice dispute', escalate: 'FMC dispute resolution + container line counterparty'},\n 'CBP_CUSTOMS_HOLD_CARGO': {severity: 'HIGH', clock: '24h \u2014 CBP holds can trigger storage + exam fees + perishable loss', escalate: 'CBP entry team + importer of record + FDA if food/drug'}\n};\nconst config = incidentMap[d.incident_type] || {severity: 'HIGH', clock: 'Review applicable regulation', escalate: 'Compliance team'};\nreturn [{json: {...d, ...config, ts: new Date().toISOString()}}];"}, "name": "Code - Classify Incident", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [470, 300], "id": "w4n2"}, {"parameters": {"authentication": "oAuth2", "resource": "channel", "operation": "post", "channelId": "compliance-incident", "text": "=:rotating_light: SUPPLY CHAIN INCIDENT: {{ $json.incident_type }}\nSeverity: {{ $json.severity }}\nAccount: {{ $json.account_id }}\nClock: {{ $json.clock }}\nEscalate: {{ $json.escalate }}\nTime: {{ $json.ts }}"}, "name": "Slack - Incident Alert", "type": "n8n-nodes-base.slack", "typeVersion": 2.2, "position": [690, 200], "id": "w4n3"}, {"parameters": {"fromEmail": "[email protected]", "toEmail": "[email protected]", "ccEmail": "[email protected]", "bccEmail": "[email protected]", "subject": "=[{{ $json.severity }}] Supply Chain Incident: {{ $json.incident_type }} \u2014 {{ $json.account_id }}", "emailType": "text", "message": "=Incident Type: {{ $json.incident_type }}\nSeverity: {{ $json.severity }}\nAccount: {{ $json.account_id }}\nRegulatory Clock: {{ $json.clock }}\nEscalation Path: {{ $json.escalate }}\nDetected: {{ $json.ts }}\n\nImmediate action required per supply chain compliance protocols."}, "name": "Gmail - Notify CEO + CCO", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [690, 400], "id": "w4n4"}, {"parameters": {"operation": "appendOrUpdate", "documentId": {"__rl": true, "value": "YOUR_INCIDENTS_SHEET_ID", "mode": "id"}, "sheetName": {"__rl": true, "value": "Incidents", "mode": "name"}, "columns": {"mappingMode": "autoMapInputData", "value": {}}, "options": {}}, "name": "Google Sheets - Log Incident", "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [910, 300], "id": "w4n5"}, {"parameters": {"respondWith": "json", "responseBody": "={{ JSON.stringify({status: 'logged', incident_type: $json.incident_type, ts: $json.ts}) }}", "options": {}}, "name": "Respond - 200 OK", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.1, "position": [1130, 300], "id": "w4n6"}], "connections": {"Webhook - Incident Trigger": {"main": [[{"node": "Code - Classify Incident", "type": "main", "index": 0}]]}, "Code - Classify Incident": {"main": [[{"node": "Slack - Incident Alert", "type": "main", "index": 0}]]}, "Slack - Incident Alert": {"main": [[{"node": "Gmail - Notify CEO + CCO", "type": "main", "index": 0}]]}, "Gmail - Notify CEO + CCO": {"main": [[{"node": "Google Sheets - Log Incident", "type": "main", "index": 0}]]}, "Google Sheets - Log Incident": {"main": [[{"node": "Respond - 200 OK", "type": "main", "index": 0}]]}}, "active": false, "settings": {}, "versionId": "sc-incident-v1"}
Workflow 5: Weekly Supply Chain Platform KPI Dashboard
What it does: Monday 8 AM dual Postgres query (shipment events + compliance events), merges, builds HTML table with week-over-week delta via $getWorkflowStaticData, emails CEO + COO (BCC CISO), posts one-liner to Slack #weekly-kpi.
KPIs tracked:
- Active accounts, total shipments processed
- Customs holds, FSVP records requests open
- CBP ISF late violations, avg transit days
- Open compliance events (30d window)
- DOT / CBP / FDA open items segmented
Import JSON:
{"name": "FlowKit \u2014 Weekly Supply Chain KPI Dashboard", "nodes": [{"parameters": {"rule": {"interval": [{"field": "cronExpression", "expression": "0 8 * * 1"}]}}, "name": "Schedule - Monday 8AM", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [250, 300], "id": "w5n1"}, {"parameters": {"operation": "executeQuery", "query": "SELECT COUNT(DISTINCT account_id) AS active_accounts, COUNT(*) AS total_shipments, SUM(CASE WHEN customs_hold = true THEN 1 ELSE 0 END) AS customs_holds, SUM(CASE WHEN fsvp_records_request_open = true THEN 1 ELSE 0 END) AS fsvp_requests_open, SUM(CASE WHEN cbp_isf_late = true THEN 1 ELSE 0 END) AS cbp_isf_violations, ROUND(AVG(transit_days_actual),1) AS avg_transit_days FROM shipment_events WHERE created_at >= NOW() - INTERVAL '7 days'", "options": {}}, "name": "Postgres - Shipment Metrics", "type": "n8n-nodes-base.postgres", "typeVersion": 2.5, "position": [470, 200], "id": "w5n2"}, {"parameters": {"operation": "executeQuery", "query": "SELECT COUNT(*) AS open_incidents, SUM(CASE WHEN severity = 'IMMEDIATE' THEN 1 ELSE 0 END) AS immediate_count, SUM(CASE WHEN deadline_type LIKE 'DOT_%' THEN 1 ELSE 0 END) AS dot_open, SUM(CASE WHEN deadline_type LIKE 'CBP_%' THEN 1 ELSE 0 END) AS cbp_open, SUM(CASE WHEN deadline_type LIKE 'FDA_%' THEN 1 ELSE 0 END) AS fda_open FROM compliance_events WHERE resolved = false AND created_at >= NOW() - INTERVAL '30 days'", "options": {}}, "name": "Postgres - Compliance Events", "type": "n8n-nodes-base.postgres", "typeVersion": 2.5, "position": [470, 440], "id": "w5n3"}, {"parameters": {"mode": "mergeByIndex", "options": {}}, "name": "Merge - Combine Metrics", "type": "n8n-nodes-base.merge", "typeVersion": 3.1, "position": [690, 300], "id": "w5n4"}, {"parameters": {"jsCode": "const d = $input.first().json;\nconst state = $getWorkflowStaticData('global');\nconst prev = state.lastMetrics || {};\nfunction pct(cur, prv) {\n if (!prv || prv === 0) return 'N/A';\n const delta = ((cur - prv) / prv * 100).toFixed(1);\n return (delta > 0 ? '+' : '') + delta + '%';\n}\nconst html = [\n '<h2>FlowKit Weekly Supply Chain KPI \u2014 ' + new Date().toISOString().slice(0,10) + '</h2>',\n '<table border=1 cellpadding=6 style=\"border-collapse:collapse\">',\n '<tr><th>Metric</th><th>This Week</th><th>WoW</th></tr>',\n '<tr><td>Active Accounts</td><td>' + d.active_accounts + '</td><td>' + pct(d.active_accounts, prev.active_accounts) + '</td></tr>',\n '<tr><td>Total Shipments</td><td>' + d.total_shipments + '</td><td>' + pct(d.total_shipments, prev.total_shipments) + '</td></tr>',\n '<tr><td>Customs Holds</td><td>' + d.customs_holds + '</td><td>' + pct(d.customs_holds, prev.customs_holds) + '</td></tr>',\n '<tr><td>FSVP Records Requests Open</td><td>' + d.fsvp_requests_open + '</td><td>-</td></tr>',\n '<tr><td>CBP ISF Late Violations</td><td>' + d.cbp_isf_violations + '</td><td>' + pct(d.cbp_isf_violations, prev.cbp_isf_violations) + '</td></tr>',\n '<tr><td>Avg Transit Days</td><td>' + d.avg_transit_days + '</td><td>' + pct(d.avg_transit_days, prev.avg_transit_days) + '</td></tr>',\n '<tr><td>Open Compliance Events (30d)</td><td>' + d.open_incidents + '</td><td>-</td></tr>',\n '<tr><td>DOT Open Items</td><td>' + d.dot_open + '</td><td>-</td></tr>',\n '<tr><td>CBP Open Items</td><td>' + d.cbp_open + '</td><td>-</td></tr>',\n '<tr><td>FDA Open Items</td><td>' + d.fda_open + '</td><td>-</td></tr>',\n '</table>'\n].join('\\n');\nstate.lastMetrics = {active_accounts: d.active_accounts, total_shipments: d.total_shipments, customs_holds: d.customs_holds, cbp_isf_violations: d.cbp_isf_violations, avg_transit_days: d.avg_transit_days};\nreturn [{json: {...d, html_body: html, slack_summary: `[SC KPI] Accounts:${d.active_accounts} Shipments:${d.total_shipments} ISF violations:${d.cbp_isf_violations} Customs holds:${d.customs_holds}`}}];"}, "name": "Code - Build KPI Report", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [910, 300], "id": "w5n5"}, {"parameters": {"fromEmail": "[email protected]", "toEmail": "[email protected]", "ccEmail": "[email protected]", "bccEmail": "[email protected]", "subject": "=[FlowKit] Weekly Supply Chain KPI \u2014 {{ $now.format('YYYY-MM-DD') }}", "emailType": "html", "message": "={{ $json.html_body }}"}, "name": "Gmail - Weekly KPI Email", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1, "position": [1130, 200], "id": "w5n6"}, {"parameters": {"authentication": "oAuth2", "resource": "channel", "operation": "post", "channelId": "weekly-kpi", "text": "={{ $json.slack_summary }}"}, "name": "Slack - Weekly Summary", "type": "n8n-nodes-base.slack", "typeVersion": 2.2, "position": [1130, 400], "id": "w5n7"}], "connections": {"Schedule - Monday 8AM": {"main": [[{"node": "Postgres - Shipment Metrics", "type": "main", "index": 0}], [{"node": "Postgres - Compliance Events", "type": "main", "index": 0}]]}, "Postgres - Shipment Metrics": {"main": [[{"node": "Merge - Combine Metrics", "type": "main", "index": 0}]]}, "Postgres - Compliance Events": {"main": [[{"node": "Merge - Combine Metrics", "type": "main", "index": 1}]]}, "Merge - Combine Metrics": {"main": [[{"node": "Code - Build KPI Report", "type": "main", "index": 0}]]}, "Code - Build KPI Report": {"main": [[{"node": "Gmail - Weekly KPI Email", "type": "main", "index": 0}]]}, "Gmail - Weekly KPI Email": {"main": [[{"node": "Slack - Weekly Summary", "type": "main", "index": 0}]]}}, "active": false, "settings": {}, "versionId": "sc-kpi-v1"}
Fastest regulatory clock in this stack
DOT PHMSA §171.15(a) — 30 minutes. When a vehicle transporting hazardous materials has an incident resulting in death, hospitalization, or a reportable quantity release, the carrier must notify the NRC hotline (1-800-424-8802) by telephone immediately — defined as within 30 minutes of discovery.
The clock starts when your driver discovers the incident, not when your compliance team is notified. If your incident detection workflow relies on a cloud iPaaS step that introduces any delay, you may miss the verbatim telephone report window required by §171.15(a).
Self-hosted n8n running in your datacenter eliminates that cloud-call latency from the critical path.
n8n vs. Zapier/Make for supply chain compliance
| Capability | Zapier | Make | n8n (self-hosted) |
|---|---|---|---|
| CBP ISF data in network boundary | No | No | Yes |
| FDA FSVP records available on-prem | No | No | Yes |
| 30-min PHMSA clock — no cloud latency | Risky | Risky | Yes |
| CTPAT profile data stays internal | No | No | Yes |
| SOC 2 CC9.2 — zero subprocessor chain | No | No | Yes |
| Postgres audit trail — INSERT-only | Limited | Limited | Yes |
| Custom HOS/DQ file validation logic | Limited | Limited | Full code nodes |
Get the complete workflow pack
All 5 workflows above — plus 10 more for supply chain, logistics, and customs compliance operations — are available in the FlowKit n8n Automation Pack at stripeai.gumroad.com.
Individual templates: $12–$29. Full bundle (15 workflows): $97.
Built by the FlowKit team. Self-host n8n. Keep your compliance data where it belongs.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.