Skip to content

πŸ€– n8n Workflow Definitions (Post-MVP Vision)

Scope: POST-MVP - n8n is NOT in the MVP Status: Future automation platform (Vision only) MVP Alternative: Cloudflare Workers Cron + simple TypeScript functions

Important Note

n8n is NOT included in the MVP. The MVP uses simple Cloudflare Workers Cron triggers with TypeScript functions for automation (see simplified-mvp-architecture.md).

This document describes a potential future architecture if we add n8n post-MVP for more complex workflow automation.

Overview

n8n could provide automation backbone for GetCimple post-MVP, handling scheduled tasks, integrations, and complex multi-step workflows without custom code.

Important: This is a FUTURE vision. The MVP uses deterministic rule-based processing with no AI agents and no n8n. See Simplified MVP Architecture for the actual MVP approach.

Future Workflow Examples (Post-MVP)

1. Daily Compliance Check

Workflow: Daily Compliance Scanner
Trigger: Cron (7am daily)
Steps: 1. Query pending tasks
  2. Check task due dates
  3. Identify critical items
  4. Send notifications (Email/WhatsApp)
  5. Update dashboard metrics
  6. Log execution

2. Document Processing Pipeline (Requires AI - Post-MVP)

Workflow: Policy Document Processor
Trigger: Webhook (on file upload)
Steps: 1. Receive upload notification
  2. Extract text (PDF/Word)
  3. Send to AI for analysis (Post-MVP only)
  4. Extract key information
  5. Update question bank
  6. Tag with frameworks
  7. Notify user of completion

Note: MVP uses simple text extraction without AI analysis

3. Board Report Generation

Workflow: Monthly Board Report
Trigger: Cron (1st Monday of month)
Steps: 1. Gather compliance metrics
  2. Query critical incidents
  3. Calculate trends
  4. Generate PDF report
  5. Email to board list
  6. Archive in document store

4. Evidence Collection Reminder

Workflow: Evidence Collection Flow
Trigger: Manual or scheduled
Steps: 1. Identify missing evidence
  2. Send WhatsApp reminder
  3. Wait for response (24h)
  4. If no response, escalate
  5. If received, validate
  6. Update compliance status

Workflow Implementations

Daily Compliance Check (Detailed)

{
  "name": "Daily Compliance Scanner",
  "nodes": [
    {
      "id": "1",
      "type": "n8n-nodes-base.cron",
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 7,
              "minute": 0
            }
          ]
        }
      }
    },
    {
      "id": "2",
      "type": "n8n-nodes-base.httpRequest",
      "parameters": {
        "url": "={{$env.API_URL}}/api/tasks/pending",
        "method": "GET",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "getcimpleApi"
      }
    },
    {
      "id": "3",
      "type": "n8n-nodes-base.if",
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$json.priority}}",
              "value2": "critical"
            }
          ]
        }
      }
    },
    {
      "id": "4",
      "type": "n8n-nodes-base.twilio",
      "parameters": {
        "operation": "send",
        "from": "whatsapp:+14155238886",
        "to": "={{$json.user.whatsapp}}",
        "message": "πŸ”΄ Critical Task Due\n\n{{$json.task.title}}\n" +
                   "Due: {{$json.task.dueDate}}\n\n" +
                   "Reply DONE when complete."
      }
    }
  ]
}

Integration Nodes Used

GetCimple API (Custom)

// Custom n8n node for GetCimple API
export class GetCimpleApi implements INodeType {
  description: INodeTypeDescription = {
    displayName: 'GetCimple API',
    name: 'getcimpleApi',
    icon: 'file:getcimple.svg',
    group: ['transform'],
    version: 1,
    description: 'Interact with GetCimple platform',
    defaults: {
      name: 'GetCimple API',
    },
    inputs: ['main'],
    outputs: ['main'],
    credentials: [{
      name: 'getcimpleApi',
      required: true,
    }],
    properties: [
      {
        displayName: 'Resource',
        name: 'resource',
        type: 'options',
        options: [
          { name: 'Task', value: 'task' },
          { name: 'Compliance', value: 'compliance' },
          { name: 'Report', value: 'report' },
          { name: 'Evidence', value: 'evidence' },
        ],
      },
      {
        displayName: 'Operation',
        name: 'operation',
        type: 'options',
        displayOptions: {
          show: {
            resource: ['task'],
          },
        },
        options: [
          { name: 'Get Pending', value: 'getPending' },
          { name: 'Update Status', value: 'updateStatus' },
          { name: 'Assign', value: 'assign' },
        ],
      },
    ],
  };
}

Standard Nodes Configuration

HTTP Request Node

  • Authentication: API Key (header)
  • Base URL: Environment variable
  • Error handling: Continue on fail
  • Timeout: 30 seconds

Email Node

  • SMTP configuration
  • Template support
  • Attachment handling
  • Delivery tracking

Twilio Node

  • WhatsApp Business API
  • SMS fallback
  • Media support
  • Delivery receipts

Workflow Templates

1. Compliance Alert Template

name: Compliance Alert
version: 1.0
trigger_type: webhook|cron|manual
parameters:
  - alert_threshold: number
  - notification_channels: array
  - escalation_path: object
steps:
  - check_compliance_score
  - evaluate_threshold
  - send_notifications
  - log_alert

2. Document Analysis Template

name: Document Analyzer
version: 1.0
trigger_type: webhook
parameters:
  - document_type: string
  - analysis_depth: enum[basic|detailed]
  - output_format: enum[json|summary]
steps:
  - validate_document
  - extract_content
  - ai_analysis
  - store_results
  - notify_completion

Error Handling

Retry Logic

// Workflow error handler
{
  "errorWorkflow": "error-handler-workflow",
  "retryOnFail": true,
  "maxRetries": 3,
  "retryDelayMs": 5000,
  "continueOnFail": false
}

Error Notification Workflow

{
  "name": "Error Handler",
  "nodes": [
    {
      "type": "n8n-nodes-base.errorTrigger",
      "parameters": {}
    },
    {
      "type": "n8n-nodes-base.slack",
      "parameters": {
        "channel": "#alerts",
        "text": "Workflow Error: {{$json.error.message}}\n" +
                "Workflow: {{$json.workflow.name}}\nTime: {{$now}}"
      }
    }
  ]
}

Monitoring & Metrics

Workflow Metrics

-- n8n execution metrics
CREATE TABLE workflow_executions (
  id UUID PRIMARY KEY,
  workflow_id TEXT,
  workflow_name TEXT,
  status TEXT, -- 'success', 'error', 'running'
  started_at TIMESTAMP,
  finished_at TIMESTAMP,
  execution_time_ms INTEGER,
  error_message TEXT,
  tenant_id UUID
);

-- Key metrics query
SELECT
  workflow_name,
  COUNT(*) as total_executions,
  AVG(execution_time_ms) as avg_time,
  COUNT(CASE WHEN status = 'error' THEN 1 END) as errors,
  COUNT(CASE WHEN status = 'success' THEN 1 END) * 100.0 /
    COUNT(*) as success_rate
FROM workflow_executions
WHERE started_at > NOW() - INTERVAL '24 hours'
GROUP BY workflow_name;

Health Checks

Healthcheck Workflow:
  - Check API connectivity
  - Verify database access
  - Test email sending
  - Validate WhatsApp API
  - Report status to monitoring

Security Configuration

Credentials Management

// Encrypted credential storage
{
  "getcimpleApi": {
    "apiKey": "encrypted:xxx",
    "baseUrl": "https://api.getcimple.com"
  },
  "twilioApi": {
    "accountSid": "encrypted:xxx",
    "authToken": "encrypted:xxx",
    "whatsappNumber": "+14155238886"
  },
  "smtp": {
    "host": "smtp.sendgrid.net",
    "port": 587,
    "user": "encrypted:xxx",
    "password": "encrypted:xxx"
  }
}

Webhook Security

// Webhook authentication
function validateWebhook(req) {
  const signature = req.headers['x-getcimple-signature']
  const payload = req.body
  const secret = process.env.WEBHOOK_SECRET

  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex')

  return signature === expectedSignature
}

Deployment Options

Advantages:
  - No infrastructure management
  - Automatic updates
  - Built-in monitoring
  - $20/month for small team

Configuration:
  - Set environment variables
  - Configure credentials
  - Import workflow templates
  - Set up error handling

Option 2: Self-Hosted

Docker Compose:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=${N8N_PASSWORD}
      - N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
    volumes:
      - ./n8n:/home/node/.n8n
    ports:
      - 5678:5678

MVP Implementation Priority

  1. Week 1: Basic setup and authentication
  2. Week 2: Daily compliance check workflow
  3. Week 3: Document processing workflow
  4. Week 4: WhatsApp integration workflows
  5. Week 5: Board report generation
  6. Week 6: Error handling and monitoring

Success Metrics

  • Workflow success rate > 95%
  • Average execution time < 30 seconds
  • Zero manual intervention for routine tasks
  • 80% of tasks automated

Related Documents: