Skip to main content

Workflow Patterns

This guide documents reusable patterns for building n8n workflows within the SO1 automation system.

Input Processing Patterns

Pattern A: Webhook → Parse → Validate

Purpose: Secure and validated input processing Use Cases: GitHub webhooks, API endpoints, external integrations
HOOKSTART → CODE (Parser) → IF (Validation) → EDIT FIELDS (Standardize)

                              THROW (Error)

Key Nodes

NodeRole
HOOKSTARTSecure webhook with authentication
CODEExtract & validate payload structure
IFCheck required fields and data types
EDIT FIELDSStandardize to common schema
THROWLog and alert on validation failure

LLM Integration Patterns

Pattern B: Throttled LLM Chain

Purpose: Rate-limited multi-stage LLM processing
INPUT → THROTTLE (3s) → LLM Stage 1 → THROTTLE (5s) → LLM Stage 2 → OUTPUT

Configuration

  • Use 3-5 second delays between LLM calls
  • Implement retry logic with exponential backoff
  • Cache intermediate results

Decision Patterns

Pattern C: Quality Gate

Purpose: Iterative processing until quality threshold
GENERATE → EVALUATE → IF (Quality ≥ 85%) → OUTPUT

           REVISE → GENERATE

Implementation

// Quality check logic
if (qualityScore >= 0.85 || iterations >= maxIterations) {
  return { approved: true };
}
return { approved: false, feedback: issues };

Output Patterns

Pattern D: Multi-Channel Notification

Purpose: Deliver to multiple destinations
RESULT → SPLIT → Slack Webhook
              → Notion Page
              → Email
              → GitHub PR Comment

Configuration

Each channel runs in parallel with independent error handling.

Error Handling Patterns

Pattern E: Graceful Degradation

Purpose: Continue processing despite partial failures
TRY (Primary) → CATCH → TRY (Fallback) → CATCH → NOTIFY (Failure)

Best Practices

  1. Always have a fallback path
  2. Log all errors with context
  3. Notify on critical failures
  4. Don’t fail silently

Composition Rules

Chaining Workflows

Use executeWorkflow nodes to chain modular workflows:
{
  "workflowId": "NEXT_WORKFLOW_ID",
  "options": {
    "waitForCompletion": true
  }
}

Shared Data

Pass context between workflows via:
  • Workflow input parameters
  • Shared database tables
  • Message queues