{
  "id": "jshpcczcRyM828wo",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "N-0135 Maverick Spend Detection",
  "tags": [],
  "nodes": [
    {
      "id": "0ff4ad5e-8755-4e7c-b93d-3efae75115c5",
      "name": "Mark Transaction as Processed",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1056,
        1232
      ],
      "parameters": {
        "columns": {
          "value": {
            "processed": "=Yes",
            "transaction_id": "={{ $json.transaction_id }}"
          },
          "schema": [
            {
              "id": "transaction_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "transaction_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "supplier_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "supplier_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "amount",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "department",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "department",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "processed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "processed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "transaction_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 701382615,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
          "cachedResultName": "Get Transactions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
          "cachedResultName": "Maverick"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "01fb5eb5-6901-41ad-a470-26effb0cf912",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1728,
        496
      ],
      "parameters": {
        "width": 720,
        "height": 464,
        "content": "## Maverick Spend Detection Workflow\n## How it works:\n\nThis workflow automatically runs every day to monitor procurement transactions and ensure compliance. It compares each transaction against an approved supplier list to detect unauthorized (maverick) spending. When a violation is found, AI generates corrective recommendations, alerts are sent via Slack and Email, and the incident is logged for tracking. If no action is taken within 2 hours, the workflow escalates the issue to management.\n\n## Setup steps:\nConnect Google Sheets and configure supplier and transaction data sources\nEnsure supplier names are standardized (lowercase, trimmed) for accurate matching\nSet up and authenticate Slack integration for real-time alerts\nConfigure Gmail credentials for detailed email notifications\nVerify all required fields (transaction_id, supplier_name, amount, etc.) exist\nAdjust the schedule trigger time based on business requirements\nTest the workflow with sample data before enabling automation\nActivate the workflow for daily automated execution"
      },
      "typeVersion": 1
    },
    {
      "id": "fdf1fa67-0f63-4571-9fb3-27c774c13351",
      "name": "Daily Compliance Scan",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1616,
        1536
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 11
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "92af11a6-8cab-4281-a244-34dc8a265e92",
      "name": "Get Approved Supplier List",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1296,
        1440
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=0",
          "cachedResultName": "Get Approved Suppliers"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
          "cachedResultName": "Maverick"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6d641df9-b075-48c8-9dfb-608d3959e21e",
      "name": "Get Pending Transactions",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1072,
        1632
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 701382615,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
          "cachedResultName": "Get Transactions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
          "cachedResultName": "Maverick"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "97b41664-17e2-4589-a274-2c1e780180bc",
      "name": "Clean & Normalize Transaction Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -1072,
        1440
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "8e0234e4-2656-4961-b0f2-b1ed31c52da3",
              "name": "supplier_name",
              "type": "string",
              "value": "={{ $json.supplier_name ? $json.supplier_name.toLowerCase().trim() : '' }}"
            },
            {
              "id": "7bb29a7f-d976-41d2-8dfa-90d00a9b3c21",
              "name": "amount",
              "type": "string",
              "value": "={{ $json.amount }}"
            },
            {
              "id": "799bb90a-adae-4511-a566-65d350a89d1e",
              "name": "department",
              "type": "string",
              "value": "={{ $json.department }}"
            },
            {
              "id": "a98eeb55-0c62-49c6-84ee-3dfb5615104c",
              "name": "transaction_id",
              "type": "string",
              "value": "={{ $json.transaction_id }}"
            },
            {
              "id": "c11de234-9012-4abc-b234-ef5678901234",
              "name": "processed",
              "type": "string",
              "value": "={{ $json.processed }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8090644a-3e5c-43cb-84d1-595b0170580f",
      "name": "Merge Supplier & Transaction Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        -848,
        1536
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "9d3ba805-d959-44e0-8397-72e19d59bfd2",
      "name": "Detect Maverick Spend (Unapproved Supplier)",
      "type": "n8n-nodes-base.code",
      "position": [
        -624,
        1536
      ],
      "parameters": {
        "jsCode": "// Get all incoming data\nconst allItems = $input.all();\n\n// Separate suppliers & transactions safely\nconst approvedItems = allItems.filter(i => i.json.contract_status);\nconst transactionItems = allItems.filter(i => i.json.transaction_id);\n\n// Create approved supplier set\nconst approvedSet = new Set(\n  approvedItems.map(i =>\n    String(i.json.supplier_name || '').toLowerCase().trim()\n  )\n);\n\n// Process transactions\nreturn transactionItems.map(tx => {\n  const supplier = String(tx.json.supplier_name || '').toLowerCase().trim();\n\n  return {\n    json: {\n      transaction_id: tx.json.transaction_id || '',\n      supplier_name: tx.json.supplier_name || '',\n      amount: tx.json.amount || '',\n      department: tx.json.department || '',\n      processed: tx.json.processed || '',\n      is_maverick: !approvedSet.has(supplier),\n      approved_suppliers_list: [...approvedSet].join(', ')\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "4ed47ec8-2867-433c-8f5c-9b97cf2e06b8",
      "name": "Check Maverick Spend Condition",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        1536
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8190c846-3edd-4bd6-8038-2bd97745cf54",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.is_maverick }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "4a1e6645-035d-49a5-8281-5971578dfdf2",
      "name": "Generate AI Compliance Suggestions",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -176,
        1232
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a procurement compliance expert.\n\nA purchase was made from an UNAPPROVED supplier:\n\n- Supplier: {{ $json.supplier_name }}\n- Department: {{ $json.department }}\n- Amount: \u20b9{{ $json.amount }}\n- Transaction ID: {{ $json.transaction_id }}\n\nApproved suppliers list:\n{{ $json.approved_suppliers_list }}\n\nInstructions:\n- If approved suppliers are available, suggest 2\u20133 relevant suppliers from the list.\n- If no suitable approved supplier is available, clearly say \"No approved supplier available\" and suggest initiating supplier onboarding.\n\nProvide output in EXACT format:\n\n1. Recommended Suppliers:\n- Supplier 1\n- Supplier 2\n- Supplier 3\n\n2. Corrective Action:\n<one clear action>\n\n3. Policy Reminder:\n<one short line>\n\nKeep response short, structured, and professional. Do NOT add extra explanation."
            }
          ]
        },
        "builtInTools": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.1
    },
    {
      "id": "888ab427-20df-491a-962b-241ab28005a0",
      "name": "Skip Approved Supplier (No Action)",
      "type": "n8n-nodes-base.set",
      "position": [
        -112,
        1632
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "skip-01",
              "name": "transaction_id",
              "type": "string",
              "value": "={{ $json.transaction_id }}"
            },
            {
              "id": "skip-02",
              "name": "supplier_name",
              "type": "string",
              "value": "={{ $json.supplier_name }}"
            },
            {
              "id": "skip-03",
              "name": "processed",
              "type": "string",
              "value": "=Yes"
            },
            {
              "id": "skip-04",
              "name": "skip_reason",
              "type": "string",
              "value": "=Supplier is approved - no action needed"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "59d7ed11-da8c-4ecb-8b76-c61a4c39ad9d",
      "name": "Mark Approved Transaction as Processed",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        176,
        1632
      ],
      "parameters": {
        "columns": {
          "value": {
            "processed": "=Yes"
          },
          "schema": [
            {
              "id": "transaction_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "transaction_id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "processed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "processed",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "transaction_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 701382615,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=701382615",
          "cachedResultName": "Get Transactions"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
          "cachedResultName": "Maverick"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "0b4b5b27-cf10-4018-b601-b9bf42eb6773",
      "name": "Format AI Output & Add Timestamp",
      "type": "n8n-nodes-base.code",
      "position": [
        192,
        1232
      ],
      "parameters": {
        "jsCode": "// Get the current item\nconst original = $input.item.json;\n\n// Extract AI text \u2014 handle all possible output shapes from the Gemini n8n node\nlet aiText = 'No AI suggestions available.';\n\n// Shape 1: n8n Gemini node wraps response in a 'text' field directly\nif (original.text && typeof original.text === 'string' && original.text.trim()) {\n  aiText = original.text.trim();\n}\n// Shape 2: some versions use 'output'\nelse if (original.output && typeof original.output === 'string' && original.output.trim()) {\n  aiText = original.output.trim();\n}\n// Shape 3: raw Gemini REST-style candidates array (unlikely via n8n node but kept as safety net)\nelse if (original.candidates && original.candidates[0]?.content?.parts) {\n  aiText = original.candidates[0].content.parts\n    .map(p => p.text || '')\n    .join(' ')\n    .trim();\n}\n\n// Normalise whitespace\naiText = aiText.replace(/\\n{3,}/g, '\\n\\n').trim();\n\nconst now = new Date();\n\nreturn [\n  {\n    json: {\n      transaction_id:    original.transaction_id,\n      supplier_name:     original.supplier_name,\n      amount:            original.amount,\n      department:        original.department,\n      is_maverick:       original.is_maverick,\n      ai_suggestions:    aiText,\n      timestamp:         now.toISOString(),\n      timestamp_readable: now.toLocaleString('en-IN', {\n        timeZone:   'Asia/Kolkata',\n        dateStyle:  'medium',\n        timeStyle:  'short'\n      })\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "1b4556f3-3271-4173-8637-a009fd37f5f2",
      "name": "Send Slack Alert (Maverick Spend)",
      "type": "n8n-nodes-base.slack",
      "position": [
        432,
        1232
      ],
      "parameters": {
        "text": "=*Maverick Spend Detected!*\n\n*Transaction ID:* `{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.transaction_id }}`\n*Unauthorized Supplier:*{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }}\n*Amount:* \u20b9{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }}\n*Department:* {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}\n*Detected At:* {{ $json.timestamp_readable }} IST\n\n *AI Suggestions:*\n```{{ $json.ai_suggestions }}```\n\n Please review this transaction within 2 hours or it will be escalated.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0AP6S28KM3",
          "cachedResultName": "all-aishvarya"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "8f6a3c6b-c72c-450e-b58e-82735110c527",
      "name": "Send Email Alert (Violation Report)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        656,
        1232
      ],
      "parameters": {
        "message": "=<!DOCTYPE html>\n<html>\n<body style=\"font-family: Arial, sans-serif; max-width: 680px; margin: auto; padding: 20px; color: #333;\">\n\n  <div style=\"background: #c0392b; color: white; padding: 18px 24px; border-radius: 8px 8px 0 0;\">\n    <h2 style=\"margin: 0;\"> Maverick Spend Violation Detected</h2>\n    <p style=\"margin: 6px 0 0; font-size: 13px; opacity: 0.9;\">Automated alert from Procurement Compliance System</p>\n  </div>\n\n  <div style=\"border: 1px solid #ddd; border-top: none; border-radius: 0 0 8px 8px; padding: 24px;\">\n\n    <h3 style=\"color: #c0392b; margin-top: 0;\">Transaction Details</h3>\n    <table style=\"width: 100%; border-collapse: collapse; margin-bottom: 20px;\">\n      <tr style=\"background: #f8f8f8;\">\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold; width: 40%;\">Transaction ID</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-family: monospace;\">{{ $('Check Maverick Spend Condition').item.json.transaction_id }}</td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Unauthorized Supplier</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd; color: #c0392b; font-weight: bold;\">{{ $('Check Maverick Spend Condition').item.json.supplier_name }}</td>\n      </tr>\n      <tr style=\"background: #f8f8f8;\">\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Amount</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-size: 18px; font-weight: bold;\">\u20b9{{ $('Check Maverick Spend Condition').item.json.amount }}</td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Department</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd;\">{{ $('Check Maverick Spend Condition').item.json.department }}</td>\n      </tr>\n      <tr style=\"background: #f8f8f8;\">\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Status</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd;\">\n          <span style=\"background: #e67e22; color: white; padding: 4px 12px; border-radius: 4px; font-size: 13px;\">Pending Review</span>\n        </td>\n      </tr>\n      <tr>\n        <td style=\"padding: 10px; border: 1px solid #ddd; font-weight: bold;\">Detected At</td>\n        <td style=\"padding: 10px; border: 1px solid #ddd;\">{{ $('Format AI Output & Add Timestamp').item.json.timestamp_readable }} IST</td>\n      </tr>\n    </table>\n\n    <h3 style=\"color: #2980b9;\"> AI-Recommended Compliant Suppliers</h3>\n    <div style=\"background: #eaf4fb; border-left: 4px solid #2980b9; padding: 16px; border-radius: 4px; white-space: pre-line; font-size: 14px; line-height: 1.7;\">\n{{ $('Format AI Output & Add Timestamp').item.json.ai_suggestions }}\n    </div>\n\n    <div style=\"background: #fef9e7; border: 1px solid #f1c40f; border-radius: 6px; padding: 16px; margin-top: 20px;\">\n      <p style=\"margin: 0; font-size: 13px;\"> <strong>Action Required:</strong> Please review this transaction within <strong>2 hours</strong>. If no action is taken, this alert will be automatically escalated to senior management.</p>\n    </div>\n\n    <p style=\"color: #999; font-size: 12px; margin-top: 24px;\">This is an automated message from your n8n Procurement Compliance Workflow.</p>\n  </div>\n\n</body>\n</html>",
        "options": {},
        "subject": "=Maverick Spend Alert - {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }} | \u20b9{{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }} | {{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e03ea9c2-afda-4efe-8f01-d8f8f0d12480",
      "name": "Log Violation in Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        864,
        1232
      ],
      "parameters": {
        "columns": {
          "value": {
            "amount": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.amount }}",
            "status": "=Pending Review",
            "timestamp": "={{ $('Format AI Output & Add Timestamp').item.json.timestamp_readable }}",
            "department": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.department }}",
            "supplier_name": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.supplier_name }}",
            "ai_suggestions": "={{ $('Format AI Output & Add Timestamp').item.json.ai_suggestions }}",
            "transaction_id": "={{ $('Detect Maverick Spend (Unapproved Supplier)').item.json.transaction_id }}"
          },
          "schema": [
            {
              "id": "violation_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "violation_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "transaction_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "transaction_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "supplier_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "supplier_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "department",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "department",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ai_suggestions",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ai_suggestions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "escalation_status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "escalation_status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1873248992,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit#gid=1873248992",
          "cachedResultName": "Violation log "
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1dbzPFJsrq3N7UjQBKeIfAjI0FqAxtuxXLbi-eHE2Nlk/edit?usp=drivesdk",
          "cachedResultName": "Maverick"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f6ad4596-bead-4c0b-ac29-004f2fe61e3e",
      "name": "Wait 2 Hours Before Escalation",
      "type": "n8n-nodes-base.wait",
      "position": [
        1280,
        1232
      ],
      "parameters": {
        "unit": "hours",
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "ad1506bd-c533-4f8f-bd03-3715622bc19f",
      "name": "Send Escalation Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        1520,
        1232
      ],
      "parameters": {
        "text": "= *ESCALATION ALERT - Unapproved Transaction Not Reviewed*\n\nThe following maverick spend transaction has been pending for *over 2 hours* with no action taken.\n\n*Transaction ID:* `{{ $json.transaction_id }}`\n*Unauthorized Supplier:* {{ $json.supplier_name }}\n*Amount:* \u20b9{{ $json.amount }}\n*Department:* {{ $json.department }}\n*Originally Detected:* {{ $json.timestamp_readable }} IST\n\n *Suggested Compliant Alternatives:*\n```{{ $json.ai_suggestions }}```\n\n@channel - Immediate action required by senior procurement management.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C0AP6S28KM3",
          "cachedResultName": "all-aishvarya"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.4
    },
    {
      "id": "2bbca330-bb99-435f-a12e-bc7f058de6e3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        1264
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 576,
        "content": "## Data Ingestion & Preparation\n\nFetches supplier and transaction data from Google Sheets, standardizes formats, and merges datasets into a unified stream for accurate comparison and processing."
      },
      "typeVersion": 1
    },
    {
      "id": "0810cdd6-70b1-4379-94a6-71e9faa76cf6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        1440
      ],
      "parameters": {
        "color": 7,
        "width": 1056,
        "height": 384,
        "content": "## Maverick Spend Detection & Decision\n\nChecks if transactions involve unapproved suppliers and routes workflow accordingly, either skipping approved entries or forwarding violations for further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "17e2c3b8-897d-4adf-8be5-845d9835905b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        1088
      ],
      "parameters": {
        "color": 7,
        "width": 1952,
        "height": 336,
        "content": "## Violation Handling, Alerts & Escalation\n\nProcesses violations using AI suggestions, sends Slack and email alerts, logs records, marks transactions processed, and escalates unresolved cases after a defined waiting period."
      },
      "typeVersion": 1
    },
    {
      "id": "68373227-5dd8-4cda-a8a7-5796b0360243",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        1408
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 304,
        "content": "## Scheduler\nruns automatically every day at 11 :00 AM"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "7f08dafa-9215-4e6f-bbd9-5e987e3660c8",
  "connections": {
    "Daily Compliance Scan": {
      "main": [
        [
          {
            "node": "Get Approved Supplier List",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Pending Transactions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Violation in Sheet": {
      "main": [
        [
          {
            "node": "Mark Transaction as Processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Pending Transactions": {
      "main": [
        [
          {
            "node": "Merge Supplier & Transaction Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get Approved Supplier List": {
      "main": [
        [
          {
            "node": "Clean & Normalize Transaction Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Transaction as Processed": {
      "main": [
        [
          {
            "node": "Wait 2 Hours Before Escalation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Maverick Spend Condition": {
      "main": [
        [
          {
            "node": "Generate AI Compliance Suggestions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Skip Approved Supplier (No Action)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 Hours Before Escalation": {
      "main": [
        [
          {
            "node": "Send Escalation Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Output & Add Timestamp": {
      "main": [
        [
          {
            "node": "Send Slack Alert (Maverick Spend)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Supplier & Transaction Data": {
      "main": [
        [
          {
            "node": "Detect Maverick Spend (Unapproved Supplier)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Slack Alert (Maverick Spend)": {
      "main": [
        [
          {
            "node": "Send Email Alert (Violation Report)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Normalize Transaction Data": {
      "main": [
        [
          {
            "node": "Merge Supplier & Transaction Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI Compliance Suggestions": {
      "main": [
        [
          {
            "node": "Format AI Output & Add Timestamp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip Approved Supplier (No Action)": {
      "main": [
        [
          {
            "node": "Mark Approved Transaction as Processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Alert (Violation Report)": {
      "main": [
        [
          {
            "node": "Log Violation in Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect Maverick Spend (Unapproved Supplier)": {
      "main": [
        [
          {
            "node": "Check Maverick Spend Condition",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}