{
  "id": "fWe6VFLH0SzN05oF",
  "name": "Real Estate Lead Capture",
  "tags": [],
  "nodes": [
    {
      "id": "5f70bb58-217b-4f52-ac69-0de83f31d626",
      "name": "Gets Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1936,
        96
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "sender": ""
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "ccd78a2f-d4ff-41e4-b856-403d58ec5d4d",
      "name": "Convert Email to Text File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -1456,
        96
      ],
      "parameters": {
        "options": {},
        "operation": "toText",
        "sourceProperty": "text"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ba425c00-9d5a-413d-ae70-f8e1f208a116",
      "name": "Extract Lead Data (Parseur)",
      "type": "n8n-nodes-parseur.parseur",
      "position": [
        -1280,
        96
      ],
      "parameters": {
        "parserId": 202917
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "db55358b-dee1-42c8-8473-09fc293b514f",
      "name": "Wait for Parsing (10s)",
      "type": "n8n-nodes-base.wait",
      "position": [
        -1072,
        96
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "b6723aad-35ee-4d9e-a3cc-b3e624de376e",
      "name": "Fetch Parsed Document from Parseur",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -848,
        96
      ],
      "parameters": {
        "url": "=https://api.parseur.com/document/{{$json[\"response\"][\"attachments\"][0][\"DocumentID\"]}}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.4
    },
    {
      "id": "01a4bc3a-1ab6-4f6e-b373-5eb233a15449",
      "name": "Parse JSON Result",
      "type": "n8n-nodes-base.set",
      "position": [
        -592,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "303d8f70-4e16-4f8b-bab9-79bd1a9b3ad0",
              "name": "parsedResult",
              "type": "object",
              "value": "={{ JSON.parse($json[\"result\"]) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6ef31aa8-b02a-4b11-9a88-40a302747c9b",
      "name": "Check if Lead Already Exists1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -416,
        96
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{$json[\"parsedResult\"][\"Email\"]}}",
              "lookupColumn": "Email"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY/edit?usp=drivesdk",
          "cachedResultName": "Real Estate Leads Tracker"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "61992145-2765-44d8-a669-5da2194860da",
      "name": "Lead Exists? (Duplicate Check)",
      "type": "n8n-nodes-base.if",
      "position": [
        -208,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "01028436-dcde-49b7-91de-1c2748551e91",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{$json[\"row_number\"]}}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "7881fa47-5437-4e81-a4d8-44550933398d",
      "name": "Skip \u2013 Duplicate Lead",
      "type": "n8n-nodes-base.noOp",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ff5684eb-5b8c-4304-9ba2-aade45be3361",
      "name": "Add New Lead to Tracker",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -16,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{$json[\"parsedResult\"][\"Name\"]}}",
            "Email": "={{$json[\"parsedResult\"][\"Email\"]}}",
            "Phone": "={{ $json.parsedResult.Phone }}",
            "Source": "={{ $json.parsedResult.Source }}",
            "Listing ID": "={{ $json.parsedResult['Listing ID'] }}",
            "Budget Range": "={{ $json.parsedResult['Budget Range'] }}",
            "Agent Assigned": "={{ $json.parsedResult['Agent Assigned'] }}",
            "Move-in Timeline": "={{ $json.parsedResult['Move-in Timeline'] }}",
            "Property Address": "={{ $json.parsedResult['Property Address'] }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property Address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Property Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Listing ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Listing ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Budget Range",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Budget Range",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Move-in Timeline",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Move-in Timeline",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Source",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Source",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Assigned",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Assigned",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "RAW"
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY/edit?usp=drivesdk",
          "cachedResultName": "Real Estate Leads Tracker"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "30dcb989-a21e-425e-b39c-7ab5d3e92a4c",
      "name": "Filters Zillow Realtor trulia and facebookmai emails",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1728,
        96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "099ea0ef-abdb-4247-8b5b-6005f525d65b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{$json[\"from\"][\"text\"]}}",
              "rightValue": "zillow.com"
            },
            {
              "id": "3ef45627-1b06-4402-92af-d2b428e63336",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{$json[\"from\"][\"text\"]}}",
              "rightValue": "realtor.com"
            },
            {
              "id": "e3a9f276-4987-4dd1-92ac-995ace1e05fa",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{$json[\"from\"][\"text\"]}}",
              "rightValue": "trulia.com"
            },
            {
              "id": "d0b8f7b8-5086-46f0-aee4-a73334cfcd2e",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{$json[\"from\"][\"text\"]}}",
              "rightValue": "facebookmail.com"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "523b35c6-3392-4ea1-87c7-213bac0aaa6a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2592,
        -128
      ],
      "parameters": {
        "width": 528,
        "height": 704,
        "content": "## Automated Real Estate Lead Intake & Tracker Pipeline\n\n### How It Works\n* **Gmail Trigger:** Polls Gmail every minute for incoming email messages.\n* **Domain Filtering:** Passes emails coming from specific real estate sources (`zillow.com`, `realtor.com`, `trulia.com`, `facebookmail.com`).\n* **Parseur OCR Processing:** Converts email text into a file, uploads it to Parseur (Parser ID: `202917`), waits 10 seconds, and fetches the structured JSON output.\n\n### Setup Checklist\n1. **Gmail Authentication:** Ensure the Gmail trigger credentials and email polling scope are active.\n2. **Parseur Parser ID:** Verify that Parser ID `202917` is active and configured with template fields matching your real estate emails.\n3. **Google Sheets Permissions:** Confirm read/write OAuth access to document `1OzmSRAd9hBjDbxi9tSibKI8bKlMELbvbegEAHagJSiY`.\n\n### Customization\n* **Sender Domains:** Modify the Filter node to include additional lead sources (e.g., Redfin, Homes.com).\n* **Parsing Buffer:** Adjust the `Wait` node time if Parseur requires longer for complex document layouts."
      },
      "typeVersion": 1
    },
    {
      "id": "5391c477-193e-4ec4-a0d5-779d324c80db",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2032,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 496,
        "height": 464,
        "content": "## 1. Gmail Intake & Source Filtering\n* **Gets Email:** Polling trigger checking inbox every minute for new messages.\n* **Filter Lead Sources:** Validates sender domain against target providers (`zillow.com`, `realtor.com`, `trulia.com`, `facebookmail.com`)."
      },
      "typeVersion": 1
    },
    {
      "id": "637e04be-2d60-4756-ae9c-f95985f575af",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 816,
        "height": 496,
        "content": "## 2. File Conversion & Parseur Extraction\n* **Convert Email to Text File:** Transforms raw body text into file format required for OCR parsing.\n* **Extract Lead Data (Parseur):** Uploads text file payload to Parseur (Parser ID: `202917`).\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5968b795-9c1c-4743-9da6-a7ff59fc2cdc",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 896,
        "height": 496,
        "content": "## 3. Google Sheets Deduplication & Logging\n* **Check if Lead Already Exists:** Searches `Real Estate Leads Tracker` sheet for matching lead email.\n* **Lead Exists? (Duplicate Check):** Evaluates if a row number was returned from the lookup step.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "1f0eafc9-6323-46e2-bbe5-a10f238841a9",
  "nodeGroups": [],
  "connections": {
    "Gets Email": {
      "main": [
        [
          {
            "node": "Filters Zillow Realtor trulia and facebookmai emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse JSON Result": {
      "main": [
        [
          {
            "node": "Check if Lead Already Exists1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Parsing (10s)": {
      "main": [
        [
          {
            "node": "Fetch Parsed Document from Parseur",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Email to Text File": {
      "main": [
        [
          {
            "node": "Extract Lead Data (Parseur)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead Data (Parseur)": {
      "main": [
        [
          {
            "node": "Wait for Parsing (10s)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Lead Already Exists1": {
      "main": [
        [
          {
            "node": "Lead Exists? (Duplicate Check)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Exists? (Duplicate Check)": {
      "main": [
        [
          {
            "node": "Skip \u2013 Duplicate Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add New Lead to Tracker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Parsed Document from Parseur": {
      "main": [
        [
          {
            "node": "Parse JSON Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filters Zillow Realtor trulia and facebookmai emails": {
      "main": [
        [
          {
            "node": "Convert Email to Text File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}