This workflow corresponds to n8n.io template #9436 — we link there as the canonical source.
This workflow follows the Agent → Gmail 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": "KMgt49BPco6oE5Xj",
"name": "Auto-Extract & Approve Invoices with OpenAI, Jotform - Fraud Detection",
"tags": [
{
"id": "TDW7E4RVCMchXf5b",
"name": "published",
"createdAt": "2025-10-13T01:18:01.305Z",
"updatedAt": "2025-10-13T01:18:01.305Z"
}
],
"nodes": [
{
"id": "2855123e-800d-426d-9adc-35b4fcbbbd65",
"name": "Has Invoice Attachment?",
"type": "n8n-nodes-base.if",
"position": [
-1264,
256
],
"parameters": {
"options": {},
"conditions": {
"options": {
"caseSensitive": false
},
"combinator": "and",
"conditions": [
{
"id": "has-attachment",
"operator": {
"type": "boolean",
"operation": "true"
},
"leftValue": "={{ $json.attachments?.length > 0 }}",
"rightValue": true
}
]
}
},
"typeVersion": 2.2
},
{
"id": "6177f958-e010-426b-8d7a-1d9f2966eaed",
"name": "Extract Invoice Attachments",
"type": "n8n-nodes-base.code",
"position": [
-736,
192
],
"parameters": {
"jsCode": "const items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n const attachments = item.json.attachments || [];\n \n // Filter for PDF and image attachments (common invoice formats)\n const invoiceAttachments = attachments.filter(att => {\n const name = att.filename?.toLowerCase() || '';\n return name.endsWith('.pdf') || \n name.endsWith('.png') || \n name.endsWith('.jpg') || \n name.endsWith('.jpeg');\n });\n \n // Process each invoice attachment\n for (const attachment of invoiceAttachments) {\n results.push({\n json: {\n email_from: item.json.from,\n email_subject: item.json.subject,\n email_date: item.json.date,\n email_id: item.json.id,\n attachment_name: attachment.filename,\n attachment_id: attachment.attachmentId,\n attachment_size: attachment.size,\n invoice_id: `INV-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`\n },\n binary: {\n data: item.binary[attachment.attachmentId]\n }\n });\n }\n}\n\nreturn results;"
},
"typeVersion": 2
},
{
"id": "49036c5c-fdc0-47d0-8885-63dcd931f2e2",
"name": "AI Invoice OCR & Extraction",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
-576,
192
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.1
},
"messages": {
"values": [
{
"content": "=You are an expert invoice processing AI. Extract ALL information from this invoice document with perfect accuracy.\n\n**Email Context:**\nFrom: {{ $json.email_from }}\nSubject: {{ $json.email_subject }}\nDate: {{ $json.email_date }}\n\nAnalyze the attached invoice image/PDF and extract complete structured information. Return ONLY valid JSON with this exact structure:\n\n{\n \"vendor_name\": \"Company Name\",\n \"vendor_email\": \"vendor@email.com\",\n \"vendor_address\": \"Full address\",\n \"vendor_tax_id\": \"Tax/VAT ID if present\",\n \"invoice_number\": \"INV-12345\",\n \"invoice_date\": \"YYYY-MM-DD\",\n \"due_date\": \"YYYY-MM-DD\",\n \"po_number\": \"PO number if referenced\",\n \"currency\": \"USD\",\n \"line_items\": [\n {\n \"description\": \"Item description\",\n \"quantity\": 1,\n \"unit_price\": 100.00,\n \"total\": 100.00\n }\n ],\n \"subtotal\": 100.00,\n \"tax_amount\": 8.00,\n \"tax_rate\": 8.0,\n \"shipping\": 0.00,\n \"total_amount\": 108.00,\n \"payment_terms\": \"Net 30\",\n \"notes\": \"Any special notes or terms\",\n \"bank_details\": \"Bank account information if present\",\n \"invoice_category\": \"software|hardware|services|consulting|office_supplies|utilities|marketing|travel|other\",\n \"confidence_score\": 0.95\n}\n\nIMPORTANT:\n- Extract exact amounts with 2 decimal places\n- Use YYYY-MM-DD format for dates\n- If information is missing, use null\n- Be extremely accurate with numbers\n- Classify invoice into appropriate category\n- Confidence score 0-1 based on document clarity"
}
]
}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.8
},
{
"id": "e82f7d85-e1d2-408b-a3ce-b5e12993763d",
"name": "Parse Invoice Data",
"type": "n8n-nodes-base.code",
"position": [
-288,
192
],
"parameters": {
"jsCode": "const items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n try {\n // Parse AI response\n const aiText = item.json.message?.content || item.json.output || '{}';\n \n // Clean JSON\n let cleanJson = aiText.replace(/```json\\n?/g, '').replace(/```\\n?/g, '').trim();\n const jsonMatch = cleanJson.match(/\\{[\\s\\S]*\\}/);\n if (jsonMatch) {\n cleanJson = jsonMatch[0];\n }\n \n const invoiceData = JSON.parse(cleanJson);\n \n // Get original email data\n const originalData = $('Extract Invoice Attachments').item(0).json;\n \n results.push({\n json: {\n ...originalData,\n ...invoiceData,\n parsed_at: new Date().toISOString(),\n processing_status: 'extracted'\n }\n });\n } catch (error) {\n results.push({\n json: {\n ...item.json,\n parsing_error: error.message,\n processing_status: 'failed'\n }\n });\n }\n}\n\nreturn results;"
},
"typeVersion": 2
},
{
"id": "2aedc6f8-75f4-4ae3-a562-39f270728a28",
"name": "AI Fraud Detection Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
16,
144
],
"parameters": {
"text": "=You are a financial fraud detection AI with expertise in identifying invoice anomalies, duplicate submissions, and fraudulent patterns.\n\nAnalyze this invoice for potential fraud, anomalies, or issues:\n\n## INVOICE DETAILS\n**Vendor:** {{ $json.vendor_name }}\n**Invoice Number:** {{ $json.invoice_number }}\n**Date:** {{ $json.invoice_date }}\n**Due Date:** {{ $json.due_date }}\n**Amount:** {{ $json.currency }} {{ $json.total_amount }}\n**Category:** {{ $json.invoice_category }}\n**PO Number:** {{ $json.po_number || 'None' }}\n**Email From:** {{ $json.email_from }}\n\n**Line Items:**\n{{ $json.line_items.map(item => `- ${item.description}: ${item.quantity} \u00d7 $${item.unit_price} = $${item.total}`).join('\\n') }}\n\n**Payment Terms:** {{ $json.payment_terms }}\n\n---\n\n## FRAUD DETECTION CRITERIA\n\n### Red Flags to Check:\n1. **Duplicate Invoice Detection**\n - Similar amounts recently processed\n - Same invoice number from this vendor\n - Duplicate line item descriptions\n\n2. **Amount Anomalies**\n - Unusually high amount for vendor/category\n - Round numbers (possible fake invoices)\n - Amount just under approval threshold (splitting)\n\n3. **Vendor Verification**\n - New/unknown vendor\n - Mismatched email domain vs vendor name\n - Missing tax ID or business details\n - Suspicious bank details\n\n4. **Document Quality Issues**\n - Low confidence score from OCR\n - Missing critical information\n - Unprofessional formatting\n - Mismatched totals or calculations\n\n5. **Timing Anomalies**\n - Invoice date in future\n - Very old invoice\n - Due date already passed\n - Weekend/holiday invoice dates\n\n6. **Pattern Detection**\n - Frequent small invoices (just under approval limit)\n - Vague descriptions (\"consulting services\")\n - No PO number for large amounts\n - Rush payment requests\n\n### Category-Specific Checks:\n- **Software/SaaS:** Check if subscription-based, verify renewal dates\n- **Consulting:** Verify hourly rates are reasonable\n- **Travel:** Check dates align with known business trips\n- **Office Supplies:** Verify quantities are reasonable\n\n---\n\n## YOUR ANALYSIS TASK\n\nProvide detailed fraud risk assessment covering:\n\n1. **Overall Risk Level** - critical/high/medium/low with clear reasoning\n\n2. **Specific Red Flags Found** - List all anomalies detected\n\n3. **Vendor Trust Score** - Rate vendor legitimacy (0-100)\n\n4. **Amount Validation** - Is the amount reasonable for this category?\n\n5. **Document Quality Score** - Rate invoice professionalism (0-100)\n\n6. **Duplicate Risk** - Likelihood this is a duplicate submission\n\n7. **Recommended Action** - auto_approve / manager_review / fraud_investigation / reject\n\n8. **Required Verifications** - What should be manually verified\n\n9. **Approval Workflow** - Who should approve based on amount/risk\n\n10. **Priority Level** - urgent / high / normal / low\n\nBe thorough and err on the side of caution. Flag anything suspicious for human review.",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "d79e193d-8f8e-4f63-bc5d-87af7ebd3e42",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-16,
416
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.2
}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "b07f6e14-d650-4da4-845f-191d76249aa6",
"name": "Structured Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
176,
416
],
"parameters": {
"schemaType": "manual",
"inputSchema": "{\n \"type\": \"object\",\n \"required\": [\n \"risk_level\",\n \"risk_score\",\n \"red_flags\",\n \"vendor_trust_score\",\n \"amount_validation\",\n \"document_quality_score\",\n \"duplicate_risk\",\n \"recommended_action\",\n \"required_verifications\",\n \"approval_workflow\",\n \"priority_level\",\n \"detailed_analysis_markdown\"\n ],\n \"properties\": {\n \"risk_level\": {\n \"type\": \"string\",\n \"enum\": [\"critical\", \"high\", \"medium\", \"low\"]\n },\n \"risk_score\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"maximum\": 100,\n \"description\": \"Overall fraud risk score\"\n },\n \"red_flags\": {\n \"type\": \"array\",\n \"items\": {\"type\": \"string\"},\n \"description\": \"List of specific concerns found\"\n },\n \"vendor_trust_score\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"maximum\": 100\n },\n \"amount_validation\": {\n \"type\": \"string\",\n \"description\": \"Is amount reasonable? Details\"\n },\n \"document_quality_score\": {\n \"type\": \"integer\",\n \"minimum\": 0,\n \"maximum\": 100\n },\n \"duplicate_risk\": {\n \"type\": \"string\",\n \"enum\": [\"none\", \"low\", \"medium\", \"high\", \"confirmed\"]\n },\n \"recommended_action\": {\n \"type\": \"string\",\n \"enum\": [\"auto_approve\", \"manager_review\", \"cfo_approval\", \"fraud_investigation\", \"reject\"]\n },\n \"required_verifications\": {\n \"type\": \"array\",\n \"items\": {\"type\": \"string\"}\n },\n \"approval_workflow\": {\n \"type\": \"string\",\n \"description\": \"Who should approve\"\n },\n \"priority_level\": {\n \"type\": \"string\",\n \"enum\": [\"urgent\", \"high\", \"normal\", \"low\"]\n },\n \"detailed_analysis_markdown\": {\n \"type\": \"string\",\n \"description\": \"Full analysis in markdown\"\n }\n }\n}"
},
"typeVersion": 1.3
},
{
"id": "5f940f8a-f146-4438-b87d-e85b294095bb",
"name": "Critical Fraud Risk?",
"type": "n8n-nodes-base.if",
"position": [
400,
96
],
"parameters": {
"options": {},
"conditions": {
"options": {},
"combinator": "or",
"conditions": [
{
"id": "critical-risk",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.risk_level }}",
"rightValue": "critical"
},
{
"id": "fraud-investigation",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.recommended_action }}",
"rightValue": "fraud_investigation"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "7ca0fa2f-183d-41fb-b654-bd39481ffc99",
"name": "Auto-Approve Eligible?",
"type": "n8n-nodes-base.if",
"position": [
416,
352
],
"parameters": {
"options": {},
"conditions": {
"options": {},
"combinator": "and",
"conditions": [
{
"id": "auto-approve",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.recommended_action }}",
"rightValue": "auto_approve"
},
{
"id": "low-risk-YOUR_OPENAI_KEY_HERE-small",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.output.risk_level }}",
"rightValue": "low"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "7f4ffb88-3c0a-4ee2-90bf-f6139eeb62e2",
"name": "Request Fraud Investigation",
"type": "n8n-nodes-base.gmail",
"position": [
1296,
-16
],
"parameters": {
"sendTo": "user@example.com",
"message": "=<!DOCTYPE html>\n<html>\n<head>\n<style>\nbody{font-family:Arial,sans-serif;line-height:1.6;color:#333;max-width:700px;margin:0 auto;padding:20px}\n.alert-banner{background:#dc3545;color:#fff;padding:20px;text-align:center;border-radius:8px 8px 0 0;font-size:20px;font-weight:bold}\n.content{background:#fff;padding:30px;border:3px solid #dc3545}\n.risk-YOUR_OPENAI_KEY_HERE{display:grid;grid-template-columns:1fr 1fr 1fr;gap:15px;margin:20px 0}\n.risk-YOUR_OPENAI_KEY_HERE{background:#fff3cd;padding:15px;text-align:center;border-radius:5px;border:2px solid #ffc107}\n.risk-YOUR_OPENAI_KEY_HERE.critical{background:#f8d7da;border-color:#dc3545}\n.risk-YOUR_OPENAI_KEY_HERE strong{display:block;font-size:28px;color:#dc3545;margin-bottom:5px}\n.red-flags{background:#f8d7da;padding:15px;border-left:4px solid #dc3545;margin:20px 0}\n.invoice-details{background:#f8f9fa;padding:15px;border-radius:5px;margin:20px 0}\n</style>\n</head>\n<body>\n<div class=\"alert-banner\">\ud83d\udea8 CRITICAL FRAUD ALERT \ud83d\udea8</div>\n<div class=\"content\">\n<p><strong>A potentially fraudulent invoice has been detected and requires immediate investigation.</strong></p>\n\n<div class=\"invoice-details\">\n<h3 style=\"margin-top:0;color:#dc3545\">Invoice Information</h3>\n<p><strong>Vendor:</strong> {{ $('Parse Invoice Data').item.json.vendor_name }}<br>\n<strong>Invoice Number:</strong> {{ $('Parse Invoice Data').item.json.invoice_number }}<br>\n<strong>Amount:</strong> {{ $('Parse Invoice Data').item.json.currency }} {{ $('Parse Invoice Data').item.json.total_amount }}<br>\n<strong>Date:</strong> {{ $('Parse Invoice Data').item.json.invoice_date }}<br>\n<strong>Due Date:</strong> {{ $('Parse Invoice Data').item.json.due_date }}<br>\n<strong>Category:</strong> {{ $('Parse Invoice Data').item.json.invoice_category }}<br>\n<strong>PO Number:</strong> {{ $('Parse Invoice Data').item.json.po_number || 'None provided' }}</p>\n</div>\n\n<div class=\"risk-YOUR_OPENAI_KEY_HERE\">\n<div class=\"risk-YOUR_OPENAI_KEY_HERE critical\"><strong>{{ $json.output.risk_score }}</strong>Risk Score</div>\n<div class=\"risk-YOUR_OPENAI_KEY_HERE\"><strong>{{ $json.output.vendor_trust_score }}</strong>Vendor Trust</div>\n<div class=\"risk-YOUR_OPENAI_KEY_HERE\"><strong>{{ $json.output.document_quality_score }}</strong>Doc Quality</div>\n</div>\n\n<div class=\"red-flags\">\n<h3 style=\"margin-top:0;color:#dc3545\">\u26a0\ufe0f Red Flags Detected</h3>\n<ul style=\"margin:0;padding-left:20px\">\n{{ $json.output.red_flags.map(flag => '<li><strong>' + flag + '</strong></li>').join('') }}\n</ul>\n</div>\n\n<h3>Required Verifications:</h3>\n<ul>\n{{ $json.output.required_verifications.map(ver => '<li>' + ver + '</li>').join('') }}\n</ul>\n\n<h3>AI Recommendation:</h3>\n<p style=\"font-size:18px;color:#dc3545\"><strong>{{ $json.output.recommended_action.toUpperCase().replace('_', ' ') }}</strong></p>\n\n<p><strong>\u23f0 This invoice has been BLOCKED from payment pending your investigation.</strong></p>\n\n<p>Please review immediately and take appropriate action.</p>\n\n<p style=\"margin-top:30px;padding-top:20px;border-top:1px solid #ddd;font-size:12px;color:#666\">\n<strong>Invoice ID:</strong> {{ $('Parse Invoice Data').item.json.invoice_id }}<br>\n<strong>Detected:</strong> {{ $('Parse Invoice Data').item.json.parsed_at }}\n</p>\n</div>\n</body>\n</html>",
"options": {},
"subject": "=\u26a0\ufe0f URGENT: Suspicious Invoice Requires Investigation - {{ $('Parse Invoice Data').item.json.vendor_name }}",
"operation": "sendAndWait"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "4de0ce06-d062-4c0d-a006-3dda68257db0",
"name": "Amount > $5000?",
"type": "n8n-nodes-base.if",
"position": [
880,
192
],
"parameters": {
"options": {},
"conditions": {
"options": {},
"conditions": [
{
"id": "amount-check",
"operator": {
"type": "number",
"operation": "larger"
},
"leftValue": "={{ $('Parse Invoice Data').item.json.total_amount }}",
"rightValue": "5000"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "8b3d632f-fb06-4f4c-bbe7-00012fe7581e",
"name": "Request Manager Approval",
"type": "n8n-nodes-base.gmail",
"position": [
1312,
176
],
"parameters": {
"sendTo": "user@example.com",
"message": "=<!DOCTYPE html>\n<html>\n<head>\n<style>\nbody{font-family:Arial,sans-serif;line-height:1.6;color:#333;max-width:700px;margin:0 auto;padding:20px}\n.header{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:#fff;padding:25px;text-align:center;border-radius:8px 8px 0 0}\n.content{background:#fff;padding:30px;border:1px solid #ddd}\n.info-grid{display:grid;grid-template-columns:1fr 1fr;gap:15px;margin:20px 0}\n.info-box{background:#f8f9fa;padding:15px;border-radius:5px}\n.score-box{background:#d4edda;padding:15px;text-align:center;border-radius:5px;border:2px solid #28a745}\n.score-box strong{display:block;font-size:24px;color:#28a745}\n.line-items{background:#f8f9fa;padding:15px;border-radius:5px;margin:20px 0}\ntable{width:100%;border-collapse:collapse}\ntable th{background:#667eea;color:#fff;padding:10px;text-align:left}\ntable td{padding:10px;border-bottom:1px solid #ddd}\n</style>\n</head>\n<body>\n<div class=\"header\">\n<h2 style=\"margin:0\">\ud83d\udcc4 Invoice Approval Required</h2>\n<p style=\"margin:5px 0 0 0\">{{ $('Parse Invoice Data').item.json.vendor_name }}</p>\n</div>\n<div class=\"content\">\n<div class=\"info-grid\">\n<div class=\"info-box\">\n<strong>Invoice Number:</strong> {{ $('Parse Invoice Data').item.json.invoice_number }}<br>\n<strong>Date:</strong> {{ $('Parse Invoice Data').item.json.invoice_date }}<br>\n<strong>Due Date:</strong> {{ $('Parse Invoice Data').item.json.due_date }}\n</div>\n<div class=\"info-box\">\n<strong>Amount:</strong> {{ $('Parse Invoice Data').item.json.currency }} {{ $('Parse Invoice Data').item.json.total_amount }}<br>\n<strong>Category:</strong> {{ $('Parse Invoice Data').item.json.invoice_category }}<br>\n<strong>PO #:</strong> {{ $('Parse Invoice Data').item.json.po_number || 'N/A' }}\n</div>\n</div>\n\n<div class=\"score-box\">\n<strong>{{ $json.output.vendor_trust_score }}</strong>\nVendor Trust Score (Low Risk)\n</div>\n\n<div class=\"line-items\">\n<h3 style=\"margin-top:0\">Line Items</h3>\n<table>\n<thead>\n<tr><th>Description</th><th>Qty</th><th>Unit Price</th><th>Total</th></tr>\n</thead>\n<tbody>\n{{ $('Parse Invoice Data').item.json.line_items.map(item => '<tr><td>' + item.description + '</td><td>' + item.quantity + '</td><td>$' + item.unit_price.toFixed(2) + '</td><td>$' + item.total.toFixed(2) + '</td></tr>').join('') }}\n<tr style=\"font-weight:bold;background:#f8f9fa\"><td colspan=\"3\">Subtotal</td><td>${{ $('Parse Invoice Data').item.json.subtotal.toFixed(2) }}</td></tr>\n<tr><td colspan=\"3\">Tax ({{ $('Parse Invoice Data').item.json.tax_rate }}%)</td><td>${{ $('Parse Invoice Data').item.json.tax_amount.toFixed(2) }}</td></tr>\n<tr style=\"font-weight:bold;font-size:18px;background:#667eea;color:#fff\"><td colspan=\"3\">TOTAL</td><td>${{ $('Parse Invoice Data').item.json.total_amount.toFixed(2) }}</td></tr>\n</tbody>\n</table>\n</div>\n\n<h3>AI Analysis Summary:</h3>\n<p><strong>Risk Level:</strong> {{ $json.output.risk_level.toUpperCase() }}<br>\n<strong>Recommendation:</strong> {{ $json.output.recommended_action.replace('_', ' ').toUpperCase() }}</p>\n\n{{ $json.output.red_flags.length > 0 ? '<h3>\u26a0\ufe0f Items to Verify:</h3><ul>' + $json.output.red_flags.map(flag => '<li>' + flag + '</li>').join('') + '</ul>' : '<p>\u2705 No issues detected</p>' }}\n\n<p><strong>Payment Terms:</strong> {{ $('Parse Invoice Data').item.json.payment_terms }}</p>\n\n<p style=\"margin-top:30px\"><strong>Please approve or reject this invoice.</strong></p>\n</div>\n</body>\n</html>",
"options": {},
"subject": "=Invoice Approval Required - {{ $('Parse Invoice Data').item.json.vendor_name }} - ${{ $('Parse Invoice Data').item.json.total_amount }}",
"operation": "sendAndWait"
},
"typeVersion": 2.1
},
{
"id": "e7d4d4b9-f1a7-49c2-acb2-bf66d102fe29",
"name": "Notify Vendor - Approved",
"type": "n8n-nodes-base.gmail",
"position": [
1328,
368
],
"parameters": {
"sendTo": "={{ $('Parse Invoice Data').item.json.email_from }}",
"message": "=<!DOCTYPE html>\n<html>\n<head>\n<style>\nbody{font-family:Arial,sans-serif;line-height:1.6;color:#333;max-width:600px;margin:0 auto;padding:20px}\n.header{background:#28a745;color:#fff;padding:20px;text-align:center;border-radius:8px 8px 0 0}\n.content{background:#fff;padding:30px;border:1px solid #ddd}\n.info-box{background:#f8f9fa;padding:15px;border-radius:5px;margin:20px 0}\n</style>\n</head>\n<body>\n<div class=\"header\"><h2 style=\"margin:0\">\u2705 Invoice Approved</h2></div>\n<div class=\"content\">\n<p>Dear {{ $('Parse Invoice Data').item.json.vendor_name }},</p>\n<p>Thank you for your invoice. We've received and automatically processed it.</p>\n<div class=\"info-box\">\n<strong>Invoice Number:</strong> {{ $('Parse Invoice Data').item.json.invoice_number }}<br>\n<strong>Amount:</strong> {{ $('Parse Invoice Data').item.json.currency }} {{ $('Parse Invoice Data').item.json.total_amount }}<br>\n<strong>Due Date:</strong> {{ $('Parse Invoice Data').item.json.due_date }}<br>\n<strong>Status:</strong> Approved for Payment\n</div>\n<p>Payment will be processed according to terms: <strong>{{ $('Parse Invoice Data').item.json.payment_terms }}</strong></p>\n<p>Expected payment date: <strong>{{ $('Parse Invoice Data').item.json.due_date }}</strong></p>\n<p>If you have questions, please reply to this email.</p>\n<p>Best regards,<br><strong>Accounts Payable</strong><br>[Your Company]</p>\n</div>\n</body>\n</html>",
"options": {},
"subject": "=Invoice Received & Processing - {{ $('Parse Invoice Data').item.json.invoice_number }}"
},
"typeVersion": 2.1
},
{
"id": "33787ce5-b0ef-46f2-9687-6d88d4effb55",
"name": "Log to Invoice Database",
"type": "n8n-nodes-base.googleSheets",
"position": [
1840,
272
],
"parameters": {
"columns": {
"value": {
"amount": "={{ $('Parse Invoice Data').item.json.total_amount }}",
"status": "={{ $json.status || 'Processed' }}",
"category": "={{ $('Parse Invoice Data').item.json.invoice_category }}",
"currency": "={{ $('Parse Invoice Data').item.json.currency }}",
"due_date": "={{ $('Parse Invoice Data').item.json.due_date }}",
"po_number": "={{ $('Parse Invoice Data').item.json.po_number }}",
"red_flags": "={{ $json.output.red_flags.join('; ') }}",
"invoice_id": "={{ $('Parse Invoice Data').item.json.invoice_id }}",
"risk_level": "={{ $json.output.risk_level }}",
"risk_score": "={{ $json.output.risk_score }}",
"vendor_name": "={{ $('Parse Invoice Data').item.json.vendor_name }}",
"invoice_date": "={{ $('Parse Invoice Data').item.json.invoice_date }}",
"vendor_email": "={{ $('Parse Invoice Data').item.json.vendor_email }}",
"vendor_trust": "={{ $json.output.vendor_trust_score }}",
"duplicate_risk": "={{ $json.output.duplicate_risk }}",
"invoice_number": "={{ $('Parse Invoice Data').item.json.invoice_number }}",
"processed_date": "={{ $('Parse Invoice Data').item.json.parsed_at }}",
"recommended_action": "={{ $json.output.recommended_action }}"
},
"mappingMode": "defineBelow"
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.5
},
{
"id": "e510ac2c-183f-4f6b-bea0-1573cb6af792",
"name": "Sticky Note - Intake",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1568,
64
],
"parameters": {
"color": 5,
"width": 674,
"height": 388,
"content": "## \ud83d\udce7 Smart Invoice Intake\n\nMonitors new invoice submitted via a **Jotform**\n\nCreate your form for free on [Jotform using this link](https://www.jotform.com/?partner=mediajade)\n\n**Output:** Invoice attachments ready for AI processing"
},
"typeVersion": 1
},
{
"id": "e03f3fdf-80c2-4c87-9e05-58f499853191",
"name": "Sticky Note - OCR",
"type": "n8n-nodes-base.stickyNote",
"position": [
-800,
0
],
"parameters": {
"color": 4,
"width": 674,
"height": 444,
"content": "## \ud83e\udd16 AI-Powered OCR & Data Extraction\n\nUses GPT-4o-mini with vision to read invoices and extract ALL structured data with high accuracy.\n\n**Result:** 95%+ accuracy on invoice data extraction"
},
"typeVersion": 1
},
{
"id": "69a627b2-fc15-440b-9668-f7cead11c022",
"name": "Sticky Note - Fraud",
"type": "n8n-nodes-base.stickyNote",
"position": [
-64,
-48
],
"parameters": {
"color": 6,
"width": 756,
"height": 692,
"content": "## \ud83d\udea8 AI Fraud Detection & Risk Analysis\n\nAdvanced fraud detection AI analyzes every invoice for anomalies, duplicates, and suspicious patterns.\n\n**Result:** Catch fraud before payment, protect company assets"
},
"typeVersion": 1
},
{
"id": "8a173f21-6a0a-4428-916e-801b83eb1dda",
"name": "Sticky Note - Routing",
"type": "n8n-nodes-base.stickyNote",
"position": [
800,
-176
],
"parameters": {
"color": 3,
"width": 720,
"height": 772,
"content": "## \ud83d\udea6 Intelligent Routing & Approval Workflows\n\nAutomatically routes invoices based on risk level, amount, and fraud analysis.\n\n**Result:** Fast processing for legitimate invoices, rigorous checks for suspicious ones"
},
"typeVersion": 1
},
{
"id": "30f7ee03-153b-4ab6-86ce-f01e014e42d1",
"name": "Sticky Note - Analytics",
"type": "n8n-nodes-base.stickyNote",
"position": [
1632,
96
],
"parameters": {
"color": 7,
"width": 480,
"height": 364,
"content": "## \ud83d\udcca Financial Analytics & Audit Trail\n\nComprehensive logging of all invoices for analytics, compliance, and audit purposes.\n\n**Result:** Data-driven financial operations with full transparency"
},
"typeVersion": 1
},
{
"id": "399c8b7f-a346-4cab-a49f-337b8b1605f4",
"name": "Send a message",
"type": "n8n-nodes-base.slack",
"position": [
992,
0
],
"parameters": {
"text": "=:rotating_light: *CRITICAL FRAUD ALERT* :rotating_light:\\n\\n*Invoice Details:*\\nVendor: {{ $('Parse Invoice Data').item.json.vendor_name }}\\nAmount: {{ $('Parse Invoice Data').item.json.currency }} {{ $('Parse Invoice Data').item.json.total_amount }}\\nInvoice #: {{ $('Parse Invoice Data').item.json.invoice_number }}\\n\\n*Risk Assessment:*\\nRisk Level: {{ $json.output.risk_level.toUpperCase() }}\\nRisk Score: {{ $json.output.risk_score }}/100\\nVendor Trust: {{ $json.output.vendor_trust_score }}/100\\n\\n*Red Flags:*\\n{{ $json.output.red_flags.map(flag => '\u2022 ' + flag).join('\\\\n') }}\\n\\n*Recommended Action:* {{ $json.output.recommended_action.toUpperCase().replace('_', ' ') }}\\n\\n:warning: *IMMEDIATE ACTION REQUIRED* - Do NOT process this invoice until investigated!",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "list",
"value": ""
},
"otherOptions": {}
},
"typeVersion": 2.3
},
{
"id": "87e7a15b-abbc-4fbc-b1ba-fe987c2740c8",
"name": "Update an invoice",
"type": "n8n-nodes-base.quickbooks",
"position": [
1104,
368
],
"parameters": {
"resource": "invoice",
"operation": "update",
"updateFields": {}
},
"typeVersion": 1
},
{
"id": "8faf07af-b384-43d9-910e-ad4991bddd87",
"name": "Jotform Trigger",
"type": "n8n-nodes-base.jotFormTrigger",
"position": [
-1488,
256
],
"parameters": {
"form": "252815253377461"
},
"credentials": {
"jotFormApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "c30da11e-1045-407f-973a-f68a6ee2b72d",
"connections": {
"Send a message": {
"main": [
[
{
"node": "Request Fraud Investigation",
"type": "main",
"index": 0
}
]
]
},
"Amount > $5000?": {
"main": [
[
{
"node": "Request Manager Approval",
"type": "main",
"index": 0
}
],
[
{
"node": "Update an invoice",
"type": "main",
"index": 0
}
]
]
},
"Jotform Trigger": {
"main": [
[
{
"node": "Has Invoice Attachment?",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Fraud Detection Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Update an invoice": {
"main": [
[
{
"node": "Notify Vendor - Approved",
"type": "main",
"index": 0
}
]
]
},
"Parse Invoice Data": {
"main": [
[
{
"node": "AI Fraud Detection Agent",
"type": "main",
"index": 0
}
]
]
},
"Critical Fraud Risk?": {
"main": [
[
{
"node": "Send a message",
"type": "main",
"index": 0
}
],
[
{
"node": "Amount > $5000?",
"type": "main",
"index": 0
}
]
]
},
"Auto-Approve Eligible?": {
"main": [
[
{
"node": "Update an invoice",
"type": "main",
"index": 0
}
],
[
{
"node": "Amount > $5000?",
"type": "main",
"index": 0
}
]
]
},
"Has Invoice Attachment?": {
"main": [
[
{
"node": "Extract Invoice Attachments",
"type": "main",
"index": 0
}
]
]
},
"AI Fraud Detection Agent": {
"main": [
[
{
"node": "Critical Fraud Risk?",
"type": "main",
"index": 0
},
{
"node": "Auto-Approve Eligible?",
"type": "main",
"index": 0
}
]
]
},
"Notify Vendor - Approved": {
"main": [
[
{
"node": "Log to Invoice Database",
"type": "main",
"index": 0
}
]
]
},
"Request Manager Approval": {
"main": [
[
{
"node": "Log to Invoice Database",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Fraud Detection Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"AI Invoice OCR & Extraction": {
"main": [
[
{
"node": "Parse Invoice Data",
"type": "main",
"index": 0
}
]
]
},
"Extract Invoice Attachments": {
"main": [
[
{
"node": "AI Invoice OCR & Extraction",
"type": "main",
"index": 0
}
]
]
},
"Request Fraud Investigation": {
"main": [
[
{
"node": "Log to Invoice Database",
"type": "main",
"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.
gmailOAuth2jotFormApiopenAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Transform accounts payable from a manual bottleneck into an intelligent, automated system that reads invoices, detects fraud, and processes payments automatically—saving 20+ hours per week while preventing costly fraudulent payments.
Source: https://n8n.io/workflows/9436/ — 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 invoice processing directly from your email inbox.
This n8n workflow is designed for e-commerce businesses, digital marketers, and content creators who want to automatically generate professional 3D product videos from product images. It's perfect for
Send a message or a voice note on Telegram right after the meeting. n8n transcribes (if it's a voice note) and sends the text to GPT. GPT generates a structured and professional meeting minutes report
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
Gmail users report spending significant time manually sorting email, so this tool helps alleviate that burden. Gmail Trigger monitors unread emails every 2 minutes Once an email arrives, the content i