Dev.to Security 🔐 Cybersecurity 👁 1 📖 20 min read

n8n for Pharma/Biotech SaaS Vendors: 5 Automations for FDA cGMP, FAERS, DSCSA, and DEA Compliance (Free Workflow JSON)

If your SaaS platform serves pharmaceutical manufacturers, commercial drug ops, CMOs/CDMOs, or drug safety reporting teams — this article shows five production-ready n8n workflows with full import-ready JSON. Target aud

If your SaaS platform serves pharmaceutical manufacturers, commercial drug ops, CMOs/CDMOs, or drug safety reporting teams — this article shows five production-ready n8n workflows with full import-ready JSON.

Target audience: Pharma/Biotech SaaS VENDORS — companies building software for commercial drug operations, cGMP manufacturing, regulatory submissions, FAERS/EudraVigilance reporting, DSCSA serialization, and DEA controlled substance management. Distinct from clinical trial management platforms (CRO/CTMS/eTMF covered separately).

Compliance stack at a glance

Regulation Scope Fastest clock
FDA 21 CFR §314.81(b)(2)(iii) FAERS 15-day expedited ADR reporting 360 hours
DEA 21 CFR §1301.76 Controlled substance theft/loss Form 106 1 business day
FDA 21 CFR §211.68 cGMP computer systems validation Annual review
FDA 21 CFR §211.180(e) Annual Product Review (APR) Calendar year
21 USC §582 DSCSA Drug Supply Chain Security Act serialization 24h quarantine
ICH E6(R3) §5.18 GCP sponsor annual audit Annual
EU CTR Reg 536/2014 Art.17 EMA SUSAR expedited report 360 hours
DEA 21 CFR §1304.11 Biennial controlled substance inventory Every 2 years

Why self-hosted n8n? FDA 21 CFR §211.68 requires that computer systems used in cGMP operations be validated — which means your workflow automation platform is itself a validated GMP system. Routing batch release decisions or FAERS data through a third-party multi-tenant SaaS (like Zapier) adds that vendor to your validation scope, your Annual Product Review, and your FDA inspection package. Self-hosted n8n is an internal tool your QA team validates once with a single URS/IQ/OQ/PQ package.

Customer tiers

Tier Profile
LARGE_INTEGRATED_PHARMA ≥$10M ARR or ≥5,000 employees — Big Pharma, NDA/BLA holders
MID_MARKET_SPECIALTY_PHARMA ≥$2M ARR or ≥500 employees — specialty pharma companies
CMO_CDMO_SAAS_VENDOR Contract manufacturing organizations — GMP facility operators
DRUG_SAFETY_REPORTING_SAAS FAERS/EudraVigilance reporting platforms — ICH E2B R3
REGULATORY_SUBMISSION_PLATFORM eCTD/eDossier submission tools — FDA/EMA filing
PHARMA_SUPPLY_CHAIN_SAAS DSCSA serialization, DEA ordering systems, cold chain
EMERGING_BIOTECH_PLATFORM Pre-commercial biotech — IND holders, Phase III transition

Compliance flags

Flag Regulation
FDA_PART_312_IND_SUBJECT 21 CFR Part 312 — IND holder obligations
FDA_PART_211_CGMP_REQUIRED 21 CFR Part 211 — Current Good Manufacturing Practice
FDA_FAERS_MANDATORY_REPORTER 21 CFR §314.81 — NDA/BLA holder FAERS reporter
DEA_SCHEDULE_CONTROLLED_SUBSTANCE 21 CFR Parts 1301-1321 — DEA registration
ICH_E6_R3_GCP_REQUIRED ICH E6(R3) — GCP sponsor/CRO obligations
EMA_SUSAR_REPORTER EU CTR Reg 536/2014 Art.17 — EudraVigilance
FDA_SERIALIZATION_DSCSA_COVERED 21 USC §582 — DSCSA lot-level traceability

Workflow 1: Pharma/Biotech Customer Onboarding Drip

Triggers from a new row in Google Sheets. A Code node classifies the customer into one of seven tiers and injects compliance flags (FAERS reporter, DEA registration, DSCSA covered, GCP scope). Day 0 email includes a §211.68 computer validation checklist for cGMP-regulated customers, FAERS 15-day clock activation instructions for NDA/BLA holders, and DEA §1301.76 security requirements for controlled substance customers. Day 3 email covers API endpoint connection and DSCSA §582.415 quarantine duty configuration. Day 7 triggers a walkthrough invite for APR and FAERS tracking.

{
  "name": "Pharma/Biotech Customer Onboarding Drip",
  "nodes": [
    {
      "id": "1",
      "name": "New Customer Row",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "parameters": {
        "event": "rowAdded",
        "sheetId": "YOUR_SHEET_ID",
        "range": "Customers!A:Z"
      },
      "position": [
        0,
        0
      ]
    },
    {
      "id": "2",
      "name": "Classify Tier + Flags",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "\nconst row = $json;\nconst arr_usd = parseFloat(row.arr_usd || 0);\nconst employees = parseInt(row.employees || 0);\nlet tier = 'EMERGING_BIOTECH_PLATFORM';\nif (arr_usd >= 10000000 || employees >= 5000) tier = 'LARGE_INTEGRATED_PHARMA';\nelse if (arr_usd >= 2000000 || employees >= 500) tier = 'MID_MARKET_SPECIALTY_PHARMA';\nelse if ((row.customer_type || '').includes('CMO') || (row.customer_type || '').includes('CDMO')) tier = 'CMO_CDMO_SAAS_VENDOR';\nelse if ((row.customer_type || '').includes('DRUG_SAFETY')) tier = 'DRUG_SAFETY_REPORTING_SAAS';\nelse if ((row.customer_type || '').includes('REGULATORY_SUBMISSION')) tier = 'REGULATORY_SUBMISSION_PLATFORM';\nelse if ((row.customer_type || '').includes('SUPPLY_CHAIN')) tier = 'PHARMA_SUPPLY_CHAIN_SAAS';\nconst flags = [];\nif ((row.regulated_product_types || '').includes('IND')) flags.push('FDA_PART_312_IND_SUBJECT');\nif ((row.regulated_product_types || '').includes('NDA') || (row.regulated_product_types || '').includes('BLA')) flags.push('FDA_PART_211_CGMP_REQUIRED');\nif ((row.faers_reporter || '') === 'yes') flags.push('FDA_FAERS_MANDATORY_REPORTER');\nif ((row.dea_registration || '') === 'yes') flags.push('DEA_SCHEDULE_CONTROLLED_SUBSTANCE');\nif ((row.gcp_scope || '') === 'yes') flags.push('ICH_E6_R3_GCP_REQUIRED');\nif ((row.ema_scope || '') === 'yes') flags.push('EMA_SUSAR_REPORTER');\nif ((row.dscsa_covered || '') === 'yes') flags.push('FDA_SERIALIZATION_DSCSA_COVERED');\nreturn [{json: {...row, tier, compliance_flags: flags.join(',')} }];\n"
      },
      "position": [
        200,
        0
      ]
    },
    {
      "id": "3",
      "name": "Day 0 Email",
      "type": "n8n-nodes-base.gmail",
      "parameters": {
        "to": "={{$json.contact_email}}",
        "subject": "Welcome to FlowKit \u2014 your cGMP automation is live",
        "message": "={{$json.tier === 'LARGE_INTEGRATED_PHARMA' ? 'Your enterprise FDA \u00a7211.68 computer validation checklist is attached. FAERS 15-day clock monitoring activates today.' : $json.compliance_flags.includes('FDA_FAERS_MANDATORY_REPORTER') ? 'Your FAERS 15-day expedited reporting workflow is now active. First MedWatch 3500A window: 360h from first awareness.' : $json.compliance_flags.includes('DEA_SCHEDULE_CONTROLLED_SUBSTANCE') ? 'DEA \u00a71301.76 security requirements guide attached. Controlled substance theft/loss Form 106 clock: 1 business day.' : 'Your n8n automation environment is ready. Start with the cGMP deviation pipeline.'}}"
      },
      "position": [
        400,
        0
      ]
    },
    {
      "id": "4",
      "name": "Log to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "operation": "appendOrUpdate",
        "sheetId": "YOUR_SHEET_ID",
        "range": "OnboardingAudit!A:F",
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{new Date().toISOString()}}",
            "customer_email": "={{$json.contact_email}}",
            "tier": "={{$json.tier}}",
            "flags": "={{$json.compliance_flags}}",
            "day0_sent": "true"
          }
        }
      },
      "position": [
        600,
        0
      ]
    },
    {
      "id": "5",
      "name": "Wait 3 Days",
      "type": "n8n-nodes-base.wait",
      "parameters": {
        "unit": "days",
        "amount": 3
      },
      "position": [
        800,
        0
      ]
    },
    {
      "id": "6",
      "name": "Day 3 Email",
      "type": "n8n-nodes-base.gmail",
      "parameters": {
        "to": "={{$json.contact_email}}",
        "subject": "FlowKit tip: connect your FDA API endpoints",
        "message": "Connect your manufacturing_execution_api for \u00a7211.68 validation monitoring. If you're a FAERS reporter, review the 15-day expedited window mapping. DSCSA \u00a7582.415 quarantine duty: system must flag suspect product within 24h of receipt."
      },
      "position": [
        1000,
        0
      ]
    },
    {
      "id": "7",
      "name": "Wait 4 Days",
      "type": "n8n-nodes-base.wait",
      "parameters": {
        "unit": "days",
        "amount": 4
      },
      "position": [
        1200,
        0
      ]
    },
    {
      "id": "8",
      "name": "Day 7 Email",
      "type": "n8n-nodes-base.gmail",
      "parameters": {
        "to": "={{$json.contact_email}}",
        "subject": "FlowKit power features: cGMP deadline tracker + FAERS pipeline",
        "message": "Ready to go deeper? Book a walkthrough: (1) cGMP annual product review \u00a7211.180(e) deadline automation, (2) FAERS 15-day expedited vs periodic distinction, (3) DEA biennial controlled substance inventory \u00a71304.11."
      },
      "position": [
        1400,
        0
      ]
    }
  ],
  "connections": {
    "New Customer Row": {
      "main": [
        [
          {
            "node": "Classify Tier + Flags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Tier + Flags": {
      "main": [
        [
          {
            "node": "Day 0 Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Day 0 Email": {
      "main": [
        [
          {
            "node": "Log to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Sheets": {
      "main": [
        [
          {
            "node": "Wait 3 Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3 Days": {
      "main": [
        [
          {
            "node": "Day 3 Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Day 3 Email": {
      "main": [
        [
          {
            "node": "Wait 4 Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 4 Days": {
      "main": [
        [
          {
            "node": "Day 7 Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Workflow 2: Manufacturing & Regulatory API Health Monitor

Runs every 3 minutes. Checks five endpoints: manufacturing_execution_api (21 CFR §211.68 validation gap if down), faers_reporting_api (FAERS 15-day clock at risk if down), dscsa_serialization_api (§582.415 quarantine duty at risk), dea_order_system_api (CSOS electronic ordering integrity), and regulatory_submission_api (eCTD/eDossier delivery risk). $getWorkflowStaticData tracks UP→DOWN state transitions so you only get alerts on state changes, not every poll. Incidents logged to Postgres with ON CONFLICT DO NOTHING so a single event generates one row.

{
  "name": "Manufacturing & Regulatory API Health Monitor",
  "nodes": [
    {
      "id": "1",
      "name": "Every 3 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 3
            }
          ]
        }
      },
      "position": [
        0,
        0
      ]
    },
    {
      "id": "2",
      "name": "Load State",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "const state = $getWorkflowStaticData('global'); return [{json: {state}}];"
      },
      "position": [
        200,
        0
      ]
    },
    {
      "id": "3",
      "name": "Check 5 Endpoints",
      "type": "n8n-nodes-base.splitInBatches",
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "position": [
        400,
        0
      ]
    },
    {
      "id": "4",
      "name": "HTTP Ping",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "={{$json.url}}",
        "method": "GET",
        "timeout": 5000,
        "continueOnFail": true
      },
      "position": [
        600,
        0
      ]
    },
    {
      "id": "5",
      "name": "Classify Status",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "\nconst ep = $('Check 5 Endpoints').item.json;\nconst resp = $json;\nconst state = $('Load State').first().json.state || {};\nconst now = Date.now();\nlet status = 'UP';\nlet regulation = '';\nif (resp.error || resp.statusCode >= 500) {\n  status = 'DOWN';\n  if (ep.name === 'manufacturing_execution_api') regulation = '21 CFR \u00a7211.68 \u2014 computer systems validation gap; manufacturing execution audit trail at risk';\n  else if (ep.name === 'faers_reporting_api') regulation = '21 CFR \u00a7314.81(b)(2)(iii) \u2014 FAERS 15-day expedited report clock; MedWatch 3500A submission at risk';\n  else if (ep.name === 'dscsa_serialization_api') regulation = '21 USC \u00a7582.415 \u2014 DSCSA suspect product quarantine duty; 24h isolation clock at risk';\n  else if (ep.name === 'dea_order_system_api') regulation = '21 CFR \u00a71301.76 \u2014 DEA CSOS electronic order system; controlled substance order integrity at risk';\n  else if (ep.name === 'regulatory_submission_api') regulation = 'FDA eCTD/eDossier \u2014 eCTD module submission gap; NDA/BLA dossier delivery risk';\n} else if ((resp.response_time_ms || 0) > 3000) {\n  status = 'DEGRADED';\n  if (ep.name === 'faers_reporting_api') regulation = '21 CFR \u00a7314.81(b)(2)(iii) \u2014 FAERS reporting latency; 15-day expedited clock must not be blocked';\n}\nconst key = ep.name + '_status';\nconst prevStatus = state[key] || 'UP';\nconst prevTs = state[key + '_ts'] || 0;\nconst alert = (status !== 'UP' && status !== prevStatus) || (status !== 'UP' && (now - prevTs) > 1800000);\nstate[key] = status; state[key + '_ts'] = now;\n$setWorkflowStaticData('global', state);\nreturn [{json: {endpoint: ep.name, status, regulation, prevStatus, alert, url: ep.url}}];\n"
      },
      "position": [
        800,
        0
      ]
    },
    {
      "id": "6",
      "name": "IF Alert",
      "type": "n8n-nodes-base.if",
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json.alert}}",
              "value2": true
            }
          ]
        }
      },
      "position": [
        1000,
        0
      ]
    },
    {
      "id": "7",
      "name": "Slack Alert",
      "type": "n8n-nodes-base.slack",
      "parameters": {
        "channel": "#pharma-ops",
        "text": "={{$json.status}} \u2014 `{{$json.endpoint}}`: {{$json.regulation}}"
      },
      "position": [
        1200,
        100
      ]
    },
    {
      "id": "8",
      "name": "Log Incident",
      "type": "n8n-nodes-base.postgres",
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO pharma_incidents (endpoint, status, regulation, ts) VALUES ('{{$json.endpoint}}', '{{$json.status}}', '{{$json.regulation}}', NOW()) ON CONFLICT DO NOTHING"
      },
      "position": [
        1200,
        -100
      ]
    }
  ],
  "connections": {
    "Every 3 Minutes": {
      "main": [
        [
          {
            "node": "Load State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load State": {
      "main": [
        [
          {
            "node": "Check 5 Endpoints",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check 5 Endpoints": {
      "main": [
        [
          {
            "node": "HTTP Ping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Ping": {
      "main": [
        [
          {
            "node": "Classify Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Status": {
      "main": [
        [
          {
            "node": "IF Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Alert": {
      "main": [
        [
          {
            "node": "Slack Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Incident",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Workflow 3: FDA/ICH/DEA/DSCSA Compliance Deadline Tracker

Runs weekdays at 8AM. Loads deadline rows from Google Sheets and classifies urgency: OVERDUE, CRITICAL (≤14d), URGENT (≤30d), WARNING (≤60d), NOTICE (≤90d). Uses alert_sent_date to dedup same-day re-alerts. Routes OVERDUE/CRITICAL to Slack @here plus Gmail. Covers 12 deadline types:

Deadline Regulation
FDA_FAERS_15DAY_EXPEDITED_REPORT 21 CFR §314.81(b)(2)(iii)
FDA_NDA_PERIODIC_SAFETY_UPDATE 21 CFR §314.81(b)(2)(ii)
FDA_IND_ANNUAL_PROGRESS_REPORT 21 CFR §312.33
FDA_CGMP_ANNUAL_PRODUCT_REVIEW 21 CFR §211.180(e)
DEA_BIENNIAL_INVENTORY 21 CFR §1304.11
DSCSA_SERIALIZATION_ANNUAL_AUDIT 21 USC §582
ICH_E6_GCP_ANNUAL_AUDIT ICH E6(R3) §5.18
EMA_PSUR_PERIODIC EU CTR Reg 536/2014 Art.35
FDA_COMPUTER_VALIDATION_ANNUAL 21 CFR §211.68
FDA_RISK_MANAGEMENT_REMS 21 USC §355-1
SOC2_TYPE2_RENEWAL SOC 2 CC7.2
ANNUAL_PENTEST FDA Cybersecurity Guidance 2023
{
  "name": "FDA/ICH/DEA/DSCSA Compliance Deadline Tracker",
  "nodes": [
    {
      "id": "1",
      "name": "Weekdays 8AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1-5"
            }
          ]
        }
      },
      "position": [
        0,
        0
      ]
    },
    {
      "id": "2",
      "name": "Load Deadlines",
      "type": "n8n-nodes-base.googleSheets",
      "parameters": {
        "operation": "read",
        "sheetId": "YOUR_SHEET_ID",
        "range": "PharmaDeadlines!A:F"
      },
      "position": [
        200,
        0
      ]
    },
    {
      "id": "3",
      "name": "Classify Urgency",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "\nconst deadlines = $input.all().map(i => i.json);\nconst now = new Date();\nconst actionMap = {\n  'FDA_FAERS_15DAY_EXPEDITED_REPORT': {label: 'FAERS 15-day expedited ADR report', reg: '21 CFR \u00a7314.81(b)(2)(iii) \u2014 MedWatch 3500A', urgencyDays: 1},\n  'FDA_NDA_PERIODIC_SAFETY_UPDATE': {label: 'NDA Periodic Safety Update', reg: '21 CFR \u00a7314.81(b)(2)(ii) \u2014 Annual IND/NDA safety update', urgencyDays: 30},\n  'FDA_IND_ANNUAL_PROGRESS_REPORT': {label: 'IND Annual Progress Report', reg: '21 CFR \u00a7312.33 \u2014 within 60 days of IND anniversary', urgencyDays: 21},\n  'FDA_CGMP_ANNUAL_PRODUCT_REVIEW': {label: 'Annual Product Review (APR)', reg: '21 CFR \u00a7211.180(e) \u2014 within calendar year of prior review', urgencyDays: 30},\n  'DEA_BIENNIAL_INVENTORY': {label: 'DEA Biennial Controlled Substance Inventory', reg: '21 CFR \u00a71304.11 \u2014 biennial inventory every 2 years', urgencyDays: 14},\n  'DSCSA_SERIALIZATION_ANNUAL_AUDIT': {label: 'DSCSA Serialization Compliance Audit', reg: '21 USC \u00a7582 \u2014 Drug Supply Chain Security Act lot traceability', urgencyDays: 14},\n  'ICH_E6_GCP_ANNUAL_AUDIT': {label: 'GCP Sponsor Audit', reg: 'ICH E6(R3) \u00a75.18 \u2014 annual GCP audit of contract vendors', urgencyDays: 14},\n  'EMA_PSUR_PERIODIC': {label: 'EMA Periodic Safety Update Report', reg: 'EU CTR Reg 536/2014 Art.35 \u2014 PSUR submission', urgencyDays: 21},\n  'FDA_COMPUTER_VALIDATION_ANNUAL': {label: 'Computer Systems Validation Review', reg: '21 CFR \u00a7211.68 \u2014 annual review of critical GMP systems', urgencyDays: 14},\n  'FDA_RISK_MANAGEMENT_REMS': {label: 'REMS Assessment Report', reg: '21 USC \u00a7355-1 \u2014 REMS assessment at 18mo, 3yr, 7yr intervals', urgencyDays: 30},\n  'SOC2_TYPE2_RENEWAL': {label: 'SOC 2 Type II Audit Renewal', reg: 'SOC 2 CC7.2 \u2014 vendor management evidence for pharma procurement', urgencyDays: 21},\n  'ANNUAL_PENTEST': {label: 'Annual Penetration Test', reg: 'FDA cybersecurity guidance (2023) + NIST SP 800-115', urgencyDays: 14}\n};\nconst results = [];\nfor (const d of deadlines) {\n  const dueDate = new Date(d.due_date);\n  const daysLeft = Math.floor((dueDate - now) / 86400000);\n  const cfg = actionMap[d.deadline_type] || {label: d.deadline_type, reg: '', urgencyDays: 30};\n  let urgency = null;\n  if (daysLeft < 0) urgency = 'OVERDUE';\n  else if (daysLeft <= 14) urgency = 'CRITICAL';\n  else if (daysLeft <= 30) urgency = 'URGENT';\n  else if (daysLeft <= 60) urgency = 'WARNING';\n  else if (daysLeft <= 90) urgency = 'NOTICE';\n  if (urgency && d.alert_sent_date !== new Date().toISOString().slice(0,10)) {\n    results.push({json: {...d, urgency, days_left: daysLeft, label: cfg.label, regulation: cfg.reg}});\n  }\n}\nreturn results.length ? results : [{json: {skip: true}}];\n"
      },
      "position": [
        400,
        0
      ]
    },
    {
      "id": "4",
      "name": "IF Skip",
      "type": "n8n-nodes-base.if",
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{!$json.skip}}",
              "value2": true
            }
          ]
        }
      },
      "position": [
        600,
        0
      ]
    },
    {
      "id": "5",
      "name": "Route by Urgency",
      "type": "n8n-nodes-base.switch",
      "parameters": {
        "dataType": "string",
        "value1": "={{$json.urgency}}",
        "rules": {
          "rules": [
            {
              "value2": "OVERDUE",
              "outputKey": "0"
            },
            {
              "value2": "CRITICAL",
              "outputKey": "1"
            },
            {
              "value2": "URGENT",
              "outputKey": "2"
            },
            {
              "value2": "WARNING",
              "outputKey": "3"
            },
            {
              "value2": "NOTICE",
              "outputKey": "4"
            }
          ]
        }
      },
      "position": [
        800,
        0
      ]
    },
    {
      "id": "6",
      "name": "Slack @here Critical",
      "type": "n8n-nodes-base.slack",
      "parameters": {
        "channel": "#compliance-ops",
        "text": "={{$json.urgency}} \u2014 {{$json.label}} ({{$json.days_left}}d): {{$json.regulation}}"
      },
      "position": [
        1000,
        0
      ]
    },
    {
      "id": "7",
      "name": "Gmail Owner",
      "type": "n8n-nodes-base.gmail",
      "parameters": {
        "to": "={{$json.owner_email}}",
        "subject": "={{$json.urgency}}: {{$json.label}} \u2014 {{$json.days_left}} days",
        "message": "={{$json.label}} is {{$json.urgency}}. Days remaining: {{$json.days_left}}. Regulation: {{$json.regulation}}. Action required by: {{$json.due_date}}."
      },
      "position": [
        1000,
        200
      ]
    }
  ],
  "connections": {
    "Weekdays 8AM": {
      "main": [
        [
          {
            "node": "Load Deadlines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Deadlines": {
      "main": [
        [
          {
            "node": "Classify Urgency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Urgency": {
      "main": [
        [
          {
            "node": "IF Skip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Skip": {
      "main": [
        [
          {
            "node": "Route by Urgency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Urgency": {
      "main": [
        [
          {
            "node": "Slack @here Critical",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Slack @here Critical",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail Owner",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail Owner",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Gmail Owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Workflow 4: Drug Safety & FAERS Incident Pipeline

Webhook-triggered. Classifies eight incident types with regulatory clocks:

Incident Clock Regulation
FAERS_15DAY_EXPEDITED_REPORT_DUE 360h 21 CFR §314.81(b)(2)(iii)
DEA_CONTROLLED_SUBSTANCE_THEFT_LOSS 8h (1 biz day) 21 CFR §1301.76
FDA_RECALL_CLASS_I 24h 21 CFR §7.55
CGMP_CRITICAL_PROCESS_DEVIATION 72h 21 CFR §211.192
DSCSA_SUSPECT_PRODUCT_DETECTION 24h 21 USC §582.415
EMA_SUSAR_EXPEDITED_REPORT 360h EU CTR Art.17
FDA_OAI_WARNING_LETTER 360h (15 biz days) 21 CFR §16.5
FDA_COMPUTER_VALIDATION_DEVIATION 168h 21 CFR §211.68

$getWorkflowStaticData prevents duplicate alerts within 30 minutes per incident ID. All incidents logged to Postgres with ON CONFLICT (incident_id) DO NOTHING.

{
  "name": "Drug Safety & FAERS Incident Pipeline",
  "nodes": [
    {
      "id": "1",
      "name": "Webhook Intake",
      "type": "n8n-nodes-base.webhook",
      "parameters": {
        "path": "pharma-incident",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "position": [
        0,
        0
      ]
    },
    {
      "id": "2",
      "name": "Classify Incident",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "\nconst ev = $json;\nconst state = $getWorkflowStaticData('global');\nconst now = Date.now();\nconst key = (ev.incident_type || '') + '_' + (ev.incident_id || '');\nif (state[key] && (now - state[key]) < 1800000) return [{json: {skip: true, incident_id: ev.incident_id}}];\nstate[key] = now;\n$setWorkflowStaticData('global', state);\nconst incidentMap = {\n  'FAERS_15DAY_EXPEDITED_REPORT_DUE': {severity: 'CRITICAL', hours: 360, label: 'FAERS 15-Day Expedited Safety Report', reg: '21 CFR \u00a7314.81(b)(2)(iii) \u2014 unexpected serious ADR in marketed drug; MedWatch 3500A to FDA FAERS within 15 calendar days', channel: '#regulatory-safety'},\n  'DEA_CONTROLLED_SUBSTANCE_THEFT_LOSS': {severity: 'CRITICAL', hours: 8, label: 'DEA Controlled Substance Theft/Loss', reg: '21 CFR \u00a71301.76 \u2014 DEA Form 106 within 1 business day of discovery; Schedule II requires immediate notification to DEA field office', channel: '#pharma-ops'},\n  'FDA_RECALL_CLASS_I': {severity: 'CRITICAL', hours: 24, label: 'FDA Class I Recall Initiation', reg: '21 CFR \u00a77.55 \u2014 most serious health hazard; recall strategy must be submitted to FDA district within 24h of product recall decision', channel: '#regulatory-safety'},\n  'CGMP_CRITICAL_PROCESS_DEVIATION': {severity: 'HIGH', hours: 72, label: 'cGMP Critical Process Deviation', reg: '21 CFR \u00a7211.192 \u2014 investigation must be completed before batch release; CAPA initiated within 3 business days', channel: '#quality-ops'},\n  'DSCSA_SUSPECT_PRODUCT_DETECTION': {severity: 'HIGH', hours: 24, label: 'DSCSA Suspect Product Detection', reg: '21 USC \u00a7582.415 \u2014 trading partner notification and product quarantine within 24h of suspect product identification', channel: '#pharma-ops'},\n  'EMA_SUSAR_EXPEDITED_REPORT': {severity: 'HIGH', hours: 360, label: 'EMA SUSAR Expedited Report', reg: 'EU CTR Reg 536/2014 Art.17 \u2014 Suspected Unexpected Serious Adverse Reaction to EudraVigilance within 15 days', channel: '#regulatory-safety'},\n  'FDA_OAI_WARNING_LETTER': {severity: 'HIGH', hours: 360, label: 'FDA OAI/Warning Letter Response', reg: '21 CFR \u00a716.5 \u2014 CAPA response plan within 15 business days; unresolved = consent decree risk', channel: '#regulatory-safety'},\n  'FDA_COMPUTER_VALIDATION_DEVIATION': {severity: 'MEDIUM', hours: 168, label: 'GMP Computer Validation Deviation', reg: '21 CFR \u00a7211.68 \u2014 validation deficiency documented in CAPA system within 5 business days; impacts batch release if critical'}\n};\nconst cfg = incidentMap[ev.incident_type] || {severity: 'MEDIUM', hours: 72, label: ev.incident_type, reg: 'Review applicable cGMP/FAERS/DSCSA regulation', channel: '#pharma-ops'};\nreturn [{json: {...ev, ...cfg, response_deadline: new Date(now + cfg.hours * 3600000).toISOString()}}];\n"
      },
      "position": [
        200,
        0
      ]
    },
    {
      "id": "3",
      "name": "IF Skip",
      "type": "n8n-nodes-base.if",
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{!$json.skip}}",
              "value2": true
            }
          ]
        }
      },
      "position": [
        400,
        0
      ]
    },
    {
      "id": "4",
      "name": "Slack Emergency",
      "type": "n8n-nodes-base.slack",
      "parameters": {
        "channel": "={{$json.channel}}",
        "text": "={{$json.severity}}: {{$json.label}} | Deadline: {{$json.response_deadline}} | {{$json.reg}}"
      },
      "position": [
        600,
        100
      ]
    },
    {
      "id": "5",
      "name": "Log to Postgres",
      "type": "n8n-nodes-base.postgres",
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO pharma_incidents (incident_id, type, severity, regulation, response_deadline, ts) VALUES ('{{$json.incident_id}}', '{{$json.incident_type}}', '{{$json.severity}}', '{{$json.reg}}', '{{$json.response_deadline}}', NOW()) ON CONFLICT (incident_id) DO NOTHING"
      },
      "position": [
        600,
        -100
      ]
    },
    {
      "id": "6",
      "name": "ACK 200",
      "type": "n8n-nodes-base.respondToWebhook",
      "parameters": {
        "responseCode": 200,
        "responseBody": "={\"incident_id\": \"{{$json.incident_id}}\", \"severity\": \"{{$json.severity}}\", \"response_deadline\": \"{{$json.response_deadline}}\", \"regulation\": \"{{$json.reg}}\"}"
      },
      "position": [
        800,
        0
      ]
    }
  ],
  "connections": {
    "Webhook Intake": {
      "main": [
        [
          {
            "node": "Classify Incident",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Incident": {
      "main": [
        [
          {
            "node": "IF Skip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Skip": {
      "main": [
        [
          {
            "node": "Slack Emergency",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Emergency": {
      "main": [
        [
          {
            "node": "Log to Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Postgres": {
      "main": [
        [
          {
            "node": "ACK 200",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Workflow 5: Weekly Pharma Platform KPI Dashboard

Runs Monday 8AM. Two parallel Postgres queries: platform metrics (total customers, ARR by tier, new accounts 7d) and compliance events (FAERS 15-day open, DEA incidents, FDA recall open, cGMP deviations open). Merges, calculates WoW% ARR via $getWorkflowStaticData, and builds a color-coded HTML table. Subject line flags: [FAERS 15-DAY OPEN], [DEA CONTROLLED SUBSTANCE INCIDENT THIS WEEK], [FDA RECALL CLASS I OPEN], [CGMP DEVIATION OPEN]. Sends to CEO, BCC CISO.

{
  "name": "Weekly Pharma Platform KPI Dashboard",
  "nodes": [
    {
      "id": "1",
      "name": "Monday 8AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "position": [
        0,
        0
      ]
    },
    {
      "id": "2",
      "name": "Fetch Platform Metrics",
      "type": "n8n-nodes-base.postgres",
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT COUNT(*) as total_pharma_customers, SUM(arr_usd) as total_arr, SUM(CASE WHEN tier='LARGE_INTEGRATED_PHARMA' THEN arr_usd ELSE 0 END) as enterprise_arr, COUNT(CASE WHEN created_at >= NOW()-INTERVAL '7 days' THEN 1 END) as new_customers_7d FROM pharma_customers"
      },
      "position": [
        200,
        100
      ]
    },
    {
      "id": "3",
      "name": "Fetch Compliance Events",
      "type": "n8n-nodes-base.postgres",
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT COUNT(CASE WHEN type='FAERS_15DAY_EXPEDITED_REPORT_DUE' AND ts >= NOW()-INTERVAL '7 days' THEN 1 END) as faers_15day_open, COUNT(CASE WHEN type='DEA_CONTROLLED_SUBSTANCE_THEFT_LOSS' AND ts >= NOW()-INTERVAL '7 days' THEN 1 END) as dea_theft_this_week, COUNT(CASE WHEN type='FDA_RECALL_CLASS_I' AND ts >= NOW()-INTERVAL '7 days' THEN 1 END) as fda_recall_open, COUNT(CASE WHEN type='CGMP_CRITICAL_PROCESS_DEVIATION' AND status='OPEN' THEN 1 END) as cgmp_deviations_open FROM pharma_incidents"
      },
      "position": [
        200,
        -100
      ]
    },
    {
      "id": "4",
      "name": "Merge Metrics",
      "type": "n8n-nodes-base.merge",
      "parameters": {
        "mode": "multiplex"
      },
      "position": [
        400,
        0
      ]
    },
    {
      "id": "5",
      "name": "Build KPI Report",
      "type": "n8n-nodes-base.code",
      "parameters": {
        "jsCode": "\nconst state = $getWorkflowStaticData('global');\nconst platform = $input.all()[0].json;\nconst compliance = $input.all()[1].json;\nconst prevArr = state.prev_arr || 0;\nconst arrWow = prevArr > 0 ? (((platform.total_arr - prevArr) / prevArr) * 100).toFixed(1) : 'N/A';\nstate.prev_arr = platform.total_arr;\n$setWorkflowStaticData('global', state);\nconst flags = [];\nif (compliance.faers_15day_open > 0) flags.push('[FAERS 15-DAY OPEN]');\nif (compliance.dea_theft_this_week > 0) flags.push('[DEA CONTROLLED SUBSTANCE INCIDENT THIS WEEK]');\nif (compliance.fda_recall_open > 0) flags.push('[FDA RECALL CLASS I OPEN]');\nif (compliance.cgmp_deviations_open > 0) flags.push('[CGMP DEVIATION OPEN]');\nconst subject = `Weekly Pharma KPI ${flags.length ? flags.join(' ') : '\u2014 No critical compliance events'}`;\nconst arrColor = parseFloat(arrWow) >= 5 ? '#2ecc71' : parseFloat(arrWow) >= 0 ? '#f39c12' : '#e74c3c';\nconst html = '<h2>FlowKit \u2014 Weekly Pharma Platform KPI</h2><table border=1 cellpadding=6><tr><th>Metric</th><th>Value</th><th>WoW</th></tr>' +\n  '<tr><td>Total Pharma Customers</td><td>' + platform.total_pharma_customers + '</td><td>\u2014</td></tr>' +\n  '<tr><td>Total ARR</td><td>$' + Number(platform.total_arr).toLocaleString() + '</td><td style=\"color:' + arrColor + '\">' + arrWow + '%</td></tr>' +\n  '<tr><td>Enterprise ARR</td><td>$' + Number(platform.enterprise_arr).toLocaleString() + '</td><td>\u2014</td></tr>' +\n  '<tr><td>New Customers (7d)</td><td>' + platform.new_customers_7d + '</td><td>\u2014</td></tr>' +\n  '</table><h3>Compliance Events</h3><ul>' +\n  '<li>FAERS 15-Day Open: ' + compliance.faers_15day_open + '</li>' +\n  '<li>DEA Incidents (7d): ' + compliance.dea_theft_this_week + '</li>' +\n  '<li>FDA Recall Class I Open: ' + compliance.fda_recall_open + '</li>' +\n  '<li>cGMP Deviations Open: ' + compliance.cgmp_deviations_open + '</li></ul>';\nreturn [{json: {subject, html}}];\n"
      },
      "position": [
        600,
        0
      ]
    },
    {
      "id": "6",
      "name": "Gmail CEO",
      "type": "n8n-nodes-base.gmail",
      "parameters": {
        "to": "[email protected]",
        "bcc": "[email protected]",
        "subject": "={{$json.subject}}",
        "message": "={{$json.html}}"
      },
      "position": [
        800,
        0
      ]
    }
  ],
  "connections": {
    "Monday 8AM": {
      "main": [
        [
          {
            "node": "Fetch Platform Metrics",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch Compliance Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Platform Metrics": {
      "main": [
        [
          {
            "node": "Merge Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Compliance Events": {
      "main": [
        [
          {
            "node": "Merge Metrics",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Metrics": {
      "main": [
        [
          {
            "node": "Build KPI Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build KPI Report": {
      "main": [
        [
          {
            "node": "Gmail CEO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Why self-hosted n8n wins in pharma

Compliance requirement Cloud iPaaS problem Self-hosted n8n fix
21 CFR §211.68 computer validation Third-party SaaS = additional validated system in scope Self-hosted n8n validated once with single URS/IQ/OQ/PQ package
FAERS 15-day clock SaaS outage = FDA regulatory exposure; no SLA covers §314.81 n8n runs on your VPC; FAERS timing is your responsibility, not a vendor's
DEA §1301.76 controlled substance data Controlled substance order/inventory data traverses vendor cloud DEA-sensitive data stays within DEA-registered facility perimeter
DSCSA §582 lot traceability DSCSA lot records in third-party cloud create subpoena target Postgres on your server = DSCSA audit trail under your control
FDA 21 CFR Part 11 audit trail 30-day SaaS log retention vs Part 11 permanent retention requirement Postgres INSERT-only with RLS = tamper-evident permanent record

5 buyer Q&A

Q: Does self-hosted n8n appear in our FDA validation package?
A: Yes — n8n is a GMP computer system under §211.68. But a single URS/IQ/OQ/PQ covers the installation once. Cloud iPaaS requires you to validate every new version release. n8n version upgrades are your timeline, not a vendor's SaaS release schedule.

Q: How does the FAERS 15-day pipeline handle the first-awareness date?
A: The Webhook Intake captures a first_awareness_date field. The incident pipeline calculates the 15-calendar-day window from that date, not from receipt — matching FDA's §314.81(b)(2)(iii) requirement. Postgres stores the awareness timestamp immutably.

Q: Can we route DEA Form 106 data through the workflow?
A: DEA CSOS and Form 106 data are DEA-sensitive and should remain within your DEA-registered facility's IT perimeter. Self-hosted n8n keeps DEA data on your server. Cloud iPaaS (Zapier/Make) routes this data through US-based cloud servers outside your DEA registration boundary.

Q: Does the deadline tracker handle REMS assessment intervals?
A: Yes — the FDA_RISK_MANAGEMENT_REMS deadline type covers REMS assessments at 18-month, 3-year, and 7-year intervals per 21 USC §355-1. Set one row per interval in the Sheets with the correct due date.

Q: How does the cGMP APR workflow interact with batch record systems?
A: The Annual Product Review tracker sends an URGENT alert 30 days before the §211.180(e) calendar-year deadline. The actual APR is authored in your DMS/QMS — this workflow handles the deadline notification, not the document. You can extend Workflow 2 to poll your QMS API and flag if APR status is not 'APPROVED' within the window.

All five workflows export as clean n8n JSON — import via Settings → Import Workflow in your self-hosted instance.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.