{
  "id": "72wod2KyYJtbRB9H",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Real Estet Automation",
  "tags": [],
  "nodes": [
    {
      "id": "b7841298-d962-4077-a738-4208c6fc18e7",
      "name": "Create Master Spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        192,
        16
      ],
      "parameters": {
        "title": "={{ $now }}",
        "options": {},
        "resource": "spreadsheet",
        "sheetsUi": {
          "sheetValues": [
            {
              "title": "99Acres"
            },
            {
              "title": "MagicBricks"
            }
          ]
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "bc5ed6fb-7ee1-4b3f-ab60-5f4ccdcfd21b",
      "name": "Fetch 99Acres Listings",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        432,
        -64
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/fatihtahta~99acres-scraper-ppe/run-sync-get-dataset-items?token=<YOUR-API-KEY>",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"startUrls\": [\n        \"{{ $('Property Search URLs').item.json['99Acres'] }}\"\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.3
    },
    {
      "id": "fdf938a4-49da-454c-92fb-f4099c6d7416",
      "name": "Fetch MagicBricks Listings",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        432,
        128
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/ecomscrape~magicbricks-property-search-scraper/run-sync-get-dataset-items?token=<YOUR-API-KEY>",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"max_retries_per_url\": 2,\n    \"proxy\": {\n        \"useApifyProxy\": true,\n        \"apifyProxyGroups\": [\n            \"RESIDENTIAL\"\n        ],\n        \"apifyProxyCountry\": \"IN\"\n    },\n    \"urls\": [\n        \"{{ $('Property Search URLs').item.json['Magic Bricks'] }}\"\n    ]\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.3
    },
    {
      "id": "fb105b28-b47a-4626-a195-7e6854a6ebf7",
      "name": "Filter & Format 99Acres Listings",
      "type": "n8n-nodes-base.code",
      "position": [
        688,
        -64
      ],
      "parameters": {
        "jsCode": "const seenIds = new Set();\nconst result = [];\n\nfor (const item of $input.all()) {\n  const data = item.json;\n\n  // Skip if id already exists\n  if (seenIds.has(data.id)) {\n    continue;\n  }\n\n  seenIds.add(data.id);\n\n  result.push({\n    json: {\n      Property_id: data.id,\n      Property_title: data.title,\n      Property_price: data.priceRange,\n      Property_pricePerSqft: data.pricePerSqft,\n      Property_url: data.url,\n    }\n  });\n}\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "59070614-bcae-4315-9470-c28a47a69015",
      "name": "Filter & Format MagicBricks Listings",
      "type": "n8n-nodes-base.code",
      "position": [
        688,
        128
      ],
      "parameters": {
        "jsCode": "const seenIds = new Set();\nconst result = [];\n\nfor (const item of $input.all()) {\n  const data = item.json;\n\n  // Remove duplicates based on id\n  if (seenIds.has(data.id)) {\n    continue;\n  }\n  seenIds.add(data.id);\n\n  // Build full MagicBricks URL\n  const fullUrl = data.url\n    ? `https://www.magicbricks.com/propertyDetails/${data.url}`\n    : null;\n\n  result.push({\n    json: {\n      Property_id: data.id,\n      Property_title: data.name,\n      Property_price: `${data.currency}${data.price}`,\n      Property_pricePerSqft: data.price_per_sq_ft,\n      Property_url: fullUrl,\n    }\n  });\n}\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "07efdf9d-da87-41ec-872a-7747b86c5ad8",
      "name": "Append Rows \u2192 99Acres Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        944,
        -64
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Property_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_price",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_pricePerSqft",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_pricePerSqft",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Master Spreadsheet').item.json.sheets[0].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Master Spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "50940371-760e-406e-846a-08d5c0cd981b",
      "name": "Append Rows \u2192 MagicBricks Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        944,
        128
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Property_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_price",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_pricePerSqft",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_pricePerSqft",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Property_url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Property_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Master Spreadsheet').item.json.sheets[1].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create Master Spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6e9c56d4-29ae-4c75-9010-7a430c822999",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        -176
      ],
      "parameters": {
        "width": 528,
        "height": 512,
        "content": "##  99Acres & MagicBricks \u2192 Google Sheets\n\n### How it works\n1. The workflow starts when a user submits property search URLs through the form.\n2. A new Google Spreadsheet is created automatically with two dedicated sheets: one for 99Acres and one for MagicBricks.\n3. Property listings are fetched from the 99Acres and MagicBricks portals using their respective APIs.\n4. The fetched data is cleaned and standardized into a consistent structure (Property ID, Title, Price, Price per Sqft, URL).\n5. Duplicate listings are removed to avoid repeated rows.\n6. The processed data is appended to the correct sheet for each portal.\n\n### Setup steps\n1. Connect your Google Sheets account in all Google Sheets nodes.\n2. Open the Form Trigger and submit valid search URLs for 99Acres and MagicBricks.\n3. Run the workflow (or submit the form live).\n4. A new spreadsheet will be created and populated automatically.\n\nNo manual sheet or spreadsheet selection is required."
      },
      "typeVersion": 1
    },
    {
      "id": "955899bb-62c7-4c5e-a0f6-bd68d7b82767",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 288,
        "content": "## Trigger\nStarts the workflow when a user submits property search URLs."
      },
      "typeVersion": 1
    },
    {
      "id": "ad1d0859-114a-4029-a4cd-d5d59e37f42b",
      "name": "Property Search URLs",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -32,
        16
      ],
      "parameters": {
        "options": {},
        "formTitle": "Real Estate Links",
        "formFields": {
          "values": [
            {
              "fieldLabel": "99Acres",
              "placeholder": "Enter Url of 99acres search Page"
            },
            {
              "fieldLabel": "Magic Bricks",
              "placeholder": "Enter Url of Magic Bricks search Page"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0413192a-5760-4ed4-8e6b-d8f750c39f94",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 176,
        "height": 352,
        "content": "## Create Spreadsheet\nCreates a new Google Spreadsheet with dedicated sheets for each portal.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1f7ce13e-a8ba-4744-9127-6bdb2a537b33",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -256
      ],
      "parameters": {
        "color": 7,
        "height": 592,
        "content": "## Fetch Property Listings\nCalls external APIFY scrapers/APIs to retrieve raw property listings\nfrom 99Acres and MagicBricks based on user-provided URLs.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d337ea0c-3dfa-4e23-a139-d6fb069e768d",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -304
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 608,
        "content": "## Clean & Standardize Data\nFilters duplicate listings and converts raw API responses\ninto a consistent format suitable for Google Sheets.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "63f2a96c-07ae-440f-ae06-cbc7a60b5b31",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -272
      ],
      "parameters": {
        "color": 7,
        "height": 576,
        "content": "## Save Results to Sheets\nAppends cleaned listings into the correct sheet\nso each portal\u2019s data stays separated and organized.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a6b2671b-22c2-44fe-80bf-e9ebe6d8865b",
  "connections": {
    "Property Search URLs": {
      "main": [
        [
          {
            "node": "Create Master Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch 99Acres Listings": {
      "main": [
        [
          {
            "node": "Filter & Format 99Acres Listings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Master Spreadsheet": {
      "main": [
        [
          {
            "node": "Fetch 99Acres Listings",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch MagicBricks Listings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch MagicBricks Listings": {
      "main": [
        [
          {
            "node": "Filter & Format MagicBricks Listings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter & Format 99Acres Listings": {
      "main": [
        [
          {
            "node": "Append Rows \u2192 99Acres Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter & Format MagicBricks Listings": {
      "main": [
        [
          {
            "node": "Append Rows \u2192 MagicBricks Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}