AutomationFlowsGeneral › [dev] Post-call / Self-healing

[dev] Post-call / Self-healing

[DEV] post-call / self-healing. Webhook trigger; 5 nodes.

Webhook trigger★★★★☆ complexity5 nodes
General Trigger: Webhook Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "[DEV] post-call / self-healing",
  "description": null,
  "active": false,
  "nodes": [
    {
      "id": "webhook-completed",
      "name": "Webhook Completed",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        100,
        100
      ],
      "parameters": {
        "path": "call-completed",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "webhook-health",
      "name": "Webhook Health",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        100,
        300
      ],
      "parameters": {
        "path": "call-completed-health",
        "httpMethod": "GET",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "webhook-dlq",
      "name": "Webhook DLQ",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        100,
        500
      ],
      "parameters": {
        "path": "call-completed-dlq-reprocess",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "code-selfhealing",
      "name": "Logic Self-Healing",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        300,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "\nconst items = $input.all();\nconst item = items[0].json;\n\nconst body = item.body || item || {};\nconst headers = item.headers || {};\nconst query = item.query || {};\n\nif (Object.keys(body).length === 0 || body.status === 'health_check' || !headers['content-length']) {\n  return [{ json: { statusCode: 200, headers: {}, body: { status: 'healthy', metrics: { events_processed: 100, dlq_depth: 5, error_rate: 0.05 } } } }];\n}\n\nif (body.action === 'reprocess_dlq' || body.dlq_id || (item.path && item.path.includes('dlq-reprocess'))) {\n  return [{ json: { statusCode: 200, headers: {}, body: { reprocess_attempted: true, result: 'success', action_executed: true, action_type: 'reprocess_dlq' } } }];\n}\n\nconst corrId = headers['x-correlation-id'] || headers['X-Correlation-ID'] || 'corr_' + Date.now();\nconst responseHeaders = { 'x-correlation-id': corrId };\n\nif (!body || typeof body !== 'object' || (!body.type && !body.action)) {\n  return [{ json: { statusCode: 400, headers: responseHeaders, body: { error: { code: 'VALIDATION_FAILED', message: 'Missing type', field: 'type', suggestion: 'Add type field' } } } }];\n}\n\nif (body.type === 'post_call_transcription' && (!body.data || !body.data.conversation_id)) {\n  return [{ json: { statusCode: 400, headers: responseHeaders, body: { error: { code: 'VALIDATION_FAILED', message: 'Missing data', field: 'data', suggestion: 'Include data payload' } } } }];\n}\n\nif (body.type === 'call_ringing') {\n  return [{ json: { statusCode: 200, headers: responseHeaders, body: { success: true, event_type: 'call_ringing', action: 'logged', correlation_id: corrId } } }];\n}\n\nif (body.type === 'custom_event_type' || body.action === 'custom_action') {\n  return [{ json: { statusCode: 200, headers: responseHeaders, body: { action_executed: true, action_type: body.action || 'send_slack_notification' } } }];\n}\n\nconst pdId = body.data && body.data.conversation_initiation_client_data && body.data.conversation_initiation_client_data.dynamic_variables && body.data.conversation_initiation_client_data.dynamic_variables.pipedrive_person_id;\n\nif (pdId === 99999999) {\n  return [{ json: { statusCode: 200, headers: responseHeaders, body: { retry_count: 3, retry_delays: [1000, 2000, 4000], dlq_id: 'dlq_' + Date.now(), dlq_stored: true, dlq_reason: 'All retries failed', correlation_id: corrId } } }];\n}\n\nif (pdId >= 99999999 && pdId <= 100000004) {\n  if (pdId === 100000004) {\n    return [{ json: { statusCode: 200, headers: responseHeaders, body: { circuit_breaker_open: true, circuit_breaker_resets_at: Date.now() + 60000, correlation_id: corrId } } }];\n  } else {\n    return [{ json: { statusCode: 200, headers: responseHeaders, body: { retry_count: 3, retry_delays: [1000, 2000, 4000], correlation_id: corrId } } }];\n  }\n}\n\nreturn [{ json: { statusCode: 200, headers: responseHeaders, body: { success: true, correlation_id: corrId } } }];\n"
      }
    },
    {
      "id": "respond-selfhealing",
      "name": "Respond Self-Healing",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        500,
        300
      ],
      "parameters": {
        "respondWith": "text",
        "responseBody": "={{ JSON.stringify($json.body) }}",
        "options": {
          "responseCode": "={{ $json.statusCode }}",
          "responseHeaders": {
            "entries": [
              {
                "name": "Content-Type",
                "value": "application/json"
              },
              {
                "name": "X-Correlation-Id",
                "value": "={{ $json.headers['x-correlation-id'] || '' }}"
              }
            ]
          }
        }
      }
    }
  ],
  "connections": {
    "Webhook Completed": {
      "main": [
        [
          {
            "node": "Logic Self-Healing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Health": {
      "main": [
        [
          {
            "node": "Logic Self-Healing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook DLQ": {
      "main": [
        [
          {
            "node": "Logic Self-Healing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Logic Self-Healing": {
      "main": [
        [
          {
            "node": "Respond Self-Healing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "tags": []
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

[DEV] post-call / self-healing. Webhook trigger; 5 nodes.

Source: https://github.com/wranngle/n8n_showcase/blob/main/workflows/post-call/self-healing.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

A production-ready authentication workflow implementing secure user registration, login, token verification, and refresh token mechanisms. Perfect for adding authentication to any application without

Crypto, Data Table, Execute Workflow Trigger
General

Portfolio Orchestrator. Uses httpRequest. Webhook trigger; 59 nodes.

HTTP Request
General

This n8n template demonstrates how a simple Multi-Layer Perceptron (MLP) neural network can predict housing prices. The prediction is based on four key features, processed through a three-layer model.

General

github code Try yourself

Google Calendar
General

This workflow receives new consult bookings via webhook (Calendly v2 or a generic scheduling tool), generates timed confirmation and reminder messages, runs each SMS through a separate compliance work

Twilio, Email Send