This workflow corresponds to n8n.io template #12385 — 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 →
{
"id": "J1H5jQX75EBWDsTh",
"name": "Intelligent Financial Anomaly Detection and Revenue Reconciliation System",
"tags": [],
"nodes": [
{
"id": "7fc718c7-4c46-4f30-9e62-113e5e0befef",
"name": "Monthly Financial Data Collection",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-2288,
208
],
"parameters": {
"rule": {
"interval": [
{
"field": "months",
"triggerAtHour": 2
}
]
}
},
"typeVersion": 1.3
},
{
"id": "59eb97c4-7900-4938-a8c2-fdfb9ce84c2a",
"name": "Workflow Configuration",
"type": "n8n-nodes-base.set",
"position": [
-2064,
208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "financialApiUrl",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Financial API endpoint URL__>"
},
{
"id": "id-2",
"name": "revenueSystemApiUrl",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Revenue system API endpoint URL__>"
},
{
"id": "id-3",
"name": "taxAgentApiUrl",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Tax agent notification API endpoint URL__>"
},
{
"id": "id-4",
"name": "alertEmail",
"type": "string",
"value": "<__PLACEHOLDER_VALUE__Email address for anomaly alerts__>"
},
{
"id": "id-5",
"name": "analysisMonths",
"type": "number",
"value": 6
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "21ca7f68-6ccc-4f2c-b3d6-ae5059d6462a",
"name": "Fetch Financial Transactions",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1840,
208
],
"parameters": {
"url": "={{ $('Workflow Configuration').first().json.financialApiUrl }}",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "months",
"value": "={{ $('Workflow Configuration').first().json.analysisMonths }}"
}
]
}
},
"typeVersion": 4.3
},
{
"id": "c3ef4ce4-8985-4c5c-baae-c7f25b467bb8",
"name": "OpenAI Model - Anomaly Detector",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1616,
432
],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "8733ac7e-4b28-4ea0-85d5-3c8b9ba2b658",
"name": "OpenAI Model - Verification Agent",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1216,
640
],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o"
},
"options": {},
"builtInTools": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "062d25fd-5fcc-4afc-8f5d-6c248d584864",
"name": "Anomaly Detection Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-944,
432
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"anomaliesDetected\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"description\": \"Whether any anomalies were found\"\n\t\t},\n\t\t\"anomalies\": {\n\t\t\t\"type\": \"array\",\n\t\t\t\"description\": \"List of detected anomalies\",\n\t\t\t\"items\": {\n\t\t\t\t\"type\": \"object\",\n\t\t\t\t\"properties\": {\n\t\t\t\t\t\"type\": {\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\"description\": \"Type of anomaly: double_charge, missing_invoice, ghost_payment, or other\"\n\t\t\t\t\t},\n\t\t\t\t\t\"transactionId\": {\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\"description\": \"Transaction identifier\"\n\t\t\t\t\t},\n\t\t\t\t\t\"amount\": {\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t\t\"description\": \"Transaction amount\"\n\t\t\t\t\t},\n\t\t\t\t\t\"description\": {\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\"description\": \"Detailed description of the anomaly\"\n\t\t\t\t\t},\n\t\t\t\t\t\"confidence\": {\n\t\t\t\t\t\t\"type\": \"number\",\n\t\t\t\t\t\t\"description\": \"Confidence score 0-100\"\n\t\t\t\t\t},\n\t\t\t\t\t\"suggestedAction\": {\n\t\t\t\t\t\t\"type\": \"string\",\n\t\t\t\t\t\t\"description\": \"Recommended action to resolve\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}"
},
"typeVersion": 1.3
},
{
"id": "c38df4f1-53fd-4b57-b3c8-8cb961b65e05",
"name": "Verification Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-1088,
640
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"verified\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"description\": \"Whether the anomaly was verified as legitimate\"\n\t\t},\n\t\t\"verificationNotes\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Notes from verification process\"\n\t\t},\n\t\t\"requiresHumanReview\": {\n\t\t\t\"type\": \"boolean\",\n\t\t\t\"description\": \"Whether human review is needed\"\n\t\t},\n\t\t\"correctionAmount\": {\n\t\t\t\"type\": \"number\",\n\t\t\t\"description\": \"Amount to correct if applicable\"\n\t\t}\n\t}\n}"
},
"typeVersion": 1.3
},
{
"id": "dd3c7741-cef9-4498-87fe-f085152c8cac",
"name": "Calculator Tool",
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"position": [
-1488,
432
],
"parameters": {},
"typeVersion": 1
},
{
"id": "4c11b6ea-d69c-4b04-818c-57b3ebdf6451",
"name": "Historical Pattern Analysis Tool",
"type": "@n8n/n8n-nodes-langchain.toolCode",
"position": [
-1360,
432
],
"parameters": {
"jsCode": "// Analyze historical transaction patterns using statistical methods\n// Input: query should contain transaction data as JSON string\n\ntry {\n // Parse the incoming transaction data\n const transactions = typeof query === 'string' ? JSON.parse(query) : query;\n \n if (!Array.isArray(transactions) || transactions.length === 0) {\n return 'No transaction data provided for analysis';\n }\n \n // Extract transaction amounts\n const amounts = transactions.map(t => parseFloat(t.amount || 0));\n \n // Calculate statistical measures\n const mean = amounts.reduce((sum, val) => sum + val, 0) / amounts.length;\n const variance = amounts.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / amounts.length;\n const stdDev = Math.sqrt(variance);\n \n // Calculate frequency distribution\n const frequencyMap = {};\n transactions.forEach(t => {\n const category = t.category || 'uncategorized';\n frequencyMap[category] = (frequencyMap[category] || 0) + 1;\n });\n \n // Identify outliers (values beyond 2 standard deviations)\n const outliers = transactions.filter(t => {\n const amount = parseFloat(t.amount || 0);\n return Math.abs(amount - mean) > 2 * stdDev;\n });\n \n // Build analysis result\n const analysis = {\n totalTransactions: transactions.length,\n statistics: {\n mean: mean.toFixed(2),\n standardDeviation: stdDev.toFixed(2),\n min: Math.min(...amounts).toFixed(2),\n max: Math.max(...amounts).toFixed(2)\n },\n frequencyDistribution: frequencyMap,\n outliers: outliers.map(t => ({\n id: t.id,\n amount: t.amount,\n category: t.category,\n deviationFromMean: (parseFloat(t.amount) - mean).toFixed(2)\n })),\n anomalyCount: outliers.length\n };\n \n return JSON.stringify(analysis, null, 2);\n \n} catch (error) {\n return `Error analyzing patterns: ${error.message}`;\n}",
"description": "Analyzes historical transaction patterns to build behavioral models and identify statistical anomalies"
},
"typeVersion": 1.3
},
{
"id": "6dfe7ed6-159d-4b6e-9ba0-be9892672928",
"name": "Anomaly Detection Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-1432,
208
],
"parameters": {
"text": "={{ 'Analyze the following financial transaction data for anomalies: ' + JSON.stringify($json) }}",
"options": {
"systemMessage": "You are a financial anomaly detection specialist with expertise in identifying unusual patterns in transaction data.\n\nYour task is to:\n1. Use the analyze_historical_patterns tool to build behavioral models from the transaction data\n2. Identify unusual activities including:\n - Double charges (duplicate transactions)\n - Missing invoices (gaps in invoice sequences)\n - Ghost payments (payments without corresponding invoices)\n - Statistical outliers and unusual patterns\n3. For each detected anomaly, call the Verification Agent Tool to verify and assess the anomaly\n4. Calculate confidence scores based on statistical deviation and pattern matching\n5. Suggest appropriate corrective actions\n\nReturn your findings in the structured format with all detected anomalies."
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 3.1
},
{
"id": "5139e38f-6d05-4ea1-8597-e5fca11a256a",
"name": "Verification Agent Tool",
"type": "@n8n/n8n-nodes-langchain.agentTool",
"position": [
-1232,
432
],
"parameters": {
"text": "={{ 'Verify this anomaly: ' + $fromAI('anomaly_data', 'The anomaly data to verify including type, amount, and description', 'string') }}",
"options": {
"systemMessage": "You are a financial verification specialist responsible for validating detected anomalies.\n\nYour task is to:\n1. Analyze the provided anomaly data\n2. Determine if the anomaly is a legitimate issue or a false positive\n3. Assess whether human review is required based on:\n - Complexity of the issue\n - Financial impact (amounts over certain thresholds)\n - Confidence level of the detection\n4. Calculate the exact correction amount if applicable\n5. Provide detailed verification notes\n\nReturn your verification results in the structured format."
},
"hasOutputParser": true,
"toolDescription": "Verifies detected financial anomalies and determines if they require human review or can be auto-corrected"
},
"typeVersion": 3
},
{
"id": "1e0c6159-215f-4135-82d1-a3c74d1a6205",
"name": "Check for Anomalies",
"type": "n8n-nodes-base.if",
"position": [
-912,
208
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "id-1",
"operator": {
"type": "boolean",
"operation": "equals"
},
"leftValue": "={{ $json.anomaliesDetected }}",
"rightValue": true
}
]
}
},
"typeVersion": 2.3
},
{
"id": "a6bd1056-36f5-4fb8-883e-70f23c673c19",
"name": "Prepare Revenue Adjustments",
"type": "n8n-nodes-base.set",
"position": [
-512,
112
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "id-1",
"name": "adjustments",
"type": "array",
"value": "={{ $json.anomalies.filter(a => a.verified && !a.requiresHumanReview).map(a => ({ transactionId: a.transactionId, correctionAmount: a.correctionAmount, type: a.type })) }}"
}
]
},
"includeOtherFields": true
},
"typeVersion": 3.4
},
{
"id": "9cc75aba-bea7-48d5-94e7-8e255248c72f",
"name": "Update Revenue Entries",
"type": "n8n-nodes-base.httpRequest",
"position": [
-288,
112
],
"parameters": {
"url": "={{ $('Workflow Configuration').first().json.revenueSystemApiUrl }}",
"method": "POST",
"options": {},
"jsonBody": "={{ { adjustments: $json.adjustments, timestamp: new Date().toISOString(), source: 'anomaly_detection_system' } }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.3
},
{
"id": "02c370e1-5654-4941-993f-7284739c412a",
"name": "Notify Tax Agent",
"type": "n8n-nodes-base.httpRequest",
"position": [
-64,
112
],
"parameters": {
"url": "={{ $('Workflow Configuration').first().json.taxAgentApiUrl }}",
"method": "POST",
"options": {},
"jsonBody": "={{ { adjustments: $json.adjustments, anomaliesCount: $json.anomalies.length, timestamp: new Date().toISOString(), status: 'completed' } }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.3
},
{
"id": "a06c6a3d-5b6e-494f-a9fd-e2ff54ca1b08",
"name": "Send Anomaly Alert",
"type": "n8n-nodes-base.emailSend",
"position": [
-512,
304
],
"parameters": {
"html": "=<h2>Financial Anomaly Detection Alert</h2>\n<p>The automated anomaly detection system has identified potential issues in the financial transactions.</p>\n\n<h3>Summary</h3>\n<ul>\n <li><strong>Anomalies Detected:</strong> {{ $json.anomaliesDetected ? 'Yes' : 'No' }}</li>\n <li><strong>Total Anomalies:</strong> {{ $json.anomalies ? $json.anomalies.length : 0 }}</li>\n <li><strong>Detection Time:</strong> {{ new Date().toISOString() }}</li>\n</ul>\n\n<h3>Anomaly Details</h3>\n{{ $json.anomalies && $json.anomalies.length > 0 ? $json.anomalies.map(a => `\n<div style=\"border: 1px solid #ddd; padding: 10px; margin: 10px 0; border-radius: 5px;\">\n <p><strong>Type:</strong> ${a.type}</p>\n <p><strong>Transaction ID:</strong> ${a.transactionId}</p>\n <p><strong>Amount:</strong> $${a.amount}</p>\n <p><strong>Description:</strong> ${a.description}</p>\n <p><strong>Confidence:</strong> ${a.confidence}%</p>\n <p><strong>Suggested Action:</strong> ${a.suggestedAction}</p>\n</div>\n`).join('') : '<p>No anomalies detected.</p>' }}\n\n<p style=\"margin-top: 20px; color: #666;\"><em>This is an automated alert from the Financial Anomaly Detection System.</em></p>",
"options": {},
"subject": "Financial Anomalies Detected - Review Required",
"toEmail": "={{ $('Workflow Configuration').first().json.alertEmail }}",
"fromEmail": "<__PLACEHOLDER_VALUE__Sender email address__>"
},
"typeVersion": 2.1
},
{
"id": "43a7475e-1f26-47fa-bb42-6c13a90b74d6",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1200,
-288
],
"parameters": {
"color": 6,
"width": 656,
"height": 272,
"content": "## Prerequisites\nOpenAI API access, financial system API credentials with read/write permissions.\n## Use Cases\nMonthly financial close automation, revenue recognition validation\n## Customization\nModify anomaly detection algorithms for industry-specific patterns\n## Benefits\nReduces financial close time by 60%, catches revenue errors before reporting"
},
"typeVersion": 1
},
{
"id": "f3cd6193-33b6-436e-9137-9f1bb7dc23e1",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1680,
-304
],
"parameters": {
"width": 432,
"height": 288,
"content": "## Setup Steps\n1. Configure OpenAI API credentials in \"Anomaly Detection Agent\"\n2. Set up financial data source API connection in \"Fetch Financial Transactions\" node with authentication\n3. Define anomaly detection thresholds and rules in AI agent tool configurations\n4. Configure tax system integration credentials in \"Update Revenue Entries\" \n5. Set up email notification service with recipient lists in \"Send Anomaly Alert\" node"
},
"typeVersion": 1
},
{
"id": "198b1c14-69b2-46f3-8549-00eba8aa1ea1",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2384,
-288
],
"parameters": {
"width": 656,
"height": 288,
"content": "## How It Works\nThis workflow automates financial oversight for accounting teams, tax professionals, and financial controllers managing monthly transaction volumes. It solves the challenge of identifying and correcting revenue discrepancies, tax calculation errors, and unusual patterns that manual review often misses. The system collects monthly financial transactions via scheduled trigger, then fetches complete transaction data through API integration. An AI anomaly detection agent analyzes patterns using multiple specialized tools: an OpenAI model identifies statistical outliers and unusual behaviors, a calculator validates mathematical accuracy of revenue entries, and a historical pattern analyzer compares against baseline trends. Detected anomalies undergo verification by a secondary AI agent to eliminate false positives. Confirmed issues route to automated revenue adjustments and tax agent notifications, while alert emails provide detailed anomaly reports with recommended actions, ensuring financial accuracy and compliance."
},
"typeVersion": 1
},
{
"id": "ae96116d-bd70-4b89-88eb-b483de49f2a5",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1648,
32
],
"parameters": {
"color": 7,
"width": 976,
"height": 736,
"content": "## Anomaly detection agent analyzes using calculator, pattern analysis, and AI models\n**Why**: Combines mathematical validation with machine learning to identify diverse anomaly types human review might miss\n\n"
},
"typeVersion": 1
},
{
"id": "d0ca5aa8-2b38-46d5-be10-1013660f3af7",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-624,
32
],
"parameters": {
"color": 7,
"width": 1024,
"height": 672,
"content": "## Transaction fetcher retrieves complete financial records via API\n**Why**: Accesses real-time data from source systems, eliminating data entry errors and delays\n\n "
},
"typeVersion": 1
},
{
"id": "835c06fc-0cd7-41c1-bdb4-4d93063db187",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2368,
64
],
"parameters": {
"color": 7,
"width": 704,
"height": 512,
"content": "\n## Scheduled trigger collects monthly financial data automatically\n**Why**: Ensures consistent monitoring without manual intervention, catching issues promptly before month-end close\n\n"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "13b58625-d315-4f1c-8f49-b0a603d63d6b",
"connections": {
"Calculator Tool": {
"ai_tool": [
[
{
"node": "Anomaly Detection Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Check for Anomalies": {
"main": [
[
{
"node": "Prepare Revenue Adjustments",
"type": "main",
"index": 0
},
{
"node": "Send Anomaly Alert",
"type": "main",
"index": 0
}
]
]
},
"Update Revenue Entries": {
"main": [
[
{
"node": "Notify Tax Agent",
"type": "main",
"index": 0
}
]
]
},
"Workflow Configuration": {
"main": [
[
{
"node": "Fetch Financial Transactions",
"type": "main",
"index": 0
}
]
]
},
"Anomaly Detection Agent": {
"main": [
[
{
"node": "Check for Anomalies",
"type": "main",
"index": 0
}
]
]
},
"Verification Agent Tool": {
"ai_tool": [
[
{
"node": "Anomaly Detection Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Verification Output Parser": {
"ai_outputParser": [
[
{
"node": "Verification Agent Tool",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Prepare Revenue Adjustments": {
"main": [
[
{
"node": "Update Revenue Entries",
"type": "main",
"index": 0
}
]
]
},
"Fetch Financial Transactions": {
"main": [
[
{
"node": "Anomaly Detection Agent",
"type": "main",
"index": 0
}
]
]
},
"Anomaly Detection Output Parser": {
"ai_outputParser": [
[
{
"node": "Anomaly Detection Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"OpenAI Model - Anomaly Detector": {
"ai_languageModel": [
[
{
"node": "Anomaly Detection Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Historical Pattern Analysis Tool": {
"ai_tool": [
[
{
"node": "Anomaly Detection Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Monthly Financial Data Collection": {
"main": [
[
{
"node": "Workflow Configuration",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model - Verification Agent": {
"ai_languageModel": [
[
{
"node": "Verification Agent Tool",
"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.
openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow automates financial oversight for accounting teams, tax professionals, and financial controllers managing monthly transaction volumes. It solves the challenge of identifying and correcting revenue discrepancies, tax calculation errors, and unusual patterns that…
Source: https://n8n.io/workflows/12385/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow automates comprehensive real estate investment analysis by orchestrating specialized AI agents to evaluate property data, market trends, and financial metrics. Designed for real estate i
This workflow automates end-to-end sustainability lifecycle management for corporate sustainability teams, ESG governance officers, and circular economy programme leads. It addresses the challenge of
This workflow automates end-to-end carbon emissions monitoring, strategy optimisation, and ESG reporting using a multi-agent AI supervisor architecture in n8n. Designed for sustainability managers, ES
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
This workflow automates end-to-end carbon emissions monitoring, strategy optimisation, and ESG reporting using a multi-agent AI supervisor architecture in n8n. Designed for sustainability managers, ES