{
  "name": "Qualify mortgage leads and collect documents with Gemini, Gmail, Drive, Telegram, and Supabase",
  "nodes": [
    {
      "id": "6a71b550-8237-4761-aa17-bf3633012aa8",
      "name": "Generate Personalized Email",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        320,
        -640
      ]
    },
    {
      "id": "bea5b817-6759-44dd-af3d-09721b7b1b5a",
      "name": "Create Gmail Draft",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        -640
      ]
    },
    {
      "id": "37d4f043-78a6-4615-abfe-02c4946660f2",
      "name": "Aggregate Log Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        -640
      ]
    },
    {
      "id": "8573b74a-e099-4d26-a557-ae769a797710",
      "name": "Create Drive Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        672,
        -640
      ]
    },
    {
      "id": "00bca220-c70d-4ef0-8c64-84b5bedeca80",
      "name": "Share Drive Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        896,
        -640
      ]
    },
    {
      "id": "68481bfe-c542-4417-9fcf-368b0b0d5bcb",
      "name": "Store in Database",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1792,
        -640
      ]
    },
    {
      "id": "773a1dd9-0cd8-439f-af0c-e47bb0f4bc95",
      "name": "Validate Input",
      "type": "n8n-nodes-base.if",
      "position": [
        -608,
        192
      ]
    },
    {
      "id": "287b67ee-910c-434c-ac65-fae098b55318",
      "name": "Send Success Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        736,
        96
      ]
    },
    {
      "id": "f0e07519-5def-4db1-a9df-123c01435aee",
      "name": "Send Partial Failure Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        736,
        288
      ]
    },
    {
      "id": "545688ea-8362-4ac0-95b4-1b2829012792",
      "name": "Send Validation Error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -384,
        288
      ]
    },
    {
      "id": "1efd1ad3-21d6-455e-9a23-7af5943c12b2",
      "name": "Upload ID1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -384,
        96
      ]
    },
    {
      "id": "80ef637a-2997-4084-8acc-58531f4836c0",
      "name": "Upload Payslip1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -160,
        96
      ]
    },
    {
      "id": "dddb0d6e-0641-462b-89a5-22b672b3b5af",
      "name": "Upload Bank Statement1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        64,
        96
      ]
    },
    {
      "id": "15775092-8702-4a1c-8ee4-3f4022f3ebed",
      "name": "Send Email Created Confirmation",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1344,
        -640
      ]
    },
    {
      "id": "fbcff950-a080-4366-b781-954deedc9915",
      "name": "Request Email Approval1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -128,
        -544
      ]
    },
    {
      "id": "5d9a6fd3-5fa9-4c05-aa98-acbea93ad832",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -800,
        -544
      ]
    },
    {
      "id": "473bacef-d6d5-41f6-ab86-6d2a755de5ad",
      "name": "Check income threshold",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        -544
      ]
    },
    {
      "id": "52793993-e72c-4926-8b69-a4437f35355b",
      "name": "Check approval response",
      "type": "n8n-nodes-base.if",
      "position": [
        96,
        -544
      ]
    },
    {
      "id": "746733a1-676c-4b04-9b5a-5b9e2d496a88",
      "name": "Check all uploads successful",
      "type": "n8n-nodes-base.if",
      "position": [
        512,
        192
      ]
    },
    {
      "id": "ba73f9f0-970c-41c4-8806-c9438b489089",
      "name": "Normalize lead name",
      "type": "n8n-nodes-base.code",
      "position": [
        -576,
        -544
      ]
    },
    {
      "id": "3799e719-fae7-47e7-9998-012dd70d0114",
      "name": "Evaluate upload results",
      "type": "n8n-nodes-base.code",
      "position": [
        288,
        96
      ]
    },
    {
      "id": "6f89d4a0-33d7-468a-8520-d4c5858ec503",
      "name": "Log declined lead",
      "type": "n8n-nodes-base.supabase",
      "position": [
        384,
        -448
      ]
    },
    {
      "id": "7b7e5098-2931-4403-8ce4-6f43336cb220",
      "name": "Update upload error log",
      "type": "n8n-nodes-base.supabase",
      "position": [
        512,
        0
      ]
    },
    {
      "id": "368ba308-d5ae-4cb1-a315-beb9115cd6b2",
      "name": "Upload portal trigger",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -832,
        192
      ]
    },
    {
      "id": "2dace547-f410-4302-b297-e4a97da90ca8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -688
      ],
      "parameters": {
        "width": 672,
        "height": 672,
        "content": "## Mortgage Lead Automation with AI and Human Approval\n\nThis workflow automates mortgage lead handling while keeping you in control.\n\nNew leads are captured and normalized. High income leads are sent "
      }
    },
    {
      "id": "65fe3dc5-87d2-4692-9868-bf03951b5343",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -736
      ],
      "parameters": {
        "width": 624,
        "height": 400,
        "content": "Captures new mortgage inquiries and cleans name data.\nApplies income threshold before continuing.\nPrevents low quality leads from triggering AI and admin steps."
      }
    },
    {
      "id": "9d13f6ac-973f-444a-b7b7-584151496c93",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -736
      ],
      "parameters": {
        "width": 448,
        "height": 400,
        "content": "Sends high value leads to Telegram for review.\nBroker must approve before AI email drafting.\nDeclined leads are logged in Supabase."
      }
    },
    {
      "id": "5945c161-51ef-43d4-b353-9874ed9c2ee4",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -736
      ],
      "parameters": {
        "width": 976,
        "height": 448,
        "content": "Generates personalized mortgage email using Gemini.\nCreates client specific Drive folder.\nPrepares Gmail draft with secure upload link."
      }
    },
    {
      "id": "c618560b-ffeb-45eb-8696-c37c985c0786",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -16
      ],
      "parameters": {
        "width": 656,
        "height": 576,
        "content": "Client uploads required documents through secure form.\nHidden fields link uploads to correct Drive folder.\nInput validation ensures required data is present."
      }
    },
    {
      "id": "5dbbeca7-b331-4a06-b155-2c3f16e6757f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -16
      ],
      "parameters": {
        "width": 608,
        "height": 320,
        "content": "Uploads ID, payslip, and bank statement to Drive.\nHandles partial failures without breaking workflow.\nEvaluates overall upload status."
      }
    },
    {
      "id": "f49871a9-702e-4707-9c71-ec3c0a66b133",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -96
      ],
      "parameters": {
        "width": 512,
        "height": 608,
        "content": "Sends Telegram notifications for success or failure.\nAggregates errors and activity data.\nStores structured results in Supabase."
      }
    }
  ],
  "connections": {
    "Upload ID1": {
      "main": [
        [
          {
            "node": "Upload Payslip1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Input": {
      "main": [
        [
          {
            "node": "Upload ID1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Validation Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Payslip1": {
      "main": [
        [
          {
            "node": "Upload Bank Statement1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log declined lead": {
      "main": [
        []
      ]
    },
    "Store in Database": {
      "main": [
        []
      ]
    },
    "Aggregate Log Data": {
      "main": [
        [
          {
            "node": "Store in Database",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Gmail Draft": {
      "main": [
        [
          {
            "node": "Send Email Created Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Normalize lead name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Share Drive Folder": {
      "main": [
        [
          {
            "node": "Create Gmail Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Drive Folder": {
      "main": [
        [
          {
            "node": "Share Drive Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize lead name": {
      "main": [
        [
          {
            "node": "Check income threshold",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload portal trigger": {
      "main": [
        [
          {
            "node": "Validate Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check income threshold": {
      "main": [
        [
          {
            "node": "Request Email Approval1",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Upload Bank Statement1": {
      "main": [
        [
          {
            "node": "Evaluate upload results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check approval response": {
      "main": [
        [
          {
            "node": "Generate Personalized Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log declined lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Evaluate upload results": {
      "main": [
        [
          {
            "node": "Check all uploads successful",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update upload error log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request Email Approval1": {
      "main": [
        [
          {
            "node": "Check approval response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update upload error log": {
      "main": [
        []
      ]
    },
    "Generate Personalized Email": {
      "main": [
        [
          {
            "node": "Create Drive Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check all uploads successful": {
      "main": [
        [
          {
            "node": "Send Success Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Partial Failure Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Created Confirmation": {
      "main": [
        [
          {
            "node": "Aggregate Log Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}