n8n Implementation for Clinical Research Teams: Complete Beginner’s Guide to Workflow Automation
Affiliate Disclosure: As a clinical data management professional, I regularly test and evaluate automation tools for research workflows. Some links in this article are affiliate links, meaning AI Tool Clinic may earn a commission if you choose to purchase through them—at no extra cost to you. All opinions and recommendations are based on my 12+ years of hands-on experience in clinical research environments.
Introduction: Why Clinical Research Teams Need n8n
After spending over a decade managing clinical data across Phase I-IV trials, I’ve witnessed firsthand the chaos that manual workflows create. Picture this: A site reports a serious adverse event in Medidata Rave at 3 PM on Friday. Your safety team doesn’t see it until Monday morning because someone forgot to check the weekend reports. By then, you’re facing regulatory reporting deadline pressures and potential compliance issues.
This scenario isn’t hypothetical—it happens more often than anyone in pharma wants to admit. The clinical research ecosystem is a maze of disconnected systems: your Electronic Data Capture (EDC) platform speaks one language, your Clinical Trial Management System (CTMS) speaks another, and your regulatory submission databases might as well be on a different planet. Data analysts spend 40-60% of their time on manual data transfers, reconciliation, and chasing down discrepancies instead of actual analysis.
Traditional integration solutions exist, but they come with pharmaceutical-grade price tags. Enterprise platforms can cost $50,000-$200,000 annually for capabilities that most clinical teams only partially utilize. Zapier and similar cloud services raise immediate red flags for HIPAA compliance and data sovereignty concerns when handling Protected Health Information (PHI).
Enter n8n—an open-source workflow automation platform that’s changing how clinical research teams approach process automation. Unlike closed-source alternatives, n8n offers self-hosting capabilities, giving you complete control over where your data lives and flows. This isn’t just about cost savings (though we’ll demonstrate substantial ROI); it’s about building compliant, auditable, and scalable automation infrastructure that meets 21 CFR Part 11 requirements without vendor lock-in.
In this comprehensive guide, I’ll walk you through implementing n8n specifically for clinical research operations, drawing from real-world deployment experiences across CROs and pharmaceutical companies. Whether you’re a clinical data manager tired of manual exports, a clinical operations lead seeking efficiency gains, or an IT professional supporting research teams, this guide provides actionable steps to transform your workflow automation capabilities.
Comparison: Workflow Automation Tools for Clinical Research
Before diving into implementation, here’s how n8n stacks up against alternatives I’ve evaluated for clinical research environments:
| Tool | Best For | Free Tier | Self-Hosted | HIPAA-Ready | Starting Price | Clinical Research Fit |
|---|---|---|---|---|---|---|
| n8n | Full control, complex workflows | ✅ Unlimited (self-hosted) | ✅ Yes | ✅ Yes (with proper setup) | Free / $20/month cloud | ⭐⭐⭐⭐⭐ Excellent |
| Zapier | Quick simple automations | 100 tasks/month | ❌ No | ⚠️ BAA available (expensive) | $19.99/month | ⭐⭐⭐ Limited by PHI concerns |
| Make (Integromat) | Visual workflow design | 1,000 operations/month | ❌ No | ⚠️ BAA available | $9/month | ⭐⭐⭐⭐ Good value |
| Microsoft Power Automate | Microsoft ecosystem integration | 2,000 calls/month | ⚠️ Hybrid | ✅ Yes (enterprise) | $15/user/month | ⭐⭐⭐⭐ Best for MS shops |
| REDCap | Research data capture with limited automation | ✅ Free (institutional) | ✅ Yes | ✅ Yes | Free | ⭐⭐⭐ Purpose-built but limited |
What is n8n? Understanding Workflow Automation for Clinical Research
n8n (pronounced “n-eight-n,” short for “nodemation”) is an open-source workflow automation tool that lets you connect different applications, services, and databases without writing extensive code. Think of it as the central nervous system for your clinical research operations—it watches for specific events (like a new patient enrollment) and automatically triggers a series of actions (updating your CTMS, sending notifications, creating tracking records).
How n8n Works
At its core, n8n uses a node-based visual interface. Each “node” represents either a trigger (what starts the workflow) or an action (what happens next). You connect these nodes to create automation workflows that can be as simple as “when a form is submitted, send an email” or as complex as “monitor EDC query status, check response timelines, escalate to clinical managers if overdue, and update the query tracking database with audit trails.”
From a clinical data management perspective, n8n bridges the gap between IT-controlled enterprise systems and the practical needs of research operations teams. I’ve used it to eliminate countless hours of manual work—from automating weekly enrollment reports to creating real-time monitoring dashboards that pull data from multiple sources.
Self-Hosted vs Cloud: Critical Decision for Clinical Research
n8n offers two deployment options, each with distinct implications for healthcare compliance:
Self-Hosted n8n (Community Edition – Free)
– Complete data control—everything stays on your infrastructure
– No limitations on workflow executions or automation complexity
– Full customization and integration capabilities
– Requires technical resources for setup, maintenance, and security
– Ideal for organizations handling PHI or subject to strict data governance
n8n Cloud (Managed Service – Starting at $20/month)
– Hosted infrastructure managed by n8n
– Faster deployment with minimal technical overhead
– Built-in SSL, backups, and updates
– Requires Business Associate Agreement (BAA) for HIPAA compliance
– Limited control over data residency and infrastructure security
For most clinical research environments I’ve worked with, self-hosted deployment is the only viable option initially. The ability to validate your automation infrastructure, maintain complete audit trails, and ensure PHI never leaves your controlled environment outweighs the convenience of cloud hosting—at least until you’ve secured proper compliance documentation.
Why Automation Matters in Clinical Research
Clinical trials generate massive data volumes across fragmented systems. A mid-sized Phase III trial might involve:
– 50-100 clinical sites entering data into EDC systems
– Thousands of queries requiring resolution and documentation
– Continuous safety monitoring across multiple databases
– Regulatory submission packages requiring data from 10+ sources
– Site communication logs spanning email, portals, and phone calls
Manual coordination of these activities introduces delays, errors, and compliance risks. In one multi-site trial I managed, we discovered that 30% of site communications were delayed by 24-48 hours simply because information sat in one system while team members checked another. Implementing automated routing reduced average response time from 36 hours to 4 hours.
Automation isn’t about replacing clinical professionals—it’s about freeing them from repetitive data shuttling so they can focus on actual research activities: protocol compliance assessment, data quality analysis, and patient safety monitoring.
Relevance to HIPAA and 21 CFR Part 11
Any system touching clinical trial data must address regulatory requirements:
HIPAA Compliance: If your workflows handle PHI (patient names, dates of birth, medical record numbers), you need encrypted data storage, access controls, audit logging, and potentially Business Associate Agreements with any third-party processors. Self-hosted n8n gives you control over all these elements.
21 CFR Part 11: FDA regulations require electronic records to be trustworthy, reliable, and equivalent to paper records. This means your automation workflows need:
– Audit trails showing who created/modified workflows and when
– Validation documentation proving workflows perform as intended
– Access controls limiting who can change production workflows
– Secure authentication (no shared credentials)
n8n’s open-source architecture actually simplifies validation compared to black-box commercial solutions. You can review the actual code, document exact workflow logic, and maintain complete records of system behavior—all critical for regulatory inspections.
Prerequisites: What You Need Before Implementation
Jumping straight into n8n installation without proper planning is a recipe for frustration. Based on implementations I’ve led and observed, here’s what you need lined up first:
Technical Requirements
For Self-Hosted Deployment:
– Server/Virtual Machine: Minimum 2 CPU cores, 4GB RAM, 20GB storage for basic implementations. I recommend 4 CPU cores and 8GB RAM if you’ll run multiple concurrent workflows or process large datasets.
– Operating System: Linux (Ubuntu 20.04+ or Debian 10+) preferred for stability. Windows Server works but adds complexity. macOS for development/testing only.
– Database: n8n includes SQLite by default, but PostgreSQL or MySQL is strongly recommended for production clinical environments (better performance, reliability, and audit capabilities).
– Network Access: If integrating with cloud-based clinical systems, you’ll need outbound HTTPS access. For bidirectional integrations, you’ll need a publicly accessible endpoint or VPN configuration.
– SSL Certificate: Essential for HIPAA compliance and secure API communications. Let’s Encrypt provides free certificates, or use your organization’s certificate authority.
For n8n Cloud Deployment:
– Business Associate Agreement (BAA) from n8n for HIPAA compliance
– Network whitelisting documentation for security teams
– Data residency confirmation matching your compliance requirements
Hosting Options Comparison
From my experience implementing n8n across different organizational contexts:
On-Premises Server ($0 software + existing infrastructure)
– ✅ Maximum control and compliance assurance
– ✅ No recurring cloud costs
– ❌ Requires IT involvement for maintenance
– ❌ You handle security, backups, and updates
– Best for: Large pharma companies, academic medical centers with existing infrastructure
Cloud VM (AWS/Azure/GCP) ($50-150/month)
– ✅ Scalable resources on demand
– ✅ Professional backup and disaster recovery options
– ⚠️ Ongoing cloud costs
– ⚠️ Requires cloud security configuration expertise
– Best for: CROs, biotech companies, distributed research teams
n8n Cloud ($20-240/month depending on usage)
– ✅ Fastest time to value
– ✅ Managed infrastructure
– ❌ Less control over data and infrastructure
– ❌ Requires additional compliance documentation
– Best for: Small research teams, pilot projects, non-PHI workflows
Team Skill Assessment
Realistic evaluation of your team’s capabilities prevents implementation stalls:
Minimum Required Skills:
– Basic understanding of APIs and webhooks (at least one team member)
– Familiarity with your clinical systems’ data structures
– Ability to follow technical documentation and troubleshoot
Helpful But Not Required:
– JavaScript knowledge for complex data transformations
– SQL skills for database integrations
– DevOps experience for production deployment
In my implementations, I’ve successfully trained clinical data coordinators with no coding background to build and maintain n8n workflows within 2-3 weeks. The visual interface is genuinely accessible—but you need at least one person comfortable with technical concepts to handle initial setup and troubleshoot integration issues.
Compliance Considerations Checklist
Before implementing any automation in clinical research:
- [ ] Data Classification: Document what types of data your workflows will process (PHI, PII, de-identified, aggregate)
- [ ] Risk Assessment: Complete privacy and security risk analysis for automated data flows
- [ ] Validation Plan: Define how you’ll validate workflows for regulatory compliance (test scripts, acceptance criteria)
- [ ] Change Control: Establish process for reviewing and approving workflow changes
- [ ] Access Control Policy: Define who can create, modify, execute, and view workflows
- [ ] Audit Strategy: Plan for workflow execution logging and audit trail retention
- [ ] Business Associate Agreements: Identify any third-party services in your workflows requiring BAAs
- [ ] Disaster Recovery: Document backup and recovery procedures for workflow definitions and execution data
Budget Planning
Self-Hosted Cost Breakdown (First Year):
– Server/VM hosting: $600-1,800 annually
– SSL certificate: $0-200 annually (free with Let’s Encrypt)
– Database (if separate): $0-300 annually
– Backup storage: $100-500 annually
– Staff time (setup and training): 40-80 hours
– Total: $700-2,800 + staff time
n8n Cloud Cost Breakdown (First Year):
– Starter plan: $240/year (10,000 executions/month)
– Pro plan: $600/year (100,000 executions/month)
– Business Associate Agreement: Requires Pro+ plan
– Total: $600-2,400+ depending on volume
Compare this to enterprise clinical automation solutions I’ve evaluated at $50,000-200,000 annually, and the ROI becomes clear—especially for small to mid-sized research organizations.
Step 1: Installation and Initial Setup
I’ll walk through the three most common installation paths I recommend for clinical research teams. Choose based on your technical comfort level and infrastructure requirements.
Option A: Docker Installation (Recommended for Most Teams)
Docker provides the easiest path to a production-grade n8n deployment with proper isolation and reproducibility.
Prerequisites:
– Docker and Docker Compose installed on your server
– Basic command line familiarity
Step-by-step process:
- Create project directory and configuration:
mkdir /opt/n8n-clinical
cd /opt/n8n-clinical
- Create docker-compose.yml file:
version: '3.8'
services:
postgres:
image: postgres:14
restart: always
environment:
POSTGRES_USER: n8n_user
POSTGRES_PASSWORD: your_secure_password_here
POSTGRES_DB: n8n_clinical
volumes:
- postgres_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n:latest
restart: always
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=n8n_clinical
- DB_POSTGRESDB_USER=n8n_user
- DB_POSTGRESDB_PASSWORD=your_secure_password_here
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=your_admin_password
- N8N_HOST=n8n.yourorganization.com
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://n8n.yourorganization.com/
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
volumes:
postgres_data:
n8n_data:
- Launch n8n:
docker-compose up -d
- Verify installation:
docker-compose logs -f n8n
You should see logs indicating n8n has started successfully. Access the interface at http://your-server-ip:5678.
Option B: npm Installation (For Development/Testing)
If you’re evaluating n8n or setting up a development environment:
# Install n8n globally
npm install n8n -g
# Start n8n
n8n start
# With custom configuration
export N8N_BASIC_AUTH_ACTIVE=true
export N8N_BASIC_AUTH_USER=admin
export N8N_BASIC_AUTH_PASSWORD=your_password
n8n start
This approach works well for personal testing but lacks the isolation and management capabilities needed for production clinical environments.
Option C: n8n Cloud (Managed Service)
For teams wanting to pilot automation without infrastructure complexity:
- Visit n8n.io/cloud
- Create an account using your organizational email
- Choose the Pro plan ($50/month minimum) if handling PHI—required for BAA
- Contact n8n sales to execute Business Associate Agreement
- Configure SSO integration if required by your organization
- Access your instance at your-organization.n8n.cloud
Configuring Healthcare Security Standards
Regardless of installation method, implement these security configurations:
1. SSL/TLS Certificate Setup (Self-Hosted):
Use Nginx or Caddy as a reverse proxy with SSL termination. Here’s a basic Nginx configuration:
server {
listen 443 ssl http2;
server_name n8n.yourorganization.com;
ssl_certificate /etc/letsencrypt/live/n8n.yourorganization.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.yourorganization.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}
}
2. Authentication Configuration:
Enable basic authentication at minimum, LDAP/SAML integration for enterprise deployments:
# Environment variables for authentication
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=complex_password_here
# For LDAP integration (enterprise)
N8N_AUTH_LDAP_ENABLED=true
N8N_AUTH_LDAP_SERVER_URL=ldap://yourdc.organization.com
N8N_AUTH_LDAP_BIND_DN=cn=n8n_service,ou=services,dc=organization,dc=com
3. Network Security:
Configure firewall rules limiting access:
# Allow only from your organization's IP ranges
ufw allow from 10.0.0.0/8 to any port 5678
ufw allow from 192.168.1.0/24 to any port 5678
ufw enable
4. Audit Logging:
Enable execution data logging for compliance:
N8N_LOG_LEVEL=info
N8N_LOG_OUTPUT=file
N8N_LOG_FILE_LOCATION=/var/log/n8n/
User Authentication and Access Control
Create separate accounts for each team member—shared credentials violate 21 CFR Part 11. Document who has access in your validation records:
- Access n8n settings → Users & Access
- Create individual accounts with strong passwords
- Assign roles based on responsibilities (creator, executor, viewer)
- Document access grants in your quality management system
- Review and recertify access quarterly
Connecting to Network Infrastructure
If integrating with internal clinical systems:
VPN Configuration: Many EDC and CTMS systems restrict API access to specific IP ranges. You’ll need to:
– Document n8n server’s IP address
– Submit IT access requests for each target system
– Configure VPN if required by security policies
– Test connectivity to each system before building workflows
Proxy Settings: For organizations routing traffic through proxies:
HTTP_PROXY=http://proxy.organization.com:8080
HTTPS_PROXY=http://proxy.organization.com:8080
Initial Configuration Validation
Before building workflows, verify your installation:
- [ ] Access n8n interface via HTTPS with valid certificate
- [ ] Login with unique credentials (not default)
- [ ] Verify database connection (Settings → About should show PostgreSQL)
- [ ] Test external connectivity (create simple HTTP request to public API)
- [ ] Check audit logs are capturing activity
- [ ] Confirm backup processes are running
- [ ] Document installation configuration in validation records
Step 2: Understanding n8n Core Concepts for Clinical Workflows
Before automating clinical research processes, you need to understand how n8n thinks. Coming from a clinical data management background, I found the learning curve manageable once I mapped familiar research concepts to n8n’s terminology.
Workflows: Your Automated Processes
A workflow in n8n is equivalent to a Standard Operating Procedure (SOP)—it defines a specific process from trigger to completion. Examples from my implementations:
- Adverse Event Escalation Workflow: Monitors EDC for Grade 3+ events → extracts patient information → creates safety database ticket → notifies medical monitor
- Query Management Workflow: Checks EDC query status daily → identifies overdue queries → sends reminders to site coordinators → escalates to CRAs after 7 days
- Enrollment Tracking Workflow: Detects new patient randomization → updates CTMS → generates screening/enrollment report → posts to SharePoint
Each workflow lives independently but can be triggered by others, creating sophisticated automation chains.
Nodes: Building Blocks of Automation
Nodes are the individual steps in your workflow. n8n provides 350+ pre-built nodes, but these are the most relevant for clinical research:
Trigger Nodes (Start Your Workflow):
– Webhook: Receive real-time notifications from clinical systems (e.g., EDC sends data when query created)
– Schedule: Run workflows on a timer (daily enrollment reports, weekly metrics updates)
– Manual Trigger: Start workflow on-demand for testing or ad-hoc operations
Action Nodes (Do Something):
– HTTP Request: Connect to any system with an API (most EDC/CTMS platforms)
– Database Nodes (PostgreSQL, MySQL, SQL Server): Query or update clinical databases
– Email: Send notifications to team members or sites
– Microsoft Excel/Google Sheets: Read/write data for reporting
– FTP/SFTP: Transfer files to regulatory submission systems
– IF/Switch: Conditional logic based on data values
– Set/Code: Transform data between systems
Clinical Research Example:
Let’s say you need to automate patient screening log updates:
- Schedule Trigger (runs daily at 8 AM)
- HTTP Request Node (queries EDC API for new screening records)
- IF Node (checks if patients meet inclusion criteria)
- Set Node (formats data for CTMS structure)
- HTTP Request Node (posts eligible patients to CTMS)
- Email Node (sends enrollment summary to clinical team)
Credentials: Secure Connection Management
Clinical systems require authentication. n8n’s credential system stores these securely and reuses them across workflows:
- API Keys: For REDCap, many EDC systems
- OAuth2: For Microsoft Graph, Google services
- Basic Auth: For custom internal systems
- Database Credentials: For direct database connections
Critical for compliance: Never hardcode passwords or API keys in workflows. Always use the credential system so access can be audited and revoked when team members leave.
Expressions: Dynamic Data Handling
n8n uses JavaScript expressions to manipulate data between nodes. This is where clinical data managers have an advantage—you already think in terms of data transformations and mappings.
Common clinical research uses:
// Extract patient ID from complex EDC response
{{ $json["subjects"][0]["subjectId"] }}
// Calculate days between screening and randomization
{{ DateTime.fromISO($json["randomizationDate"]).diff(DateTime.fromISO($json["screeningDate"]), 'days').days }}
// Format adverse event severity for safety database
{{ $json["toxicityGrade"] >= 3 ? "Serious" : "Non-serious" }}
// Clean site numbers (remove leading zeros)
{{ $json["siteNumber"].replace(/^0+/, '') }}
You don’t need to be a programmer—n8n provides expression documentation and examples. I learned by starting with simple expressions and building complexity gradually.
Execution Data and Debugging
Every time a workflow runs, n8n captures execution data—extremely valuable for validation and troubleshooting:
- Input data received by each node
- Transformations applied
- Output data sent to next node
- Execution duration
- Success or error status
For regulatory environments, configure execution data retention (Settings → Execution Data) to maintain audit trails. I recommend 30-90 days for production workflows handling clinical data.
Mapping Clinical Processes to Automation Logic
The key to successful n8n implementation is thinking through your process logic before building:
Manual Process: “When a site submits a query response, I check if it’s complete, update the query tracking spreadsheet, and email the data manager if action is needed.”
n8n Logic:
1. Trigger: Webhook from EDC when query status changes
2. Condition: IF query status = “Answered”
3. Extract: Get query details and site response
4. Evaluate: Check if response meets data requirements
5. Update: Write to query tracking database
6. Notify: IF incomplete, email data manager with details
Clinical Trial Enrollment Process:
Manual: “Every Monday, I pull screening logs from all sites, check against randomization lists, calculate enrollment rates, and update the steering committee dashboard.”
n8n workflow:
1. Trigger: Schedule (Monday 6 AM)
2. Query: HTTP request to EDC for screening records
3. Query: HTTP request to IWRS for randomization records
4. Join: Match and compare datasets
5. Calculate: Compute enrollment metrics (rates, projections)
6. Format: Create summary table
7. Upload: Post to SharePoint dashboard
8. Notify: Email steering committee with summary
Common Node Types for Research Teams
Based on workflows I’ve built across multiple trials:
Data Collection: HTTP Request (80% of integrations), Database nodes, Webhook
Data Processing: IF/Switch, Set, Code, Merge, Split In Batches
Notifications: Email, Slack, Microsoft Teams, SMS
File Operations: Read/Write Files, FTP, Move Binary Data
Reporting: Google Sheets, Microsoft Excel, PDF generation
Scheduling: Cron, Schedule Trigger, Wait node
The beauty of n8n is you can start with simple two-node workflows (trigger → action) and progressively add complexity as your team gains confidence.
Step 3: Building Your First Clinical Research Workflow
Theory is useful, but nothing beats building a real workflow. I’ll walk through creating an adverse event notification system—a common pain point I’ve addressed in multiple implementations.
Use Case: Automating Serious Adverse Event Alerts
Manual Process Problem:
Sites enter SAEs into the EDC system. Data managers check daily reports, manually identify new events, then send notifications to the safety team via email with attachments pulled from multiple systems. Average time: 12-24 hours from event entry to safety team notification. During this gap, critical regulatory reporting timelines may be at risk.
Automated Solution:
Real-time webhook from EDC detects new SAE, extracts relevant data, checks against safety database for duplicates, creates formatted notification email with all necessary details, and sends to safety team within 5 minutes of event entry.
Workflow Architecture
This workflow will include:
1. Webhook trigger (receives SAE notification from EDC)
2. Data extraction and validation
3. Duplicate check against safety database
4. Conditional routing based on severity
5. Email notification with formatted data
6. Logging to tracking database
Step-by-Step Implementation
Step 1: Create New Workflow
- Click “+” to create new workflow
- Name it: “SAE Real-Time Notification”
- Add description: “Receives SAE notifications from EDC and alerts safety team with complete event details”
- Add tags: “safety”, “adverse-events”, “production”
Step 2: Configure Webhook Trigger
- Add Webhook node (click + icon, search “webhook”)
- Configure:
- HTTP Method: POST
- Path:
sae-notification - Authentication: Basic Auth (create credential with secure username/password)
- Response Mode: “Last Node”
- Note the webhook URL—you’ll configure this in your EDC system
- Test webhook by clicking “Listen for Test Event”
Step 3: Add Data Extraction Node
EDC systems send data in various formats. We’ll standardize using a Set node:
- Add Set node, name it “Extract SAE Data”
- Configure fields to extract:
patientId:{{ $json["body"]["subject_id"] }}eventTerm:{{ $json["body"]["ae_term"] }}severity:{{ $json["body"]["severity"] }}onsetDate:{{ $json["body"]["onset_date"] }}siteNumber:{{ $json["body"]["site_number"] }}reportDate:{{ DateTime.now().toISO() }}eventId:{{ $json["body"]["ae_id"] }}
Adjust field mappings based on your EDC’s webhook payload structure.
Step 4: Add Duplicate Check
Prevent duplicate notifications by checking if this SAE already exists in your tracking system:
- Add PostgreSQL node (or your database), name it “Check for Duplicate”
- Configure credential to your safety database
- Operation: Execute Query
- Query:
SELECT event_id, notification_sent
FROM sae_tracking
WHERE event_id = '{{ $json["eventId"] }}'
Step 5: Add Conditional Logic
- Add IF node, name it “Is New SAE?”
- Condition:
{{ $json["data"].length === 0 }}
(True if no existing records found) - This creates two paths: “true” (new SAE) and “false” (duplicate)
Step 6: Format Notification Email
On the “true” path (new SAE):
- Add Set node, name it “Format Email Content”
- Create formatted fields:
// Email Subject
{{ "URGENT: New SAE - " + $node["Extract SAE Data"].json["eventTerm"] + " - Site " + $node["Extract SAE Data"].json["siteNumber"] }}
// Email Body (use HTML mode)
<h2>Serious Adverse Event Notification</h2>
<table>
<tr><td><strong>Patient ID:</strong></td><td>{{ $node["Extract SAE Data"].json["patientId"] }}</td></tr>
<tr><td><strong>Event:</strong></td><td>{{ $node["Extract SAE Data"].json["eventTerm"] }}</td></tr>
<tr><td><strong>Severity:</strong></td><td>{{ $node["Extract SAE Data"].json["severity"] }}</td></tr>
<tr><td><strong>Onset Date:</strong></td><td>{{ $node["Extract SAE Data"].json["onsetDate"] }}</td></tr>
<tr><td><strong>Site Number:</strong></td><td>{{ $node["Extract SAE Data"].json["siteNumber"] }}</td></tr>
<tr><td><strong>Reported:</strong></td><td>{{ $node["Extract SAE Data"].json["reportDate"] }}</td></tr>
</table>
<p><strong>Action Required:</strong> Review in safety database and initiate regulatory reporting if applicable.</p>
<p><a href="https://edc.yourcompany.com/ae/{{ $node["Extract SAE Data"].json["eventId"] }}">View in EDC System</a></p>
Step 7: Send Email Notification
- Add Email node (or Microsoft Outlook/Gmail), name it “Send to Safety Team”
- Configure:
- From:
[email protected] - To:
[email protected] - CC: Data management lead email
- Subject:
{{ $json["subject"] }} - Body (HTML):
{{ $json["body"] }} - Priority: High
Step 8: Log to Tracking Database
Maintain audit trail by recording notification:
- Add PostgreSQL node, name it “Log Notification”
- Operation: Insert
- Table:
sae_tracking - Columns:
event_id:{{ $node["Extract SAE Data"].json["eventId"] }}patient_id:{{ $node["Extract SAE Data"].json["patientId"] }}notification_sent:{{ $node["Extract SAE Data"].json["reportDate"] }}notified_email:[email protected]severity:{{ $node["Extract SAE Data"].json["severity"] }}
Step 9: Handle Duplicate Path
On the “false” path (duplicate detected):
- Add NoOp node or Set node with note: “Duplicate detected – no action taken”
- Optionally add logging to track how often duplicates occur
Step 10: Add Error Handling
Critical for production workflows:
1.