AutomationFlowsAI & RAG › Route Revenue Transactions and Assess AI Outputs with Anthropic Claude and…

Route Revenue Transactions and Assess AI Outputs with Anthropic Claude and…

Original n8n title: Route Revenue Transactions and Assess AI Outputs with Anthropic Claude and Openai

ByCheng Siong Chin @cschin on n8n.io

This workflow automates intelligent routing of user queries to optimal AI models (Anthropic, OpenAI) based on complexity analysis, then validates outputs through multi-stage quality assessment. Designed for teams managing high-volume AI operations, it solves the critical problem…

Cron / scheduled trigger★★★★★ complexityAI-powered37 nodesAgentAnthropic ChatOutput Parser StructuredAgent ToolTool CodeData Table
AI & RAG Trigger: Cron / scheduled Nodes: 37 Complexity: ★★★★★ AI nodes: yes Added:

This workflow corresponds to n8n.io template #13341 — we link there as the canonical source.

This workflow follows the Agent → Agenttool recipe pattern — see all workflows that pair these two integrations.

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
{
  "id": "bpjXPC_tpVC_1eIvwuTsP",
  "name": "Multi-model AI routing & quality assessment system",
  "tags": [],
  "nodes": [
    {
      "id": "db738604-8327-4e32-ab93-6d50f8ba509d",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1760,
        272
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "efc35e80-b30d-41c1-bdef-72164d24f257",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1536,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "revenueThreshold",
              "type": "number",
              "value": 10000
            },
            {
              "id": "id-2",
              "name": "highRiskThreshold",
              "type": "number",
              "value": 50000
            },
            {
              "id": "id-3",
              "name": "complianceRegion",
              "type": "string",
              "value": "US"
            },
            {
              "id": "id-4",
              "name": "taxRate",
              "type": "number",
              "value": 0.21
            },
            {
              "id": "id-5",
              "name": "payoutCommissionRate",
              "type": "number",
              "value": 0.15
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "df98c1e9-4a36-4c82-bd08-86ec75692913",
      "name": "Generate Sample Revenue Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1312,
        272
      ],
      "parameters": {
        "jsCode": "// Generate sample revenue data with multiple transactions\nconst transactions = [\n  {\n    transactionId: \"TXN-001\",\n    partnerId: \"PARTNER-123\",\n    partnerName: \"Acme Corp\",\n    revenueAmount: 15000,\n    engagementMetrics: {\n      clicks: 1250,\n      conversions: 85,\n      impressions: 50000\n    },\n    timestamp: new Date().toISOString(),\n    channel: \"affiliate\",\n    region: \"North America\",\n    status: \"pending\"\n  },\n  {\n    transactionId: \"TXN-002\",\n    partnerId: \"PARTNER-456\",\n    partnerName: \"Global Tech Solutions\",\n    revenueAmount: 28500,\n    engagementMetrics: {\n      clicks: 2100,\n      conversions: 142,\n      impressions: 85000\n    },\n    timestamp: new Date(Date.now() - 3600000).toISOString(),\n    channel: \"direct\",\n    region: \"Europe\",\n    status: \"pending\"\n  },\n  {\n    transactionId: \"TXN-003\",\n    partnerId: \"PARTNER-789\",\n    partnerName: \"Digital Marketing Pro\",\n    revenueAmount: 8750,\n    engagementMetrics: {\n      clicks: 680,\n      conversions: 45,\n      impressions: 32000\n    },\n    timestamp: new Date(Date.now() - 7200000).toISOString(),\n    channel: \"referral\",\n    region: \"Asia Pacific\",\n    status: \"pending\"\n  },\n  {\n    transactionId: \"TXN-004\",\n    partnerId: \"PARTNER-234\",\n    partnerName: \"Enterprise Partners Inc\",\n    revenueAmount: 45000,\n    engagementMetrics: {\n      clicks: 3500,\n      conversions: 225,\n      impressions: 120000\n    },\n    timestamp: new Date(Date.now() - 10800000).toISOString(),\n    channel: \"affiliate\",\n    region: \"North America\",\n    status: \"pending\"\n  },\n  {\n    transactionId: \"TXN-005\",\n    partnerId: \"PARTNER-567\",\n    partnerName: \"StartUp Ventures\",\n    revenueAmount: 5200,\n    engagementMetrics: {\n      clicks: 420,\n      conversions: 28,\n      impressions: 18000\n    },\n    timestamp: new Date(Date.now() - 14400000).toISOString(),\n    channel: \"social\",\n    region: \"Latin America\",\n    status: \"pending\"\n  }\n];\n\nreturn transactions.map(transaction => ({ json: transaction }));"
      },
      "typeVersion": 2
    },
    {
      "id": "f595713f-ea15-4fb1-a12a-0de19d33a0f6",
      "name": "Revenue Signal Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1088,
        272
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a Revenue Signal Validation Agent specialized in analyzing engagement and payout data.\n\nYour task is to:\n1. Validate the structure and completeness of revenue transaction data\n2. Verify that all required fields are present: transactionId, partnerId, revenueAmount, engagementMetrics\n3. Check data quality: ensure amounts are positive numbers, metrics are realistic, timestamps are valid\n4. Detect anomalies: unusual patterns, suspicious engagement ratios, duplicate transactions\n5. Calculate engagement quality score (0-100) based on click-through rates, conversion rates\n6. Assign validation status: VALID, INVALID, or SUSPICIOUS\n7. Provide detailed reasoning for the validation decision\n\nReturn structured validation results with all findings."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "620cc606-6e7f-4ecb-90e5-c061d59f402d",
      "name": "Anthropic Model - Revenue Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -1136,
        496
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9ccec2a0-45e4-450b-9ff8-e60411241f17",
      "name": "Revenue Validation Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -960,
        496
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"transactionId\": {\n      \"type\": \"string\",\n      \"description\": \"Original transaction ID\"\n    },\n    \"validationStatus\": {\n      \"type\": \"string\",\n      \"description\": \"Validation result: VALID, INVALID, or SUSPICIOUS\"\n    },\n    \"engagementQualityScore\": {\n      \"type\": \"number\",\n      \"description\": \"Quality score from 0-100\"\n    },\n    \"anomaliesDetected\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"List of detected anomalies\"\n    },\n    \"reasoning\": {\n      \"type\": \"string\",\n      \"description\": \"Detailed explanation of validation decision\"\n    },\n    \"originalData\": {\n      \"type\": \"object\",\n      \"description\": \"Original transaction data\"\n    }\n  },\n  \"required\": [\"transactionId\", \"validationStatus\", \"engagementQualityScore\", \"reasoning\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "1cf414c1-845c-4b44-b800-1b5e6475ab7c",
      "name": "Route by Validation Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        -720,
        256
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Valid",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.validationStatus }}",
                    "rightValue": "VALID"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Invalid",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.validationStatus }}",
                    "rightValue": "INVALID"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.validationStatus }}",
                    "rightValue": "SUSPICIOUS"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Unprocessed"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "67e8c79f-fdd6-46ed-a8c3-838e52fde728",
      "name": "Governance Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -64,
        160
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a Governance Agent responsible for coordinating monetization workflows and ensuring compliance.\n\nYour task is to:\n1. Receive validated revenue data and orchestrate the monetization process\n2. Call the Payout Calculation Agent Tool to determine partner payouts based on revenue and commission rates\n3. Call the Compliance Check Agent Tool to verify regulatory requirements are met\n4. Call the Risk Assessment Agent Tool to evaluate financial and operational risks\n5. Call the Tax Calculation Tool to compute tax liabilities\n6. Synthesize all tool outputs into a comprehensive governance decision\n7. Assign final risk level: LOW, MEDIUM, HIGH, or CRITICAL\n8. Provide actionable recommendations for each transaction\n\nCoordinate all tools systematically and return structured governance results."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "12c8f11d-128e-4f4c-a950-4681e50c02fe",
      "name": "Anthropic Model - Governance Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -544,
        416
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "df19c336-4777-4226-ba63-ad882c4a133e",
      "name": "Governance Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -384,
        416
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"transactionId\": {\n      \"type\": \"string\",\n      \"description\": \"Transaction identifier\"\n    },\n    \"payoutAmount\": {\n      \"type\": \"number\",\n      \"description\": \"Calculated payout amount\"\n    },\n    \"taxLiability\": {\n      \"type\": \"number\",\n      \"description\": \"Tax amount owed\"\n    },\n    \"complianceStatus\": {\n      \"type\": \"string\",\n      \"description\": \"Compliance check result: COMPLIANT or NON_COMPLIANT\"\n    },\n    \"riskLevel\": {\n      \"type\": \"string\",\n      \"description\": \"Overall risk: LOW, MEDIUM, HIGH, or CRITICAL\"\n    },\n    \"riskFactors\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Identified risk factors\"\n    },\n    \"recommendations\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Actionable recommendations\"\n    },\n    \"approvalRequired\": {\n      \"type\": \"boolean\",\n      \"description\": \"Whether manual approval is needed\"\n    }\n  },\n  \"required\": [\"transactionId\", \"payoutAmount\", \"complianceStatus\", \"riskLevel\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "2ce36366-6d51-48ec-8377-b3d6931d9dce",
      "name": "Payout Calculation Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        -256,
        320
      ],
      "parameters": {
        "text": "={{ $fromAI(\"revenueData\", \"Revenue transaction data to calculate payouts\", \"json\") }}",
        "options": {
          "systemMessage": "You are a Payout Calculation Specialist.\n\nYour task is to:\n1. Analyze revenue transaction data provided\n2. Calculate partner payout amounts based on revenue and commission rates\n3. Apply tiered commission structures if applicable\n4. Account for any deductions or adjustments\n5. Verify calculation accuracy\n6. Return structured payout details including gross revenue, commission rate, deductions, and net payout amount"
        },
        "hasOutputParser": true,
        "toolDescription": "Calculates partner payout amounts based on revenue data and commission rates"
      },
      "typeVersion": 3
    },
    {
      "id": "a98def78-bddb-4222-be9a-185166f6d677",
      "name": "Anthropic Model - Payout Tool",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -288,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0c11a85d-e50a-4ba6-a1c9-60a38d0d3e88",
      "name": "Payout Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -96,
        528
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"grossRevenue\": {\n      \"type\": \"number\",\n      \"description\": \"Total revenue amount\"\n    },\n    \"commissionRate\": {\n      \"type\": \"number\",\n      \"description\": \"Applied commission rate\"\n    },\n    \"deductions\": {\n      \"type\": \"number\",\n      \"description\": \"Total deductions\"\n    },\n    \"netPayoutAmount\": {\n      \"type\": \"number\",\n      \"description\": \"Final payout amount\"\n    }\n  },\n  \"required\": [\"grossRevenue\", \"commissionRate\", \"netPayoutAmount\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "048485d2-6495-47cb-ab3e-b2a147b18b12",
      "name": "Compliance Check Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        80,
        320
      ],
      "parameters": {
        "text": "={{ $fromAI(\"transactionData\", \"Transaction data to verify compliance\", \"json\") }}",
        "options": {
          "systemMessage": "You are a Compliance Verification Specialist.\n\nYour task is to:\n1. Review transaction data for regulatory compliance\n2. Verify adherence to regional regulations (US, EU, APAC)\n3. Check KYC/AML requirements\n4. Validate transaction limits and thresholds\n5. Identify compliance violations or risks\n6. Return compliance status: COMPLIANT, NON_COMPLIANT, or REQUIRES_REVIEW\n7. Provide detailed compliance findings and required actions"
        },
        "hasOutputParser": true,
        "toolDescription": "Verifies regulatory compliance for revenue transactions including KYC/AML and regional requirements"
      },
      "typeVersion": 3
    },
    {
      "id": "20ac6c4a-fc90-4c38-9ebb-7b29a9e3dd82",
      "name": "Anthropic Model - Compliance Tool",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        80,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0faaddfc-bc84-42a0-9c46-a12640c9ef0d",
      "name": "Compliance Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        288,
        528
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"complianceStatus\": {\n      \"type\": \"string\",\n      \"description\": \"COMPLIANT, NON_COMPLIANT, or REQUIRES_REVIEW\"\n    },\n    \"violations\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"List of compliance violations\"\n    },\n    \"requiredActions\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Actions needed to achieve compliance\"\n    }\n  },\n  \"required\": [\"complianceStatus\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "980e3b90-cf06-4950-ada9-686b89344ee5",
      "name": "Risk Assessment Agent Tool",
      "type": "@n8n/n8n-nodes-langchain.agentTool",
      "position": [
        416,
        320
      ],
      "parameters": {
        "text": "={{ $fromAI(\"transactionData\", \"Transaction data for risk assessment\", \"json\") }}",
        "options": {
          "systemMessage": "You are a Risk Assessment Specialist for financial transactions.\n\nYour task is to:\n1. Evaluate financial and operational risks in revenue transactions\n2. Assess fraud risk based on transaction patterns and anomalies\n3. Evaluate credit risk and partner reliability\n4. Identify operational risks (processing delays, system failures)\n5. Calculate overall risk score (0-100)\n6. Assign risk level: LOW, MEDIUM, HIGH, or CRITICAL\n7. Recommend risk mitigation strategies\n8. Flag transactions requiring manual review"
        },
        "hasOutputParser": true,
        "toolDescription": "Assesses financial and operational risks for revenue transactions and provides risk scores"
      },
      "typeVersion": 3
    },
    {
      "id": "4faf3fcf-f1bb-47f0-9795-5f615570ea56",
      "name": "Anthropic Model - Risk Tool",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        464,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "03e934aa-e94f-4a1a-9e71-9917c51d0030",
      "name": "Risk Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        672,
        528
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"riskScore\": {\n      \"type\": \"number\",\n      \"description\": \"Overall risk score 0-100\"\n    },\n    \"riskLevel\": {\n      \"type\": \"string\",\n      \"description\": \"LOW, MEDIUM, HIGH, or CRITICAL\"\n    },\n    \"riskFactors\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Identified risk factors\"\n    },\n    \"mitigationStrategies\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Recommended mitigation actions\"\n    },\n    \"requiresManualReview\": {\n      \"type\": \"boolean\",\n      \"description\": \"Whether manual review is needed\"\n    }\n  },\n  \"required\": [\"riskScore\", \"riskLevel\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "2884bb07-51e7-44a2-82ee-dbc205f6fbcf",
      "name": "Tax Calculation Tool",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        752,
        320
      ],
      "parameters": {
        "jsCode": "const revenueData = $fromAI('revenueData', 'Revenue data for tax calculation', 'json');\n\ntry {\n  const data = typeof revenueData === 'string' ? JSON.parse(revenueData) : revenueData;\n  \n  const revenue = parseFloat(data.revenueAmount || data.grossRevenue || 0);\n  const region = data.region || 'US';\n  \n  // Tax rates by region\n  const taxRates = {\n    'US': 0.21,\n    'EU': 0.25,\n    'UK': 0.19,\n    'APAC': 0.17\n  };\n  \n  const taxRate = taxRates[region] || 0.21;\n  const taxLiability = revenue * taxRate;\n  const netRevenue = revenue - taxLiability;\n  \n  const result = {\n    revenue: revenue.toFixed(2),\n    region: region,\n    taxRate: taxRate,\n    taxLiability: taxLiability.toFixed(2),\n    netRevenue: netRevenue.toFixed(2),\n    calculationDate: new Date().toISOString()\n  };\n  \n  return JSON.stringify(result, null, 2);\n  \n} catch (error) {\n  return JSON.stringify({\n    error: 'Tax calculation failed',\n    message: error.message,\n    taxLiability: 0\n  });\n}",
        "description": "Calculates tax liabilities based on revenue amounts and applicable tax rates"
      },
      "typeVersion": 1.3
    },
    {
      "id": "d426c3d8-991d-4a6e-8660-424784a34a05",
      "name": "Route by Risk Level",
      "type": "n8n-nodes-base.switch",
      "position": [
        960,
        176
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Low Risk",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.riskLevel }}",
                    "rightValue": "LOW"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.riskLevel }}",
                    "rightValue": "MEDIUM"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "High Risk",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "or",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.riskLevel }}",
                    "rightValue": "HIGH"
                  },
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.riskLevel }}",
                    "rightValue": "CRITICAL"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Unclassified"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "18e94122-9075-4bd7-9ada-3e071a1ebeb4",
      "name": "Store Approved Transactions",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1232,
        160
      ],
      "parameters": {
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "approved_transactions"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "2923b02c-fdf9-4ebc-ab17-4ae234c4ee93",
      "name": "Store High Risk Transactions",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1232,
        352
      ],
      "parameters": {
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "high_risk_transactions"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "33d297e6-5c13-45e6-bd3b-c493b4e05ea1",
      "name": "Store Failed Validations",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1232,
        624
      ],
      "parameters": {
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "failed_validations"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "952da337-e41a-457f-a761-33a74441de92",
      "name": "Aggregate Results",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1712,
        352
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "7602ac53-2a83-4837-9967-72723ef30073",
      "name": "Reporting Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1904,
        352
      ],
      "parameters": {
        "text": "={{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a Reporting Agent specialized in generating comprehensive monetization reports.\n\nYour task is to:\n1. Analyze aggregated transaction data from all processing paths\n2. Generate executive summary with key metrics: total transactions, approval rate, risk distribution\n3. Calculate financial metrics: total revenue, total payouts, total tax liability, net profit\n4. Identify trends and patterns across approved, high-risk, and failed transactions\n5. Highlight compliance issues and risk factors\n6. Provide actionable insights and recommendations for process improvement\n7. Format the report in a structured, executive-ready format\n\nReturn comprehensive reporting data with all analytics and insights."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3.1
    },
    {
      "id": "ee1d7cf1-9f79-4724-a3f3-b4c53b3c4ecc",
      "name": "Anthropic Model - Reporting Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        1904,
        576
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "7c0469a2-d685-44dc-a8cb-cdda7505974d",
      "name": "Reporting Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2096,
        576
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"executiveSummary\": {\n      \"type\": \"string\",\n      \"description\": \"High-level summary of findings\"\n    },\n    \"totalTransactions\": {\n      \"type\": \"number\",\n      \"description\": \"Total number of transactions processed\"\n    },\n    \"approvalRate\": {\n      \"type\": \"number\",\n      \"description\": \"Percentage of approved transactions\"\n    },\n    \"totalRevenue\": {\n      \"type\": \"number\",\n      \"description\": \"Total revenue amount\"\n    },\n    \"totalPayouts\": {\n      \"type\": \"number\",\n      \"description\": \"Total payout amount\"\n    },\n    \"totalTaxLiability\": {\n      \"type\": \"number\",\n      \"description\": \"Total tax liability\"\n    },\n    \"netProfit\": {\n      \"type\": \"number\",\n      \"description\": \"Net profit after payouts and taxes\"\n    },\n    \"riskDistribution\": {\n      \"type\": \"object\",\n      \"description\": \"Distribution of transactions by risk level\"\n    },\n    \"keyInsights\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Key insights and findings\"\n    },\n    \"recommendations\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"string\"\n      },\n      \"description\": \"Actionable recommendations\"\n    }\n  },\n  \"required\": [\"executiveSummary\", \"totalTransactions\", \"totalRevenue\"]\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "88471f6a-f42c-45b9-a18e-1e071ccc325d",
      "name": "Store Final Report",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2256,
        352
      ],
      "parameters": {
        "options": {},
        "dataTableId": {
          "__rl": true,
          "mode": "name",
          "value": "monetization_reports"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "830ded1e-2509-48b2-8a38-8dadcd83315a",
      "name": "Merge Storage Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        1456,
        336
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "ac70415b-8948-4240-b764-a152d9ba4775",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -368
      ],
      "parameters": {
        "color": 6,
        "width": 576,
        "height": 320,
        "content": "## Prerequisites\nActive API accounts for Anthropic Claude and OpenAI. \n## Use Cases\nCustomer support ticket routing and quality monitoring. \n## Customization\nAdjust classification logic by modifying validation node expressions. \n## Benefits\nReduces AI costs by 40-60% through intelligent model selection. "
      },
      "typeVersion": 1
    },
    {
      "id": "50f3ab4c-90ba-4bfb-a10a-4a9a5f73e8d5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        -336
      ],
      "parameters": {
        "width": 544,
        "height": 304,
        "content": "\n## Setup Steps\n1. Connect Anthropic and OpenAI  API credentials in n8n credentials manager\n2. Configure Google Sheets connection for storing validation results and flagged responses\n3. Set Schedule Trigger interval (recommended: hourly or daily based on volume)\n4. Customize classification thresholds in validation nodes (confidence scores, risk levels)\n5. Update agent prompt templates to match your domain requirements\n6. Configure Slack/Gmail notifications for high-priority quality flags\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fcd6b834-7e0c-4ee2-a6a3-4103bd03a628",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -304
      ],
      "parameters": {
        "width": 848,
        "height": 224,
        "content": "## How It Works\nThis workflow automates intelligent routing of user queries to optimal AI models (Anthropic, OpenAI) based on complexity analysis, then validates outputs through multi-stage quality assessment. Designed for teams managing high-volume AI operations, it solves the critical problem of balancing cost-efficiency with output quality\u2014automatically selecting budget-friendly models for simple tasks while routing complex requests to premium models. The system analyzes incoming queries via validation tools, routes them through specialized AI agents based on assessment scores, executes parallel quality checks, aggregates validation results, and stores flagged responses for human review. This ensures consistent, high-quality AI responses while optimizing computational costs and maintaining governance standards across diverse use cases."
      },
      "typeVersion": 1
    },
    {
      "id": "a67991d2-9ac7-4fb0-927c-f8783462236e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 752,
        "height": 832,
        "content": "## Assess Risk  \n**What:** Assess risk simultaneously.\n**Why:** Comprehensive quality assurance  "
      },
      "typeVersion": 1
    },
    {
      "id": "f307ecd2-f8dd-4bc4-8045-3334f07bedd0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 1440,
        "height": 736,
        "content": "## Model-Specific Agents\n**What:** Anthropic and OpenAI generate responses based on routing.\n**Why:** Leverages each model's strengths for optimal performance."
      },
      "typeVersion": 1
    },
    {
      "id": "a1340649-9522-4ecc-9623-dc0e8d95353f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 1248,
        "height": 720,
        "content": "## Query Classification\n**What:** Categorizes incoming requests by complexity and domain.\n**Why:** Determines optimal routing path and appropriate model selection."
      },
      "typeVersion": 1
    },
    {
      "id": "a601b9df-eff4-478d-97b1-629803747d45",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1664,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 832,
        "height": 832,
        "content": "\n## Results Reporting \n**What:** Consolidates validation scores and flags issues.\n**Why:** Provides unified quality metrics for decision-making  "
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "e365a2f6-4704-48d8-9f36-5dfe4a9b9813",
  "connections": {
    "Reporting Agent": {
      "main": [
        [
          {
            "node": "Store Final Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Governance Agent": {
      "main": [
        [
          {
            "node": "Route by Risk Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Results": {
      "main": [
        [
          {
            "node": "Reporting Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Risk Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Risk Assessment Agent Tool",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Route by Risk Level": {
      "main": [
        [
          {
            "node": "Store Approved Transactions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store High Risk Transactions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Payout Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Payout Calculation Agent Tool",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Revenue Signal Agent": {
      "main": [
        [
          {
            "node": "Route by Validation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tax Calculation Tool": {
      "ai_tool": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Merge Storage Results": {
      "main": [
        [
          {
            "node": "Aggregate Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Generate Sample Revenue Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reporting Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Reporting Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Compliance Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Compliance Check Agent Tool",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Governance Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Store Failed Validations": {
      "main": [
        [
          {
            "node": "Merge Storage Results",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Risk Assessment Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Route by Validation Status": {
      "main": [
        [
          {
            "node": "Governance Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store Failed Validations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Model - Risk Tool": {
      "ai_languageModel": [
        [
          {
            "node": "Risk Assessment Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Compliance Check Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Store Approved Transactions": {
      "main": [
        [
          {
            "node": "Merge Storage Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sample Revenue Data": {
      "main": [
        [
          {
            "node": "Revenue Signal Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store High Risk Transactions": {
      "main": [
        [
          {
            "node": "Merge Storage Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Anthropic Model - Payout Tool": {
      "ai_languageModel": [
        [
          {
            "node": "Payout Calculation Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Payout Calculation Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Model - Revenue Agent": {
      "ai_languageModel": [
        [
          {
            "node": "Revenue Signal Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Revenue Validation Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Revenue Signal Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Model - Compliance Tool": {
      "ai_languageModel": [
        [
          {
            "node": "Compliance Check Agent Tool",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Model - Reporting Agent": {
      "ai_languageModel": [
        [
          {
            "node": "Reporting Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Model - Governance Agent": {
      "ai_languageModel": [
        [
          {
            "node": "Governance Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

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

About this workflow

This workflow automates intelligent routing of user queries to optimal AI models (Anthropic, OpenAI) based on complexity analysis, then validates outputs through multi-stage quality assessment. Designed for teams managing high-volume AI operations, it solves the critical problem…

Source: https://n8n.io/workflows/13341/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

This workflow automates enterprise budget monitoring and cost optimization using Anthropic Claude as the core AI engine across multiple specialist agents. It targets finance teams, operations managers

Agent, Anthropic Chat, Output Parser Structured +5
AI & RAG

This workflow automates end-to-end ESG (Environmental, Social, and Governance) sustainability reporting for enterprise sustainability teams, compliance officers, and green governance leads. It solves

Agent, OpenAI Chat, Output Parser Structured +12
AI & RAG

This workflow automates semiconductor board-level reliability monitoring using AI agents. It targets reliability engineers, manufacturing teams, and quality analysts. The system collects capacity, his

Google Sheets, Agent, OpenAI Chat +10
AI & RAG

Automates daily project monitoring by fetching project data, analyzing tasks and team capacity with anthropic models, and generating resource optimization recommendations. Target audience: project man

HTTP Request, Agent, Anthropic Chat +3
AI & RAG

This workflow automates procurement fraud detection and supplier compliance monitoring for organizations managing complex purchasing operations. Designed for procurement teams, audit departments, and

OpenAI Chat, Output Parser Structured, Agent +6