| nodes |
[{"parameters":{"formTitle":"R [{"parameters":{"formTitle":"Real Estate - Form","formDescription":"Please provide all of your metrics to get the best real estate deals.","formFields":{"values":[{"fieldLabel":"Location","requiredField":true},{"fieldLabel":"Status","fieldType":"dropdown","fieldOptions":{"values":[{"option":"forSale"}]},"requiredField":true},{"fieldLabel":"Minimum Price","requiredField":true},{"fieldLabel":"Maximum Price","requiredField":true},{"fieldLabel":"Minimum Number of Beds","requiredField":true},{"fieldLabel":"Minimum Number of Bathrooms","requiredField":true},{"fieldLabel":"sortselection","fieldType":"dropdown","fieldOptions":{"values":[{"option":"Price"}]},"requiredField":true},{"fieldLabel":"Multi Family?","fieldType":"dropdown","fieldOptions":{"values":[{"option":"true"},{"option":"false"}]},"requiredField":true}]},"options":{}},"type":"n8n-nodes-base.formTrigger","typeVersion":2.3,"position":[0,0],"id":"5b2356a7-a20d-4ae7-b9ea-53395848c39a","name":"On form submission","webhookId":"ea20f37f-8676-4c8e-807a-e18200f9aa62"},{"parameters":{"url":"https://zillow56.p.rapidapi.com/search?","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","sendQuery":true,"queryParameters":{"parameters":[{"name":"location","value":"={{ $json.Location }}"},{"name":"status","value":"={{ $json.Status }}"},{"name":"price_min","value":"={{ $json['Minimum Price'] }}"},{"name":"price_max","value":"={{ $json['Maximum Price'] }}"},{"name":"beds_min","value":"={{ $json['Minimum Number of Beds'] }}"},{"name":"baths_min","value":"={{ $json['Minimum Number of Bathrooms'] }}"},{"name":"sortSelection","value":"={{ $json.sortselection }}"},{"name":"isMultiFamily","value":"={{ $json['Multi Family?'] }}"}]},"options":{}},"type":"n8n-nodes-base.httpRequest","typeVersion":4.3,"position":[208,0],"id":"ddb750b1-e1f9-44f6-845c-40d792a6520d","name":"Search for Deals","credentials":{"httpHeaderAuth":{"id":"Zgd6WeNleJH1GJW4","name":"Header Auth account"}}},{"parameters":{"fieldToSplitOut":"results","options":{}},"type":"n8n-nodes-base.splitOut","typeVersion":1,"position":[416,0],"id":"090fc404-e8cb-413c-9566-449222d89a36","name":"Split Out"},{"parameters":{"jsCode":"// ── CONFIGURABLE ASSUMPTIONS ─────────────────────────────────────────\nconst downPaymentPct = 0.20; // 20 % down\nconst closingCostPct = 0.03; // 3 % closing costs\nconst annualInterestRate = 0.05; // 5 % APR\nconst loanTermYears = 30; // 30‑yr mortgage\nconst propertyTaxRate = 0.012; // 1.2 % of assessed value per year\nconst insuranceRate = 0.003; // 0.3 % of price per year\nconst maintenanceRate = 0.01; // 1 % of price per year\n// ─────────────────────────────────────────────────────────────────────\n// IMPORTANT for n8n: return array of { json: … }\nreturn items.map(item => {\n // —— raw inputs (fall back to 0 if missing) ————————————————\n const j = item.json;\n const price = parseFloat(j.price) || 0;\n const rent = parseFloat(j.rentZestimate) || 0;\n const livingArea = parseFloat(j.LivingArea) || 0; // sqft\n const zEstimate = parseFloat(j.zestimate) || 0;\n const taxAssessedVal = parseFloat(j.taxAssessedValue)|| price;\n // ————————————————————————————————————————————————————————\n // —— Financing ——————————————————————————\n const downPayment = price * downPaymentPct;\n const closingCosts = price * closingCostPct;\n const loanAmount = price - downPayment;\n const monthlyRate = annualInterestRate / 12;\n const numPayments = loanTermYears * 12;\n const mortgagePayment= loanAmount * monthlyRate /\n (1 - Math.pow(1 + monthlyRate, -numPayments));\n // —— Operating expenses ———————————————\n const annualTax = taxAssessedVal * propertyTaxRate;\n const annualIns = price * insuranceRate;\n const annualMaint = price * maintenanceRate;\n const monthlyTax = annualTax / 12;\n const monthlyIns = annualIns / 12;\n const monthlyMaint = annualMaint / 12;\n // —— Cash‑flow & returns ——————————————\n const totalMonthlyExp = mortgagePayment + monthlyTax + monthlyIns + monthlyMaint;\n const monthlyCashFlow = rent - totalMonthlyExp;\n const annualCashFlow = monthlyCashFlow * 12;\n const capRate = annualCashFlow / price; // NOI ÷ price\n const cashOnCashROI = annualCashFlow / (downPayment + closingCosts);\n // —— Extra metrics ————————————————\n const pricePerSqft = livingArea ? price / livingArea : 0;\n const rentPerSqft = livingArea ? rent / livingArea : 0;\n const rentToPricePct = price ? (rent * 12) / price : 0; // GRM inverse\n const priceVsZestPct = zEstimate ? (price - zEstimate) / zEstimate : 0;\n // ————————————————————————————————————————————————————————\n // —— Attach everything to output JSON ——\n Object.assign(j, {\n downPayment: +downPayment.toFixed(2),\n closingCosts: +closingCosts.toFixed(2),\n loanAmount: +loanAmount.toFixed(2),\n mortgagePayment: +mortgagePayment.toFixed(2),\n monthlyPropertyTax: +monthlyTax.toFixed(2),\n monthlyInsurance: +monthlyIns.toFixed(2),\n monthlyMaintenance: +monthlyMaint.toFixed(2),\n totalMonthlyExpenses: +totalMonthlyExp.toFixed(2),\n monthlyCashFlow: +monthlyCashFlow.toFixed(2),\n annualCashFlow: +annualCashFlow.toFixed(2),\n capRate: +capRate.toFixed(4), // 0.0523 ➜ 5.23 %\n cashOnCashROI: +cashOnCashROI.toFixed(4), // 0.1234 ➜ 12.34 %\n pricePerSqft: +pricePerSqft.toFixed(2),\n rentPerSqft: +rentPerSqft.toFixed(2),\n rentToPricePct: +(rentToPricePct*100).toFixed(2), // % of price per yr\n priceVsZestimatePct: +(priceVsZestPct*100).toFixed(2) // over/under %\n });\n // Return a proper n8n item\n return { json: j };\n});\n"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[864,0],"id":"0840379e-e03a-442a-bcdb-4e4d7833e916","name":"Code in JavaScript"},{"parameters":{"assignments":{"assignments":[{"id":"8bdbd5fe-78d0-4569-8076-573f46dd5034","name":"Address","value":"={{ $json.streetAddress }} {{ $json.city }} {{ $json.state }} {{ $json.zipcode }} {{ $json.country }}","type":"string"},{"id":"eed9bcfb-4f00-482f-9414-a7570bdf8f5f","name":"homeStatus","value":"={{ $json.homeStatus }}","type":"string"},{"id":"4ef1f2eb-aea6-405b-85a1-fffe21f85b34","name":"homeType","value":"={{ $json.homeType }}","type":"string"},{"id":"8263a3b2-b408-4f55-91bb-86c9520fdb44","name":"totalSize","value":"={{ $json.lotAreaValue }} {{ $json.lotAreaUnit }}","type":"string"},{"id":"e3f552dc-53bd-45cf-bea6-af8229731f87","name":"livingArea","value":"={{ $json.livingArea }}","type":"number"},{"id":"2207b169-47a3-428c-be30-b751447f8a53","name":"price","value":"={{ $json.price }}","type":"number"},{"id":"16a0e52a-9377-497a-83fd-3afa25598c04","name":"taxAssessedValue","value":"={{ $json.taxAssessedValue }}","type":"number"},{"id":"f6147499-df03-4cde-affc-2fcd13626d32","name":"zestimate","value":"={{ $json.zestimate }}","type":"number"},{"id":"1c0f0085-e321-4dd2-9f9d-ff72b505f025","name":"rentZestimate","value":"={{ $json.rentZestimate }}","type":"number"},{"id":"54ae01bc-e9d6-44fb-a8bf-cb7181374409","name":"priceReduction","value":"={{ $json.priceReduction }}","type":"string"},{"id":"06f2f109-5fcb-4042-bab2-823bd700c8d0","name":"bathrooms","value":"={{ $json.bathrooms }}","type":"number"},{"id":"54672fbf-3454-459c-a7e5-f04eea02bb3d","name":"bedrooms","value":"={{ $json.bedrooms }}","type":"number"},{"id":"1d2d6bab-dbf5-472b-bb05-9fbb7f824424","name":"isNonOwnerOccupied","value":"={{ $json.isNonOwnerOccupied }}","type":"boolean"},{"id":"4384ee7b-6064-4464-8826-c4d4056f85de","name":"isPreforeclosureAuction","value":"={{ $json.isPreforeclosureAuction }}","type":"boolean"},{"id":"b8fb5175-5260-4f70-9f87-f01348acdf25","name":"isPremierBuilder","value":"={{ $json.isPremierBuilder }}","type":"boolean"},{"id":"598ef3a5-ec3c-4ead-b3c7-85a5ec46fb4f","name":"isShowcaseListing","value":"={{ $json.isShowcaseListing }}","type":"boolean"}]},"options":{}},"type":"n8n-nodes-base.set","typeVersion":3.4,"position":[624,0],"id":"0367649e-6e55-44bd-977d-7f60844e897b","name":"Edit Fields"},{"parameters":{"operation":"appendOrUpdate","documentId":{"__rl":true,"value":"1Pjkm9z5fQg_QQLYYtRDSgJPJxIm5ukt2hu9pwvG_52E","mode":"list","cachedResultName":"Real Estate Deals [TEMPLATE]","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1Pjkm9z5fQg_QQLYYtRDSgJPJxIm5ukt2hu9pwvG_52E/edit?usp=drivesdk"},"sheetName":{"__rl":true,"value":"gid=0","mode":"list","cachedResultName":"Sheet1","cachedResultUrl":"https://docs.google.com/spreadsheets/d/1Pjkm9z5fQg_QQLYYtRDSgJPJxIm5ukt2hu9pwvG_52E/edit#gid=0"},"columns":{"mappingMode":"defineBelow","value":{"Address":"={{ $json.Address }}","homeStatus":"={{ $json.homeStatus }}","homeType":"={{ $json.homeType }}","totalSize":"={{ $json.totalSize }}","LivingArea":"={{ $json.livingArea }}","price":"={{ $json.price }}","taxAssessedValue":"={{ $json.taxAssessedValue }}","zestimate":"={{ $json.zestimate }}","rentZestimate":"={{ $json.rentZestimate }}","priceReduction":"={{ $json.priceReduction }}","bathrooms":"={{ $json.bathrooms }}","bedrooms":"={{ $json.bedrooms }}","isNonOwnerOccupied":"={{ $json.isNonOwnerOccupied }}","isPreforeclosureAuction":"={{ $json.isPreforeclosureAuction }}","isPremierBuilder":"={{ $json.isPremierBuilder }}","isShowcaseListing":"={{ $json.isShowcaseListing }}","downPayment":"={{ $json.downPayment }}","closingCosts":"={{ $json.closingCosts }}","loanAmount":"={{ $json.loanAmount }}","mortgagePayment":"={{ $json.mortgagePayment }}","monthlyPropertyTax":"={{ $json.monthlyPropertyTax }}","monthlyMaintenance":"={{ $json.monthlyMaintenance }}","monthlyInsurance":"={{ $json.monthlyInsurance }}","totalMonthlyExpenses":"={{ $json.totalMonthlyExpenses }}","annualCashFlow":"={{ $json.annualCashFlow }}","monthlyCashFlow":"={{ $json.monthlyCashFlow }}","capRate":"={{ $json.capRate }}","cashOnCashROI":"={{ $json.cashOnCashROI }}","pricePerSqft":"={{ $json.pricePerSqft }}","rentPerSqft":"={{ $json.rentPerSqft }}","rentToPricePct":"={{ $json.rentToPricePct }}","priceVsZestimatePct":"={{ $json.priceVsZestimatePct }}"},"matchingColumns":["Address"],"schema":[{"id":"Address","displayName":"Address","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true,"removed":false},{"id":"homeStatus","displayName":"homeStatus","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"homeType","displayName":"homeType","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"totalSize","displayName":"totalSize","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"LivingArea","displayName":"LivingArea","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"price","displayName":"price","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"taxAssessedValue","displayName":"taxAssessedValue","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"zestimate","displayName":"zestimate","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"rentZestimate","displayName":"rentZestimate","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"priceReduction","displayName":"priceReduction","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"bathrooms","displayName":"bathrooms","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"bedrooms","displayName":"bedrooms","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"isNonOwnerOccupied","displayName":"isNonOwnerOccupied","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"isPreforeclosureAuction","displayName":"isPreforeclosureAuction","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"isPremierBuilder","displayName":"isPremierBuilder","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"isShowcaseListing","displayName":"isShowcaseListing","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"downPayment","displayName":"downPayment","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"closingCosts","displayName":"closingCosts","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"loanAmount","displayName":"loanAmount","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"mortgagePayment","displayName":"mortgagePayment","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"monthlyPropertyTax","displayName":"monthlyPropertyTax","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"monthlyInsurance","displayName":"monthlyInsurance","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"monthlyMaintenance","displayName":"monthlyMaintenance","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"totalMonthlyExpenses","displayName":"totalMonthlyExpenses","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"monthlyCashFlow","displayName":"monthlyCashFlow","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"annualCashFlow","displayName":"annualCashFlow","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"capRate","displayName":"capRate","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"cashOnCashROI","displayName":"cashOnCashROI","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"pricePerSqft","displayName":"pricePerSqft","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"rentPerSqft","displayName":"rentPerSqft","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"rentToPricePct","displayName":"rentToPricePct","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true},{"id":"priceVsZestimatePct","displayName":"priceVsZestimatePct","required":false,"defaultMatch":false,"display":true,"type":"string","canBeUsedToMatch":true}],"attemptToConvertTypes":false,"convertFieldsToString":false},"options":{}},"type":"n8n-nodes-base.googleSheets","typeVersion":4.7,"position":[1184,208],"id":"d9efc71a-2d86-49e7-ac5f-6a8870261acc","name":"Append or update row in sheet","credentials":{"googleSheetsOAuth2Api":{"id":"NufmenCs2JQN68sm","name":"Google Sheets account"}}},{"parameters":{"aggregate":"aggregateAllItemData","options":{}},"type":"n8n-nodes-base.aggregate","typeVersion":1,"position":[1184,-160],"id":"733f904c-d2da-4651-b75b-364618f9cfb3","name":"Aggregate"},{"parameters":{"promptType":"define","text":"=You are a seasoned real estate investment analyst. Each day, you'll receive a JSON array of property records with fields such as:\nAddress\nhomeStatus, homeType, size\nprice, taxAssessedValue, zestimate, rentZestimate\ndownPayment, closingCosts, loanAmount, mortgagePayment\nmonthlyPropertyTax, monthlyInsurance, monthlyMaintenance\ntotalMonthlyExpenses, monthlyCashFlow, annualCashFlow\ncapRate, cashOnCashROI\nThe input is available as:\n{{ JSON.stringify($json.data) }}\nYour tasks:\nWrite a short one-sentence summary of the overall real estate market sentiment.\nList the Top 3 properties ranked by cash-on-cash ROI, and for each show:\nAddress\nROI (%)\nMonthly cash flow\nList the Top 3 properties ranked by cap rate, and for each show:\nAddress\nCap rate (%)\nAnnual cash flow\nHighlight any properties with negative monthly cash flow.\nCalculate and display portfolio-wide averages for:\nCap rate (%)\nCash-on-cash ROI (%)\nMonthly cash flow (USD)\nSuggest up to two next actions, for example:\n“Schedule showings for properties X, Y”\n“Consider raising your max price filter to find better cap rates”\nFormat your output as a clean daily report with headings and bullet points.\nUse the Gmail tool to email this summary.\nSet the email subject to:\nDaily Real Estate KPI Report for {{ $now }}\n(Ensure the date is in YYYY-MM-DD format.)\nMake sure the email is HTML formatted and easy to read.\n","options":{}},"type":"@n8n/n8n-nodes-langchain.agent","typeVersion":3,"position":[1392,-160],"id":"fc43feb3-18ca-41f9-aa8d-2ee89ab7b38d","name":"AI Agent"},{"parameters":{"model":{"__rl":true,"value":"gpt-4o-mini","mode":"list","cachedResultName":"gpt-4o-mini"},"builtInTools":{},"options":{}},"type":"@n8n/n8n-nodes-langchain.lmChatOpenAi","typeVersion":1.3,"position":[1264,48],"id":"251d85a3-b9aa-4e1d-bc78-533c59a3c330","name":"OpenAI Chat Model","credentials":{"openAiApi":{"id":"5DFuvUPLavfaWChn","name":"OpenAi account"}}},{"parameters":{},"type":"@n8n/n8n-nodes-langchain.toolCalculator","typeVersion":1,"position":[1536,48],"id":"b02f0deb-d55d-45f2-936b-9b911c19a2cb","name":"Calculator"},{"parameters":{"sendTo":"[email protected]","subject":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}","message":"={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}","options":{}},"type":"n8n-nodes-base.gmailTool","typeVersion":2.1,"position":[1744,32],"id":"d0609e07-bcba-4276-a509-1eca5491c7e9","name":"Send a message in Gmail","webhookId":"b6f424d4-57be-4c06-a208-aea7541ceee9","credentials":{"gmailOAuth2":{"id":"jq5N8RrWCTNs4opL","name":"Gmail account"}}}]... |