{
  "name": "High Risk Transaction Workflow",
  "nodes": [
    {
      "parameters": {
        "path": "high-risk-action",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Extract transaction data\nconst transaction = items[0].json;\n\n// Log the HIGH RISK transaction\nconsole.log('\u26a0\ufe0f HIGH RISK TRANSACTION DETECTED:', transaction.transactionId);\nconsole.log('Amount:', transaction.amount);\nconsole.log('Reason:', transaction.riskReason);\n\n// Prepare hold response\nreturn [\n  {\n    json: {\n      transactionId: transaction.transactionId,\n      riskLevel: 'HIGH',\n      actionTaken: 'HOLD',\n      success: true,\n      message: 'Transaction held for security review',\n      executedBy: 'n8n-high-risk-workflow',\n      timestamp: new Date().toISOString(),\n      alertPriority: 'URGENT',\n      requiresManualReview: true\n    }\n  }\n];"
      },
      "name": "Process High Risk",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        470,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Alert fraud team\nconst data = items[0].json;\n\nconst fraudAlert = {\n  alertType: 'HIGH_RISK_TRANSACTION',\n  transactionId: data.transactionId,\n  priority: 'URGENT',\n  message: `High risk transaction detected - ${data.transactionId}`,\n  alertedAt: new Date().toISOString(),\n  fraudTeamNotified: true\n};\n\nconsole.log('\ud83d\udea8 FRAUD TEAM ALERT:', JSON.stringify(fraudAlert, null, 2));\n\nreturn [\n  {\n    json: {\n      ...data,\n      ...fraudAlert\n    }\n  }\n];"
      },
      "name": "Alert Fraud Team",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        690,
        200
      ]
    },
    {
      "parameters": {
        "functionCode": "// Hold transaction\nconst data = items[0].json;\n\nconsole.log(`Transaction ${data.transactionId} has been HELD`);\nconsole.log('Status changed to: ON_HOLD');\nconsole.log('Awaiting fraud team review');\n\nreturn [\n  {\n    json: {\n      ...data,\n      transactionStatus: 'HELD',\n      heldAt: new Date().toISOString(),\n      holdReason: 'High risk score detected',\n      awaitingReview: true\n    }\n  }\n];"
      },
      "name": "Hold Transaction",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        690,
        400
      ]
    },
    {
      "parameters": {
        "functionCode": "// Notify customer\nconst data = items[0].json;\n\nconst customerNotification = {\n  notificationType: 'TRANSACTION_HELD',\n  message: 'Your transaction is under security review. We will contact you shortly.',\n  sentToEmail: data.customerEmail || 'customer@email.com',\n  sentToPhone: data.customerPhone || '+91-XXXXXXXXXX',\n  notifiedAt: new Date().toISOString()\n};\n\nconsole.log('\ud83d\udce7 Customer notification sent:', customerNotification);\n\nreturn [\n  {\n    json: {\n      ...data,\n      ...customerNotification\n    }\n  }\n];"
      },
      "name": "Notify Customer",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        910,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"amount\"]}}",
              "operation": "largerEqual",
              "value2": 100000
            }
          ]
        }
      },
      "name": "Check if Critical",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1130,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Trigger account freeze for critical amounts\nconst data = items[0].json;\n\nconsole.log('\ud83d\udd12 CRITICAL TRANSACTION - Freezing account temporarily');\n\nreturn [\n  {\n    json: {\n      ...data,\n      actionTaken: 'FREEZE',\n      accountFrozen: true,\n      frozenAt: new Date().toISOString(),\n      freezeReason: 'Critical high-risk transaction detected'\n    }\n  }\n];"
      },
      "name": "Freeze Account",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1350,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{$json}}",
        "options": {}
      },
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        1570,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Process High Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process High Risk": {
      "main": [
        [
          {
            "node": "Alert Fraud Team",
            "type": "main",
            "index": 0
          },
          {
            "node": "Hold Transaction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert Fraud Team": {
      "main": [
        [
          {
            "node": "Notify Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hold Transaction": {
      "main": [
        [
          {
            "node": "Notify Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Customer": {
      "main": [
        [
          {
            "node": "Check if Critical",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Critical": {
      "main": [
        [
          {
            "node": "Freeze Account",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Freeze Account": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {},
  "id": "high-risk-workflow-001"
}