Last Updated: 2025-11-25
Core: FW (Forms & Workflow)
Related Specs: FW-03 Automation Engine
Table of Contents
- Introduction & Overview
- Architecture & Data Flow
- n8n Setup Guide
- Encore OS Configuration
- Data Mapping Reference
- Security Best Practices
- Common Integration Patterns
- Troubleshooting Guide
- Advanced: MCP Integration
Introduction & Overview
Purpose
This guide documents how to connect Encore OS’s automation engine (FW-03) to n8n workflows via webhooks, enabling advanced external integrations and multi-step orchestration.Hybrid Approach
Encore OS and n8n complement each other:- Encore OS (FW-03 Engine): Internal workflows, tenant-scoped automations, database operations
- n8n: External integrations, visual workflow design, complex branching logic, 400+ pre-built connectors
When to Use n8n
Use n8n for workflows that require:- ✅ External SaaS integrations (Salesforce, HubSpot, Slack, Google Workspace)
- ✅ Complex branching logic (if/else, switch, loops)
- ✅ Multi-step orchestration (approval chains, escalation workflows)
- ✅ Visual workflow design (drag-and-drop, no-code)
- ✅ Error handling & retries (advanced fault tolerance)
- ✅ Data transformation (JSON manipulation, aggregation)
When to Use Encore OS (FW-03)
Use Encore OS’s built-in engine for:- ✅ Tenant-scoped automations (org/site-specific rules)
- ✅ Database operations (create/update records with RLS)
- ✅ Internal notifications (via Platform Notifications)
- ✅ Simple webhooks (one-off API calls)
- ✅ Form validations (immediate feedback)
Architecture & Data Flow
High-Level Flow
Data Format
Encore OS sends webhook payloads in this format:n8n Setup Guide
Step 1: Create a New Workflow
1
Step 2: Add Webhook Trigger
1
- HTTP Method:
POST - Path: Leave default or customize (e.g.,
/encore-health-os/form-submission) - Authentication: Choose based on security needs (see Security)
- Response Mode:
Last Node(if n8n needs to return data)
Step 3: Get Webhook URL
1
https://your-n8n-instance.com/webhook/abc123)Step 4: Test Webhook
1
Step 5: Build Workflow Logic
Example: Send Slack notification1
- Channel:
#new-hires - Message:
Step 6: Activate Workflow
1
Encore OS Configuration
Step 1: Create Automation Rule
1
- Trigger Type:
Form Submission - Form: Select target form (e.g., “Employee Onboarding Form”)
Step 2: Add Conditions (Optional)
Add conditions to filter when the automation runs:Step 3: Add “Call Webhook” Action
1
- URL: Paste your n8n webhook URL
- Method:
POST - Headers:
- Body Template: Use dynamic values (see Data Mapping)
Step 4: Configure Body Template
Example body template with dynamic values:Step 5: Test with Dry Run
1
Step 6: Activate Automation
1
Activefalse (for trusted workflows)Data Mapping Reference
Available Trigger Data Fields
When an automation is triggered by a form submission, the following fields are available for dynamic mapping:Dynamic Value Syntax
Use{{path.to.field}} syntax to reference trigger data:
Simple Field Access
Nested Field Access
Metadata Fields
Example Mappings
Slack Notification
CRM Update (Salesforce, HubSpot)
Google Sheets Row
Security Best Practices
1. Always Use HTTPS
❌ Never use HTTP webhooks:2. Implement Authentication
n8n supports multiple authentication methods:Option A: Header Authentication (Recommended)
- Webhook settings → Authentication → Header Auth
- Header Name:
Authorization - Header Value:
Bearer YOUR_SECRET_TOKEN
Option B: Basic Authentication
Option C: Query Parameter (Less Secure)
3. Protect Sensitive Data
- Never log PHI/PII in webhook bodies or n8n logs
- Use encrypted storage in n8n for credentials
- Implement field-level encryption for sensitive submission data
4. Rate Limiting & Circuit Breaker
Encore OS’s FW-03 engine includes:- Circuit breaker: Trips after 5 consecutive failures
- Timeout: 30-second webhook timeout
- Retry logic: 3 retries with exponential backoff
- Rate limits on external APIs
- Error responses (return 4xx/5xx appropriately)
5. IP Whitelisting (Optional)
If n8n is self-hosted:1
6. Audit Logging
- Enable automation logs in Encore OS (automatic)
- Enable execution logs in n8n
- Review logs regularly for anomalies
Common Integration Patterns
Pattern 1: Form → n8n → Slack Notification
Use Case: Notify team when a new form is submitted Encore OS Setup:- Trigger: Form submission on “Contact Form”
- Action: Call webhook to n8n
- Webhook (receive form data)
- Slack → Send message to
#inquiries- Message:
New inquiry from {{submission_data.name}} ({{submission_data.email}})
- Message:
Pattern 2: Form → n8n → Google Sheets
Use Case: Log form submissions to a Google Sheet for analysis Encore OS Setup:- Trigger: Form submission on “Event Registration”
- Action: Call webhook to n8n
- Webhook (receive form data)
- Google Sheets → Append row
- Sheet ID:
your-sheet-id - Values:
[name, email, event_date, submitted_at]
- Sheet ID:
Pattern 3: Form → n8n → CRM Update (Salesforce/HubSpot)
Use Case: Create or update contact in CRM when form is submitted Encore OS Setup:- Trigger: Form submission on “Lead Capture Form”
- Action: Call webhook to n8n
- Webhook (receive form data)
- HubSpot → Create or Update Contact
- Email:
{{submission_data.email}} - First Name:
{{submission_data.first_name}} - Last Name:
{{submission_data.last_name}} - Properties: Map additional fields
- Email:
Pattern 4: Form → n8n → Multi-Step Approval
Use Case: Form submission triggers approval workflow with escalation Encore OS Setup:1
1
- Email → Notify requester (approved)
- Database → Update expense status
- Email → Notify requester (denied with reason)
Pattern 5: Scheduled Trigger → n8n → Report Generation
Use Case: Generate weekly compliance report Encore OS Setup:- Trigger: Scheduled (every Monday at 9 AM)
- Action: Call webhook to n8n
1
Troubleshooting Guide
Issue 1: Webhook Not Triggering
Symptoms: n8n workflow doesn’t execute when automation runs Diagnostic Steps:1
- Navigate to Automations → [Your Rule] → Logs
- Look for
execution_status: "failed"or timeout errors
- ✅ Ensure URL uses HTTPS
- ✅ Check firewall rules allow outbound connections
- ✅ Verify n8n instance is reachable from Encore OS
Issue 2: Authentication Errors (401/403)
Symptoms: Webhook returns401 Unauthorized or 403 Forbidden
Diagnostic Steps:
1
- ✅ Re-generate authentication token in n8n
- ✅ Update token in Encore OS webhook headers
- ✅ Check header name matches (e.g.,
AuthorizationvsX-API-Key)
Issue 3: Data Mapping Errors
Symptoms: n8n receives payload but fields arenull or incorrect
Diagnostic Steps:
1
- Test automation with sample data
- Check execution logs for payload sent
- View received payload in webhook node output
- Verify field paths match expected structure
- ✅ Use correct field paths:
{{submission_data.field_name}} - ✅ Check for nested fields:
{{submission_data.nested.field}} - ✅ Verify form field keys match (case-sensitive)
Issue 4: Timeout Errors
Symptoms: Automation logs showexecution_status: "timeout"
Diagnostic Steps:
1
- ✅ Optimize n8n workflow (reduce API calls, use caching)
- ✅ Increase timeout in Encore OS (30s default, max 60s)
- ✅ Split complex workflows into multiple steps
Issue 5: Circuit Breaker Tripped
Symptoms: Automation stops executing after multiple failures Diagnostic Steps:- Check automation status in Encore OS:
- Look for
circuit_breaker_tripped: true - Review
consecutive_failurescount
- Look for
- Check n8n error logs for failure reasons
- ✅ Fix underlying n8n workflow issue
- ✅ Reset circuit breaker in Encore OS:
- Edit automation rule
- Save (resets circuit breaker)
- ✅ Monitor for recurring failures
Debugging Checklist
- Webhook URL is correct and uses HTTPS
- n8n workflow is Active
- Authentication headers are correct
- Data mapping uses correct field paths
- n8n workflow completes within timeout (30s)
- Encore OS automation status is Active
- Circuit breaker is not tripped
- Firewall allows outbound HTTPS connections
- n8n instance is reachable from Encore OS
Advanced: MCP Integration
What is n8n MCP?
The n8n MCP (Model Context Protocol) server allows Encore OS’s AI agent to:- Execute n8n workflows during app building
- Query workflow definitions for documentation
- Create bidirectional integrations (Encore OS ↔ n8n)
When to Use MCP vs Webhooks
Setting Up n8n MCP
See the n8n official documentation for MCP integration setup instructions. Prerequisites:1
MCP Use Case: Bidirectional Workflow
Scenario: Form submission triggers n8n workflow, n8n updates Encore OS database Encore OS Setup:1
1
- ✅ Complex external processing in n8n
- ✅ Database updates maintain RLS policies
- ✅ Full error handling and logging
Summary
Quick Start Checklist
1
{{field}} syntaxBest Practices
- ✅ Always use HTTPS webhooks
- ✅ Implement authentication (Bearer token recommended)
- ✅ Test with dry-run mode before activating
- ✅ Monitor automation and n8n execution logs
- ✅ Document complex workflows
- ✅ Use circuit breakers for fault tolerance
- ✅ Never log sensitive data (PHI/PII)
Resources
- FW-03 Automation Engine Spec
- Automation Security Guide
- Integration Documentation
- n8n Official Documentation
Questions or Issues? Contact the platform team or review automation logs in Forms & Workflow → Automations → [Your Rule] → Logs.