Version: 1.0.0Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
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 Health 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 Health OS’s automation engine (FW-03) to n8n workflows via webhooks, enabling advanced external integrations and multi-step orchestration.Hybrid Approach
Encore Health OS and n8n complement each other:- Encore Health 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 Health OS (FW-03)
Use Encore Health 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 Health OS sends webhook payloads in this format:n8n Setup Guide
Step 1: Create a New Workflow
- Log into your n8n instance
- Click “New Workflow”
- Give it a descriptive name (e.g., “Encore Health OS Form to Slack”)
Step 2: Add Webhook Trigger
- Click “Add first step”
- Search for “Webhook” and select it
- Configure webhook settings:
- 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)
- HTTP Method:
Step 3: Get Webhook URL
- Click “Listen for Test Event” or “Listen for Production Event”
- Copy the webhook URL (e.g.,
https://your-n8n-instance.com/webhook/abc123) - Important: Use the Production URL for live automations
Step 4: Test Webhook
- Keep n8n in “Listen” mode
- Send a test POST request:
- Verify n8n receives the payload
Step 5: Build Workflow Logic
Example: Send Slack notification- Add “Slack” node
- Select “Send Message” operation
- Map webhook data:
- Channel:
#new-hires - Message:
- Channel:
Step 6: Activate Workflow
- Click “Save” in the top right
- Toggle “Active” to enable the workflow
- The webhook is now live and ready to receive data from Encore Health OS
Encore Health OS Configuration
Step 1: Create Automation Rule
- Navigate to Forms & Workflow → Automations
- Click “Create Automation”
- Configure trigger:
- Trigger Type:
Form Submission - Form: Select target form (e.g., “Employee Onboarding Form”)
- Trigger Type:
Step 2: Add Conditions (Optional)
Add conditions to filter when the automation runs:Step 3: Add “Call Webhook” Action
- Click “Add Action”
- Select “Call Webhook”
- Configure webhook action:
- 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
- Click “Test Automation”
- Select “Dry Run” mode
- Submit a test form or use sample data
- Check n8n workflow execution logs
- Verify data mapping is correct
Step 6: Activate Automation
- Set Status:
Active - Set Requires Approval:
false(for trusted workflows) - Click “Save”
Data Mapping Reference
Available Trigger Data Fields
When an automation is triggered by a form submission, the following fields are available for dynamic mapping:| Field Path | Type | Description | Example |
|---|---|---|---|
submission_id | UUID | Unique submission ID | "a1b2c3d4-..." |
form_id | UUID | Form ID | "e5f6g7h8-..." |
form_name | String | Form name | "Employee Onboarding" |
submission_data.* | Object | Form field values | See below |
submitted_by | UUID | User who submitted | "i9j0k1l2-..." |
submitted_at | ISO 8601 | Submission timestamp | "2025-11-25T10:30:00Z" |
organization_id | UUID | Tenant organization | "m3n4o5p6-..." |
site_id | UUID | Site (if scoped) | "q7r8s9t0-..." |
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 Health 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:- Get Encore Health OS’s outbound IP addresses
- Configure firewall rules to allow only those IPs
- Blocks unauthorized webhook calls
6. Audit Logging
- Enable automation logs in Encore Health 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 Health 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 Health 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 Health 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 Health OS Setup:- Trigger: Form submission on “Expense Request”
- Condition: Amount > $1000
- Action: Call webhook to n8n
- Webhook (receive expense data)
- Slack → Send approval request to manager
- Wait for Webhook (manager response)
- IF approved:
- Email → Notify requester (approved)
- Database → Update expense status
- IF denied:
- Email → Notify requester (denied with reason)
Pattern 5: Scheduled Trigger → n8n → Report Generation
Use Case: Generate weekly compliance report Encore Health OS Setup:- Trigger: Scheduled (every Monday at 9 AM)
- Action: Call webhook to n8n
- Webhook (receive trigger)
- Encore Health OS API → Fetch compliance data (via custom function)
- Google Sheets → Create new sheet with data
- Email → Send report link to compliance team
Troubleshooting Guide
Issue 1: Webhook Not Triggering
Symptoms: n8n workflow doesn’t execute when automation runs Diagnostic Steps:- Check Encore Health OS automation logs:
- Navigate to Automations → [Your Rule] → Logs
- Look for
execution_status: "failed"or timeout errors
- Verify webhook URL is correct (copy from n8n production URL)
- Check n8n workflow is Active (not paused)
- Test webhook manually:
- ✅ Ensure URL uses HTTPS
- ✅ Check firewall rules allow outbound connections
- ✅ Verify n8n instance is reachable from Encore Health OS
Issue 2: Authentication Errors (401/403)
Symptoms: Webhook returns401 Unauthorized or 403 Forbidden
Diagnostic Steps:
- Check Encore Health OS automation logs for HTTP status code
- Verify authentication headers match n8n webhook configuration
- Test authentication with curl:
- ✅ Re-generate authentication token in n8n
- ✅ Update token in Encore Health 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:
- Use Encore Health OS dry-run mode:
- Test automation with sample data
- Check execution logs for payload sent
- Check n8n execution logs:
- View received payload in webhook node output
- Verify field paths match expected structure
- Compare expected vs actual payload 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:
- Check n8n execution time in workflow logs
- Identify slow nodes (external API calls, large data processing)
- Test n8n workflow execution time manually
- ✅ Optimize n8n workflow (reduce API calls, use caching)
- ✅ Increase timeout in Encore Health 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 Health 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 Health 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 Health OS automation status is Active
- Circuit breaker is not tripped
- Firewall allows outbound HTTPS connections
- n8n instance is reachable from Encore Health OS
Advanced: MCP Integration
What is n8n MCP?
The n8n MCP (Model Context Protocol) server allows Encore Health OS’s AI agent to:- Execute n8n workflows during app building
- Query workflow definitions for documentation
- Create bidirectional integrations (Encore Health OS ↔ n8n)
When to Use MCP vs Webhooks
| Capability | Webhooks | n8n MCP |
|---|---|---|
| Trigger workflows from automations | ✅ Primary | ⚡ Alternative |
| Return data to Encore Health OS | ⚡ Limited (200 char) | ✅ Full response |
| AI agent workflow execution | ❌ N/A | ✅ Primary |
| Bidirectional workflows | ⚡ Complex | ✅ Native |
| Setup complexity | ✅ Simple | ⚡ Requires MCP config |
Setting Up n8n MCP
See the n8n official documentation for MCP integration setup instructions. Prerequisites:- Enable MCP access in n8n (Settings → MCP access)
- Enable “Available in MCP” for each workflow (workflow settings)
- Connect n8n MCP server in Encore Health OS (Project Settings → Integrations)
MCP Use Case: Bidirectional Workflow
Scenario: Form submission triggers n8n workflow, n8n updates Encore Health OS database Encore Health OS Setup:- Form submission triggers automation
- Automation calls n8n webhook
- n8n workflow processes data
- n8n calls Encore Health OS Edge Function (via MCP) to update database
- Webhook (receive form data)
- External API (e.g., validate address via Google Maps)
- HTTP Request → Encore Health OS Edge Function (update database with validated address)
- ✅ Complex external processing in n8n
- ✅ Database updates maintain RLS policies
- ✅ Full error handling and logging
Summary
Quick Start Checklist
- ✅ Create webhook trigger in n8n
- ✅ Copy production webhook URL
- ✅ Create automation rule in Encore Health OS
- ✅ Add “Call Webhook” action with URL and auth
- ✅ Map trigger data using
{{field}}syntax - ✅ Test with dry-run mode
- ✅ Activate automation and n8n workflow
- ✅ Monitor logs for successful executions
Best 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.