{
  "id": "VhEwspDqzu7ssFVE",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "My workflow 2",
  "tags": [
    {
      "id": "DxXGubfBzRKh6L8T",
      "name": "Revenue Optimization",
      "createdAt": "2025-07-25T16:24:30.370Z",
      "updatedAt": "2025-07-25T16:24:30.370Z"
    },
    {
      "id": "IxkcJ2IpYIxivoHV",
      "name": "Content Strategy",
      "createdAt": "2025-07-25T12:57:37.677Z",
      "updatedAt": "2025-07-25T12:57:37.677Z"
    },
    {
      "id": "PAKIJ2Mm9EvRcR3u",
      "name": "Trend Monitoring",
      "createdAt": "2025-07-25T12:57:37.670Z",
      "updatedAt": "2025-07-25T12:57:37.670Z"
    },
    {
      "id": "YtfXmaZk44MYedPO",
      "name": "Dynamic Pricing",
      "createdAt": "2025-07-25T16:24:30.369Z",
      "updatedAt": "2025-07-25T16:24:30.369Z"
    },
    {
      "id": "wJ30mjhtrposO8Qt",
      "name": "Simple RAG",
      "createdAt": "2025-07-28T12:55:14.424Z",
      "updatedAt": "2025-07-28T12:55:14.424Z"
    }
  ],
  "nodes": [
    {
      "id": "b3039a5a-fac6-42bc-8165-df16a3a3e610",
      "name": "\ud83d\udccb Schedule Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        144
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 852,
        "content": "# Daily CRE Scanner \u23f0\n\n**Automated Market Monitoring:**\n- Runs every 24 hours automatically\n- Triggers the entire CRE intelligence pipeline\n- No manual intervention required\n- Consistent market data collection\n\n**Schedule Benefits:**\n\u2705 Fresh data daily\n\u2705 Catches new listings immediately\n\u2705 Tracks market changes over time\n\u2705 Reliable automation\n\n**Configuration:**\n\u2022 Interval: 24 hours\n\u2022 Timezone: Server default\n\u2022 Error handling: Built-in retry\n\u2022 Next execution: Visible in logs\n\n**What Happens Next:**\n\u2192 Triggers CRE data collection from major platforms\n\u2192 Initiates complete market analysis\n\u2192 Generates daily intelligence report"
      },
      "typeVersion": 1
    },
    {
      "id": "072af1a6-fc7e-435e-bd7e-b68e5eeb6d84",
      "name": "Daily CRE Scanner",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1008,
        832
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5239bd82-fc3a-42df-bea8-40e1f0d2c01b",
      "name": "\ud83d\udccb Data Collection",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        144
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 852,
        "content": "# CRE Data Collector \ud83d\udd77\ufe0f\n\n**AI-Powered Web Scraping:**\n- Uses ScrapeGraphAI for intelligent extraction\n- Targets major CRE platforms (LoopNet)\n- Structured data output with schema\n- Handles dynamic content automatically\n\n**Data Points Collected:**\n\u2705 Property ID & type\n\u2705 Size (square footage)\n\u2705 Location details\n\u2705 Pricing information\n\u2705 Lease rates ($/sqft)\n\u2705 Contact information\n\n**API Configuration:**\n\u2022 Endpoint: ScrapeGraphAI smart scraper\n\u2022 Method: POST with JSON payload\n\u2022 Timeout: 60 seconds\n\u2022 Authentication: Header-based\n\n**Target Platform:**\n\u2022 LoopNet commercial listings\n\u2022 Real-time market data\n\u2022 Comprehensive property details\n\n**Output Format:**\n\u2192 Structured JSON with listings array\n\u2192 Ready for immediate analysis"
      },
      "typeVersion": 1
    },
    {
      "id": "22906cc4-e61a-440d-8a62-61c0633549bb",
      "name": "CRE Data Collector",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -608,
        816
      ],
      "parameters": {
        "url": "https://api.scrapegraphai.com/v1/smartscraper",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "headerAuth",
        "bodyParameters": {
          "parameters": [
            {
              "name": "website_url",
              "value": "https://www.loopnet.com/search/commercial-real-estate/"
            },
            {
              "name": "user_prompt",
              "value": "Extract commercial real estate listings: property type, size, location, price, lease rate, contact info"
            },
            {
              "name": "output_schema",
              "value": "{\"listings\": [{\"id\": \"string\", \"type\": \"string\", \"size_sqft\": \"number\", \"location\": \"string\", \"price\": \"number\", \"lease_rate\": \"number\", \"contact\": \"string\"}]}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "131f2431-f6f1-44b7-87ef-d0cdf7690f3e",
      "name": "\ud83d\udccb Analysis Engine",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        144
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 852,
        "content": "# CRE Analyzer & Dashboard \ud83d\udcca\n\n**Comprehensive Market Intelligence:**\n- Processes scraped listings data\n- Generates market summary & insights\n- Identifies investment opportunities\n- Creates actionable dashboard\n\n**Analysis Features:**\n\u2705 Property type distribution\n\u2705 Location popularity ranking\n\u2705 Average lease rate calculation\n\u2705 Below-market opportunity detection\n\u2705 Alert generation system\n\n**Key Calculations:**\n\u2022 Total listings processed\n\u2022 Market rate averages\n\u2022 Geographic clustering\n\u2022 Opportunity scoring\n\u2022 Priority rankings\n\n**Alert Triggers:**\n\u2022 High opportunity count (>10 properties)\n\u2022 Rate alerts (>$30/sqft average)\n\u2022 Market anomalies\n\n**Dashboard Output:**\n\u2192 Executive summary with KPIs\n\u2192 Top 5 property types & locations\n\u2192 Priority opportunities list\n\u2192 Actionable next steps"
      },
      "typeVersion": 1
    },
    {
      "id": "702d76c3-3229-446b-adaf-2c0d8e751121",
      "name": "CRE Analyzer & Dashboard",
      "type": "n8n-nodes-base.code",
      "position": [
        -192,
        864
      ],
      "parameters": {
        "jsCode": "// Simplified CRE Analysis & Dashboard\nconst scrapedData = $input.all()[0].json;\nconst listings = scrapedData.listings || [];\n\n// Core analysis\nconst analysis = {\n  total_listings: listings.length,\n  avg_lease_rate: 0,\n  property_types: {},\n  top_locations: {},\n  opportunities: [],\n  alerts: []\n};\n\n// Process listings\nlet totalRate = 0;\nlet rateCount = 0;\n\nlistings.forEach(listing => {\n  // Track property types\n  const type = listing.type || 'Unknown';\n  analysis.property_types[type] = (analysis.property_types[type] || 0) + 1;\n  \n  // Track locations\n  const location = listing.location || 'Unknown';\n  analysis.top_locations[location] = (analysis.top_locations[location] || 0) + 1;\n  \n  // Calculate average rates\n  if (listing.lease_rate) {\n    totalRate += listing.lease_rate;\n    rateCount++;\n  }\n  \n  // Identify opportunities (below market rate)\n  if (listing.lease_rate && listing.lease_rate < 20) {\n    analysis.opportunities.push({\n      id: listing.id,\n      type: listing.type,\n      location: listing.location,\n      rate: listing.lease_rate,\n      size: listing.size_sqft,\n      opportunity: 'Below Market Rate'\n    });\n  }\n});\n\nanalysis.avg_lease_rate = rateCount > 0 ? (totalRate / rateCount).toFixed(2) : 0;\n\n// Generate alerts\nif (analysis.opportunities.length > 10) {\n  analysis.alerts.push({\n    type: 'High Opportunity Count',\n    message: `${analysis.opportunities.length} below-market properties found`,\n    priority: 'High'\n  });\n}\n\nif (analysis.avg_lease_rate > 30) {\n  analysis.alerts.push({\n    type: 'Rate Alert',\n    message: `Average lease rate (${analysis.avg_lease_rate}) above $30/sqft`,\n    priority: 'Medium'\n  });\n}\n\n// Create dashboard summary\nconst dashboard = {\n  generated_at: new Date().toISOString(),\n  market_summary: {\n    total_properties: analysis.total_listings,\n    avg_lease_rate: `${analysis.avg_lease_rate}/sqft`,\n    opportunities_found: analysis.opportunities.length,\n    active_alerts: analysis.alerts.length\n  },\n  top_property_types: Object.entries(analysis.property_types)\n    .sort(([,a], [,b]) => b - a)\n    .slice(0, 5)\n    .map(([type, count]) => ({ type, count })),\n  top_locations: Object.entries(analysis.top_locations)\n    .sort(([,a], [,b]) => b - a)\n    .slice(0, 5)\n    .map(([location, count]) => ({ location, count })),\n  priority_opportunities: analysis.opportunities\n    .sort((a, b) => a.rate - b.rate)\n    .slice(0, 10),\n  alerts: analysis.alerts,\n  next_actions: [\n    analysis.opportunities.length > 0 ? `Review ${analysis.opportunities.length} opportunities` : 'No immediate opportunities',\n    analysis.alerts.length > 0 ? `Address ${analysis.alerts.length} alerts` : 'No alerts requiring action',\n    'Update market analysis tomorrow'\n  ]\n};\n\nconsole.log(`CRE Analysis Complete: ${dashboard.market_summary.total_properties} properties, ${dashboard.market_summary.opportunities_found} opportunities`);\n\nreturn [{ json: dashboard }];"
      },
      "typeVersion": 2
    },
    {
      "id": "422fb0a3-a654-4239-bcf4-3da927626df6",
      "name": "\ud83d\udccb Decision Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        144
      ],
      "parameters": {
        "color": 6,
        "width": 400,
        "height": 852,
        "content": "# Opportunity Check \ud83c\udfaf\n\n**Smart Conditional Logic:**\n- Evaluates if opportunities were found\n- Only sends alerts when action needed\n- Prevents notification spam\n- Optimizes workflow efficiency\n\n**Decision Logic:**\n\u2705 Checks opportunities_found > 0\n\u2705 Routes to notification if true\n\u2705 Skips alerts if no opportunities\n\u2705 Always logs data regardless\n\n**Benefits:**\n\u2022 Reduces noise in communications\n\u2022 Focuses attention on actionable items\n\u2022 Saves API calls when not needed\n\u2022 Maintains clean notification history\n\n**Routing Logic:**\n\u2192 TRUE: Send Telegram alert with details\n\u2192 FALSE: Skip notification, continue logging\n\u2192 BOTH: Always log to Google Sheets\n\n**Configuration:**\n\u2022 Condition: opportunities_found > 0\n\u2022 Type: Number comparison\n\u2022 Case sensitive: True\n\u2022 Strict validation: Enabled"
      },
      "typeVersion": 1
    },
    {
      "id": "9fcce7ef-60c1-422e-9e0c-de5f684d3bdb",
      "name": "Check for Opportunities",
      "type": "n8n-nodes-base.if",
      "position": [
        192,
        848
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-opportunities",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.market_summary.opportunities_found }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "864ba85a-3b21-4bde-a6b2-686368436e6d",
      "name": "\ud83d\udccb Telegram Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -176
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 852,
        "content": "# Send Opportunity Alert \ud83d\udcf1\n\n**Instant Telegram Notifications:**\n- Sends formatted CRE daily report\n- Includes market summary & top opportunities\n- Only triggers when opportunities exist\n- Professional message formatting\n\n**Message Content:**\n\u2705 Market summary with key metrics\n\u2705 Total properties analyzed\n\u2705 Average lease rate\n\u2705 Top 3 opportunities with details\n\u2705 Alert summary\n\n**Setup Requirements:**\n\u2022 Telegram Bot Token (from @BotFather)\n\u2022 Chat ID (your Telegram user/group ID)\n\u2022 Bot must be added to chat\n\u2022 Proper permissions configured\n\n**Message Format:**\n\ud83c\udfe2 **CRE Daily Report**\n\ud83d\udcca Market metrics\n\ud83c\udfaf Top opportunities\n\u26a0\ufe0f Active alerts\n\n**Benefits:**\n\u2192 Immediate awareness of opportunities\n\u2192 Mobile-friendly notifications\n\u2192 Formatted for quick reading\n\u2192 Historical message log"
      },
      "typeVersion": 1
    },
    {
      "id": "b4b5cccf-a7da-403f-a7fc-13226b929040",
      "name": "Send Opportunity Alert",
      "type": "n8n-nodes-base.telegram",
      "position": [
        608,
        544
      ],
      "parameters": {
        "operation": "send"
      },
      "typeVersion": 1.2
    },
    {
      "id": "4ce23013-8b82-439a-8e33-89291516078c",
      "name": "\ud83d\udccb Data Logging",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        672
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 916,
        "content": "# Log to Google Sheets \ud83d\udcc8\n\n**Historical Data Tracking:**\n- Automatically logs daily CRE metrics\n- Builds historical trend database\n- Enables long-term market analysis\n- Creates data foundation for reporting\n\n**Logged Metrics:**\n\u2705 Date (YYYY-MM-DD format)\n\u2705 Total properties analyzed\n\u2705 Average lease rate\n\u2705 Opportunities count\n\u2705 Top location\n\u2705 Alert count\n\n**Setup Requirements:**\n\u2022 Google Sheets document ID\n\u2022 Sheet name: 'CRE_Analysis'\n\u2022 Service account authentication\n\u2022 Proper column headers\n\n**Benefits:**\n\u2022 Track market trends over time\n\u2022 Identify seasonal patterns\n\u2022 Monitor alert frequency\n\u2022 Export data for analysis\n\u2022 Historical performance review\n\n**Data Structure:**\n\u2192 One row per day\n\u2192 Standardized column mapping\n\u2192 Automatic date stamping\n\u2192 Consistent data format"
      },
      "typeVersion": 1
    },
    {
      "id": "501df296-9ece-4f93-ac15-d6b753c10813",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        576,
        1456
      ],
      "parameters": {
        "resource": "spreadsheet",
        "operation": "appendOrUpdate"
      },
      "typeVersion": 4.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3d0f65de-749a-42e4-bbfc-b7073454c025",
  "connections": {
    "Daily CRE Scanner": {
      "main": [
        [
          {
            "node": "CRE Data Collector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CRE Data Collector": {
      "main": [
        [
          {
            "node": "CRE Analyzer & Dashboard",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Opportunities": {
      "main": [
        [
          {
            "node": "Send Opportunity Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "CRE Analyzer & Dashboard": {
      "main": [
        [
          {
            "node": "Check for Opportunities",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}