{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1929aeb3-feab-43a0-b755-680568c9e239",
      "name": "Parse Request Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -576,
        608
      ],
      "parameters": {
        "jsCode": "// Parse maintenance request form data\nconst formData = $input.first().json;\n\nreturn {\n  json: {\n    requestId: formData.submissionID || 'REQ-' + Date.now(),\n    tenantName: formData.tenantName || formData.q3_tenantName,\n    tenantEmail: formData.tenantEmail || formData.q4_tenantEmail,\n    tenantPhone: formData.tenantPhone || formData.q5_tenantPhone,\n    unitNumber: formData.unitNumber || formData.q6_unitNumber,\n    propertyAddress: formData.propertyAddress || formData.q7_propertyAddress,\n    issueDescription: formData.issueDescription || formData.q8_issueDescription,\n    urgencyLevel: formData.urgencyLevel || formData.q9_urgencyLevel || 'normal',\n    photoUrl: formData.photoUrl || formData.q10_photo,\n    accessInstructions: formData.accessInstructions || formData.q11_accessInstructions,\n    preferredContactMethod: formData.preferredContactMethod || formData.q12_preferredContactMethod || 'email',\n    submittedAt: new Date().toISOString(),\n    status: 'new'\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "abcf8b09-1c79-49d7-8207-7896070bc9a0",
      "name": "AI Maintenance Analysis",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -304,
        800
      ],
      "parameters": {
        "text": "=You are an expert property maintenance analyst. Analyze this maintenance request and provide comprehensive categorization and recommendations.\n\n**Request Details:**\n- Unit Number: {{ $json.unitNumber }}\n- Tenant: {{ $json.tenantName }}\n- Urgency Level (Tenant-Reported): {{ $json.urgencyLevel }}\n- Issue Description: {{ $json.issueDescription }}\n\n**Access Instructions:**\n{{ $json.accessInstructions }}\n\nProvide a detailed analysis in JSON format:\n{\n  \"issueCategory\": {\n    \"primary\": \"plumbing|electrical|hvac|appliance|structural|pest_control|lockout|general_repair|other\",\n    \"secondary\": [\"specific sub-categories\"],\n    \"confidence\": 0-100\n  },\n  \"priorityAssessment\": {\n    \"level\": \"emergency|urgent|high|normal|low\",\n    \"reasoning\": \"why this priority was assigned\",\n    \"keywords_detected\": [\"emergency keywords found\"],\n    \"safety_concern\": true|false,\n    \"habitability_issue\": true|false\n  },\n  \"estimatedComplexity\": {\n    \"level\": \"simple|moderate|complex|major\",\n    \"estimated_hours\": number,\n    \"requires_specialist\": true|false\n  },\n  \"recommendedVendor\": {\n    \"type\": \"plumber|electrician|hvac_tech|handyman|locksmith|pest_control|general_contractor\",\n    \"urgency\": \"emergency_dispatch|same_day|within_24h|within_48h|scheduled\",\n    \"specialization_needed\": \"specific expertise if required\"\n  },\n  \"cost_estimate\": {\n    \"range\": \"$min - $max\",\n    \"factors\": [\"cost factors to consider\"]\n  },\n  \"tenant_communication\": {\n    \"initial_response\": \"message to send tenant immediately\",\n    \"estimated_resolution\": \"timeframe estimate\",\n    \"temporary_solutions\": [\"interim fixes tenant can do\"]\n  },\n  \"safety_protocols\": [\n    \"safety step 1\",\n    \"safety step 2\"\n  ],\n  \"recurring_issue_check\": {\n    \"likely_recurring\": true|false,\n    \"warranty_applicable\": true|false,\n    \"preventive_recommendation\": \"suggestion to prevent future issues\"\n  },\n  \"contractor_instructions\": [\n    \"specific instruction 1\",\n    \"specific instruction 2\",\n    \"what to bring/check\"\n  ],\n  \"legal_compliance\": {\n    \"urgent_legal_requirement\": true|false,\n    \"habitability_law_concern\": true|false,\n    \"documentation_needed\": \"what needs to be documented\"\n  }\n}",
        "options": {
          "systemMessage": "You are an expert property maintenance coordinator with 20+ years of experience in residential and commercial property management. You understand emergency protocols, vendor capabilities, legal requirements, and cost optimization."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "2f21e918-270c-481d-870c-bff0576ec812",
      "name": "Extract AI Response",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        480
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "aiAnalysis",
              "name": "aiAnalysis",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "fc2f820d-a761-4960-8617-5ef22110be24",
      "name": "Merge AI Analysis",
      "type": "n8n-nodes-base.code",
      "position": [
        320,
        480
      ],
      "parameters": {
        "jsCode": "// Merge AI analysis with request data\nconst requestData = $input.first().json;\nconst aiAnalysisRaw = requestData.aiAnalysis;\n\n// Parse AI analysis\nlet aiAnalysis;\ntry {\n  aiAnalysis = JSON.parse(aiAnalysisRaw);\n} catch (e) {\n  // Fallback if parsing fails\n  aiAnalysis = {\n    issueCategory: {\n      primary: 'general_repair',\n      secondary: ['maintenance'],\n      confidence: 60\n    },\n    priorityAssessment: {\n      level: 'normal',\n      reasoning: 'Standard maintenance request',\n      keywords_detected: [],\n      safety_concern: false,\n      habitability_issue: false\n    },\n    estimatedComplexity: {\n      level: 'moderate',\n      estimated_hours: 2,\n      requires_specialist: false\n    },\n    recommendedVendor: {\n      type: 'handyman',\n      urgency: 'within_24h',\n      specialization_needed: 'General repair'\n    },\n    cost_estimate: {\n      range: '$100 - $300',\n      factors: ['Labor', 'Materials']\n    },\n    tenant_communication: {\n      initial_response: 'We have received your request and are assigning a technician.',\n      estimated_resolution: '24-48 hours',\n      temporary_solutions: []\n    },\n    safety_protocols: ['Standard safety procedures'],\n    recurring_issue_check: {\n      likely_recurring: false,\n      warranty_applicable: false,\n      preventive_recommendation: 'Regular maintenance'\n    },\n    contractor_instructions: ['Assess issue', 'Provide quote if major repair needed'],\n    legal_compliance: {\n      urgent_legal_requirement: false,\n      habitability_law_concern: false,\n      documentation_needed: 'Before/after photos'\n    }\n  };\n}\n\n// Determine work order priority\nconst priorityMap = {\n  'emergency': 1,\n  'urgent': 2,\n  'high': 3,\n  'normal': 4,\n  'low': 5\n};\n\n// Select contractor based on vendor type\nconst contractorDatabase = {\n  'plumber': { name: 'QuickFix Plumbing', phone: '+1-555-PLUMB', email: 'user@example.com' },\n  'electrician': { name: 'Bright Spark Electric', phone: '+1-555-SPARK', email: 'user@example.com' },\n  'hvac_tech': { name: 'Cool Breeze HVAC', phone: '+1-555-HVAC1', email: 'user@example.com' },\n  'handyman': { name: 'All-Fix Handyman', phone: '+1-555-FIX-IT', email: 'user@example.com' },\n  'locksmith': { name: '24/7 Locksmith', phone: '+1-555-LOCKS', email: 'user@example.com' },\n  'pest_control': { name: 'No-Bug Pest Control', phone: '+1-555-BUGS0', email: 'user@example.com' },\n  'general_contractor': { name: 'BuildRight Contractors', phone: '+1-555-BUILD', email: 'user@example.com' }\n};\n\nconst vendorType = aiAnalysis.recommendedVendor.type;\nconst contractor = contractorDatabase[vendorType] || contractorDatabase['handyman'];\n\nreturn {\n  json: {\n    ...requestData,\n    issueCategory: aiAnalysis.issueCategory.primary,\n    subCategories: aiAnalysis.issueCategory.secondary,\n    aiConfidence: aiAnalysis.issueCategory.confidence,\n    finalPriority: aiAnalysis.priorityAssessment.level,\n    priorityNumber: priorityMap[aiAnalysis.priorityAssessment.level] || 4,\n    priorityReasoning: aiAnalysis.priorityAssessment.reasoning,\n    keywordsDetected: aiAnalysis.priorityAssessment.keywords_detected,\n    safetyConcern: aiAnalysis.priorityAssessment.safety_concern,\n    habitabilityIssue: aiAnalysis.priorityAssessment.habitability_issue,\n    complexity: aiAnalysis.estimatedComplexity.level,\n    estimatedHours: aiAnalysis.estimatedComplexity.estimated_hours,\n    requiresSpecialist: aiAnalysis.estimatedComplexity.requires_specialist,\n    vendorType: vendorType,\n    vendorUrgency: aiAnalysis.recommendedVendor.urgency,\n    specialization: aiAnalysis.recommendedVendor.specialization_needed,\n    costEstimate: aiAnalysis.cost_estimate.range,\n    costFactors: aiAnalysis.cost_estimate.factors,\n    tenantMessage: aiAnalysis.tenant_communication.initial_response,\n    estimatedResolution: aiAnalysis.tenant_communication.estimated_resolution,\n    temporarySolutions: aiAnalysis.tenant_communication.temporary_solutions,\n    safetyProtocols: aiAnalysis.safety_protocols,\n    likelyRecurring: aiAnalysis.recurring_issue_check.likely_recurring,\n    warrantyApplicable: aiAnalysis.recurring_issue_check.warranty_applicable,\n    preventiveRecommendation: aiAnalysis.recurring_issue_check.preventive_recommendation,\n    contractorInstructions: aiAnalysis.contractor_instructions,\n    legalUrgent: aiAnalysis.legal_compliance.urgent_legal_requirement,\n    habitabilityLaw: aiAnalysis.legal_compliance.habitability_law_concern,\n    documentationNeeded: aiAnalysis.legal_compliance.documentation_needed,\n    assignedContractor: contractor.name,\n    contractorPhone: contractor.phone,\n    contractorEmail: contractor.email,\n    workOrderNumber: 'WO-' + Date.now(),\n    aiSummary: `${aiAnalysis.issueCategory.primary} issue - ${aiAnalysis.priorityAssessment.level} priority. ${aiAnalysis.priorityAssessment.reasoning}`\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "4e267be8-b8a5-46de-9598-303dbe3e0481",
      "name": "Is Emergency?",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "condition1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.finalPriority }}",
              "rightValue": "emergency"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "43d6ddfb-7629-4fa2-86bd-1bc09f3a953c",
      "name": "Emergency Email to Contractor",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1008,
        512
      ],
      "parameters": {
        "sendTo": "={{ $json.contractorEmail }}",
        "message": "=\ud83d\udea8 EMERGENCY MAINTENANCE REQUEST\n\nWork Order: {{ $json.workOrderNumber }}\nPriority: EMERGENCY\nCategory: {{ $json.issueCategory }}\n\n\ud83d\udccd PROPERTY DETAILS:\nAddress: {{ $json.propertyAddress }}\nUnit: {{ $json.unitNumber }}\n\n\ud83d\udc64 TENANT CONTACT:\nName: {{ $json.tenantName }}\nPhone: {{ $json.tenantPhone }}\nEmail: {{ $json.tenantEmail }}\nPreferred Contact: {{ $json.preferredContactMethod }}\n\n\ud83d\udd27 ISSUE DESCRIPTION:\n{{ $json.issueDescription }}\n\n\ud83e\udd16 AI ANALYSIS:\nCategory: {{ $json.issueCategory }}\nComplexity: {{ $json.complexity }}\nEstimated Hours: {{ $json.estimatedHours }}\nCost Estimate: {{ $json.costEstimate }}\n\n\u26a0\ufe0f PRIORITY ASSESSMENT:\n{{ $json.priorityReasoning }}\nSafety Concern: {{ $json.safetyConcern ? 'YES \u26a0\ufe0f' : 'No' }}\nHabitability Issue: {{ $json.habitabilityIssue ? 'YES - URGENT' : 'No' }}\n\n\ud83d\udd11 ACCESS INSTRUCTIONS:\n{{ $json.accessInstructions }}\n\n\ud83d\udccb CONTRACTOR INSTRUCTIONS:\n{{ $json.contractorInstructions.map((inst, i) => (i + 1) + '. ' + inst).join('\\n') }}\n\n\ud83d\udee1\ufe0f SAFETY PROTOCOLS:\n{{ $json.safetyProtocols.map((protocol, i) => (i + 1) + '. ' + protocol).join('\\n') }}\n\n\ud83d\udcf8 PHOTO: {{ $json.photoUrl || 'No photo provided' }}\n\n\u23f1\ufe0f RESPONSE REQUIRED: IMMEDIATE\nEstimated Resolution: {{ $json.estimatedResolution }}\n\n\ud83d\udcdd DOCUMENTATION REQUIRED:\n{{ $json.documentationNeeded }}\n\n{{ $json.legalUrgent ? '\u2696\ufe0f LEGAL COMPLIANCE URGENT - This repair may be legally required under habitability laws.' : '' }}\n\nPlease respond immediately with ETA.\n\nProperty Management Team\n---\nThis is an AI-enhanced emergency dispatch",
        "options": {},
        "subject": "=\ud83d\udea8 EMERGENCY WORK ORDER - {{ $json.workOrderNumber }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "ea9fd8e1-825f-4438-9fc5-46900019e0bc",
      "name": "Standard Email to Contractor",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1008,
        800
      ],
      "parameters": {
        "sendTo": "={{ $json.contractorEmail }}",
        "message": "=\ud83d\udccb MAINTENANCE WORK ORDER\n\nWork Order: {{ $json.workOrderNumber }}\nPriority: {{ $json.finalPriority.toUpperCase() }}\nCategory: {{ $json.issueCategory }}\nRequested: {{ $json.submittedAt }}\n\n\ud83d\udccd PROPERTY DETAILS:\nAddress: {{ $json.propertyAddress }}\nUnit: {{ $json.unitNumber }}\n\n\ud83d\udc64 TENANT CONTACT:\nName: {{ $json.tenantName }}\nPhone: {{ $json.tenantPhone }}\nEmail: {{ $json.tenantEmail }}\nPreferred Contact: {{ $json.preferredContactMethod }}\n\n\ud83d\udd27 ISSUE DESCRIPTION:\n{{ $json.issueDescription }}\n\n\ud83e\udd16 AI ANALYSIS:\nCategory: {{ $json.issueCategory }} ({{ $json.subCategories.join(', ') }})\nConfidence: {{ $json.aiConfidence }}%\nComplexity: {{ $json.complexity }}\nEstimated Hours: {{ $json.estimatedHours }}\nCost Estimate: {{ $json.costEstimate }}\nSpecialization: {{ $json.specialization }}\n\n\ud83d\udca1 AI INSIGHTS:\n{{ $json.aiSummary }}\n\n\ud83d\udd11 ACCESS INSTRUCTIONS:\n{{ $json.accessInstructions }}\n\n\ud83d\udccb CONTRACTOR INSTRUCTIONS:\n{{ $json.contractorInstructions.map((inst, i) => (i + 1) + '. ' + inst).join('\\n') }}\n\n\ud83d\udee1\ufe0f SAFETY PROTOCOLS:\n{{ $json.safetyProtocols.map((protocol, i) => (i + 1) + '. ' + protocol).join('\\n') }}\n\n\ud83d\udcf8 PHOTO: {{ $json.photoUrl || 'No photo provided' }}\n\n\u23f1\ufe0f TARGET RESPONSE TIME: {{ $json.vendorUrgency }}\nEstimated Resolution: {{ $json.estimatedResolution }}\n\n\ud83d\udcdd DOCUMENTATION REQUIRED:\n{{ $json.documentationNeeded }}\n- Before photos\n- After photos\n- Parts/materials used\n- Time spent\n- Any additional issues found\n\n{{ $json.warrantyApplicable ? '\ud83d\udd27 WARRANTY CHECK: This may be under warranty - please verify before proceeding.' : '' }}\n\n{{ $json.likelyRecurring ? '\ud83d\udd04 RECURRING ISSUE ALERT: Similar issues may have been reported. Check history.' : '' }}\n\n\ud83d\udca1 PREVENTIVE RECOMMENDATION:\n{{ $json.preventiveRecommendation }}\n\nPlease confirm receipt and provide ETA.\n\nBest regards,\nProperty Management Team\n\n---\nThis work order was generated using AI analysis for optimal routing and prioritization.",
        "options": {},
        "subject": "=Work Order: {{ $json.workOrderNumber }} - {{ $json.issueCategory }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "06d7272f-ee56-4acd-9731-344995d4e56e",
      "name": "Send Tenant Confirmation",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1344,
        480
      ],
      "parameters": {
        "sendTo": "={{ $('Jotform Trigger').item.json['tenant Email'] }}",
        "message": "=Hi, {{ $('Jotform Trigger').item.json['tenant Name'].first }}\n\nThank you for submitting your maintenance request. We've received your report and are taking immediate action.\n\n\ud83d\udccb **Your Request Details:**\nRequest ID: {{ $json.requestId }}\nUnit: {{ $json.unitNumber }}\nIssue: {{ $json.issueCategory }}\nPriority: {{ $json.finalPriority.toUpperCase() }}\n\n\ud83e\udd16 **AI Analysis Results:**\n{{ $json.tenantMessage }}\n\n\ud83d\udd27 **What's Happening Next:**\n\u2022 A {{ $json.vendorType.replace('_', ' ') }} has been assigned\n\u2022 Contractor: {{ $json.assignedContractor }}\n\u2022 Expected Response: {{ $json.vendorUrgency.replace('_', ' ') }}\n\u2022 Estimated Resolution: {{ $json.estimatedResolution }}\n\u2022 Cost Estimate: {{ $json.costEstimate }}\n\n{{ $json.temporarySolutions.length > 0 ? '\ud83d\udca1 **Temporary Solutions (while you wait):**\\n' + $json.temporarySolutions.map((sol, i) => (i + 1) + '. ' + sol).join('\\n') + '\\n\\n' : '' }}\n\n{{ $json.safetyConcern ? '\u26a0\ufe0f **SAFETY NOTICE:**\\nThis issue involves a potential safety concern. ' + ($json.finalPriority === 'emergency' ? 'A contractor has been dispatched immediately.' : 'Please follow any safety precautions mentioned.') + '\\n\\n' : '' }}\n\n{{ $json.habitabilityIssue ? '\ud83c\udfe0 **IMPORTANT:**\\nThis issue affects the habitability of your unit. We are prioritizing this repair to ensure your home remains safe and comfortable.\\n\\n' : '' }}\n\n\ud83d\udcf1 **Need Immediate Help?**\n{{ $json.finalPriority === 'emergency' ? 'For this emergency, contact us directly at: (555) 123-4567\\n\\n' : 'If the situation worsens, call our emergency line: (555) 123-4567\\n\\n' }}\n\n\ud83d\udcf8 **Documentation:**\nWe've received your photo and it's been shared with the contractor. They will document the repair process with before/after photos.\n\n\ud83d\udd14 **Updates:**\nYou'll receive updates when:\n\u2022 The contractor confirms their ETA\n\u2022 Work begins\n\u2022 Work is completed\n\u2022 Follow-up is needed\n\n{{ $json.likelyRecurring ? '\ud83d\udcca **Note:** Our system detected this may be related to previous issues. We\\'re investigating to prevent future occurrences.\\n\\n' : '' }}\n\nThank you for your patience. We're committed to resolving this quickly and professionally.\n\nBest regards,\nYour Property Management Team\n\n---\nRequest tracked by AI-powered maintenance system\nWork Order: {{ $json.workOrderNumber }}",
        "options": {},
        "subject": "=\u2705 Maintenance Request Received - {{ $('Parse Request Data').item.json.requestId }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "32332f95-bac9-40ae-88f5-4a29053b7469",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1744,
        560
      ],
      "parameters": {
        "columns": {
          "value": {
            "photo Url": "={{ $('Jotform Trigger').item.json['photo Url'] }}",
            "client Name": "={{ $('Jotform Trigger').item.json['tenant Name'].first }}",
            "unit Number": "={{ $('Jotform Trigger').item.json['unit Number'] }}",
            "tenant Email": "={{ $('Jotform Trigger').item.json['tenant Email'] }}",
            "tenant Phone": "={{ $('Jotform Trigger').item.json['tenant Phone'].full }}",
            "urgency Level": "={{ $('Jotform Trigger').item.json['urgency Level'] }}",
            "property Address": "={{ $('Jotform Trigger').item.json['property Address'] }}",
            "issue Description": "={{ $('Jotform Trigger').item.json['issue Description'] }}",
            "access Instructions": "={{ $('Jotform Trigger').item.json['access Instructions'] }}",
            "preferred Contact Method": "={{ $('Jotform Trigger').item.json['preferred Contact Method'] }}"
          },
          "schema": [
            {
              "id": "client Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "client Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "tenant Phone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tenant Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "tenant Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "tenant Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "unit Number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "unit Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "property Address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "property Address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "issue Description",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "issue Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "urgency Level",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "urgency Level",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "photo Url",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "photo Url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "access Instructions",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "access Instructions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "preferred Contact Method",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "preferred Contact Method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "threadId",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "threadId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "labelIds",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "labelIds",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "tenant Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw/edit?usp=drivesdk",
          "cachedResultName": "property "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "e6d7a830-a24f-41b1-a48f-9d6c828e7c5e",
      "name": "Track Recurring Issues",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1760,
        768
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "unitNumber",
            "issueCategory"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 106049282,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw/edit#gid=106049282",
          "cachedResultName": "Recurring issue"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-QwkdSMflsGtVCJEWvDnjT65cSzwv9CdQ3Stfv4ywtw/edit?usp=drivesdk",
          "cachedResultName": "property "
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "d673125a-f88e-4e8a-a45e-1cf23b70f614",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        320
      ],
      "parameters": {
        "width": 304,
        "height": 832,
        "content": "\ud83d\udce9 **TRIGGER: Maintenance Request**\n\nCaptures tenant maintenance requests via Jotform:\n\n**Required Fields:**\n\u2022 Tenant name, email, phone\n\u2022 Unit number & property address\n\u2022 Issue description (long text)\n\u2022 Urgency level (dropdown)\n\u2022 Photo upload\n\u2022 Access instructions\n\u2022 Preferred contact method\n\n**Form Setup:**\nCreate form at [JotForm](https://www.jotform.com/?partner=mediajade)\n\n**Field Types:**\n- Single line text\n- Email\n- Phone number\n- Long text (description)\n- Dropdown (urgency: emergency, urgent, normal)\n- File upload (photo)\n- Textarea (access info)"
      },
      "typeVersion": 1
    },
    {
      "id": "4d97a799-fa71-4e7e-823c-be6b88b13659",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        128
      ],
      "parameters": {
        "width": 256,
        "height": 608,
        "content": "\ud83e\uddfe **PARSE REQUEST DATA**\n\nNormalizes maintenance request from Jotform.\n\nHandles various field formats and creates standardized request object.\n\nGenerates unique request ID for tracking."
      },
      "typeVersion": 1
    },
    {
      "id": "93b4e207-6c42-4b6f-8623-38749370d67a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        -64
      ],
      "parameters": {
        "width": 368,
        "height": 880,
        "content": "\ud83e\udd16 **AI MAINTENANCE ANALYSIS**\n\n**Advanced AI Agent categorizes and prioritizes:**\n\n\u2705 **Issue Categorization**\n- Primary category (plumbing, electrical, HVAC, etc.)\n- Secondary sub-categories\n- Confidence scoring\n\n\u2705 **Priority Assessment**\n- Emergency keywords detection\n- Safety concern flagging\n- Habitability issue identification\n- Legal compliance checking\n\n\u2705 **Vendor Recommendation**\n- Optimal contractor type\n- Required specialization\n- Urgency level for dispatch\n\n\u2705 **Complexity Analysis**\n- Simple/moderate/complex/major\n- Estimated hours\n- Specialist requirement\n\n\u2705 **Cost Estimation**\n- Budget range\n- Cost factors\n\n\u2705 **Smart Communication**\n- Tenant messaging\n- Contractor instructions\n- Safety protocols\n\n\u2705 **Preventive Intelligence**\n- Recurring issue detection\n- Warranty applicability\n- Prevention recommendations\n\n**AI Model:** GPT-4 for accuracy"
      },
      "typeVersion": 1
    },
    {
      "id": "e4aef349-fe72-408c-ac54-821a48b12a2a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        304
      ],
      "parameters": {
        "width": 208,
        "height": 240,
        "content": "\ud83d\udd17 **EXTRACT AI RESPONSE**\n\nExtracts structured JSON from AI Agent.\n\nPrepares data for merging with request details."
      },
      "typeVersion": 1
    },
    {
      "id": "cc77d5b4-9487-47e3-aa42-956cf9654705",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        32
      ],
      "parameters": {
        "width": 288,
        "height": 560,
        "content": "\ud83e\udde9 **MERGE AI ANALYSIS**\n\n**Intelligent data fusion:**\n\n\u2022 Combines request with AI insights\n\u2022 Selects appropriate contractor from database\n\u2022 Generates work order number\n\u2022 Calculates priority scores\n\u2022 Handles parsing errors gracefully\n\n**Contractor Database:**\n- Plumber\n- Electrician\n- HVAC Technician\n- Handyman\n- Locksmith\n- Pest Control\n- General Contractor\n\nEach with contact details for auto-routing!"
      },
      "typeVersion": 1
    },
    {
      "id": "62884b2a-6dad-4ffe-b366-6e9f8b392b4e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        48
      ],
      "parameters": {
        "width": 304,
        "height": 400,
        "content": "\u26a1 **EMERGENCY ROUTING**\n\nChecks if issue is emergency priority.\n\n**TRUE:** Sends urgent dispatch email\n**FALSE:** Sends standard work order\n\nEmergency emails include:\n- Immediate response required\n- Safety protocols highlighted\n- Legal compliance notices\n- Direct phone contact"
      },
      "typeVersion": 1
    },
    {
      "id": "dda2bd81-b8db-43f6-84f6-fdfb841caecc",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        16
      ],
      "parameters": {
        "width": 304,
        "height": 640,
        "content": "\ud83d\udce7 **CONTRACTOR DISPATCH**\n\n**Emergency Email:**\n\ud83d\udea8 Immediate attention required\n- All critical details\n- Safety protocols\n- Legal compliance notes\n- Requires immediate ETA response\n\n**Standard Work Order:**\n\ud83d\udccb Comprehensive work order\n- Complete AI analysis\n- Contractor instructions\n- Documentation requirements\n- Preventive recommendations\n\nBoth include:\n- Tenant contact info\n- Access instructions\n- Photo links\n- Cost estimates\n- AI insights"
      },
      "typeVersion": 1
    },
    {
      "id": "35e4f6d8-065e-43a3-9a5b-c9777c106dfd",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        16
      ],
      "parameters": {
        "width": 304,
        "height": 640,
        "content": "\u2709\ufe0f **TENANT CONFIRMATION**\n\n**Professional acknowledgment email:**\n\n\u2705 Request received confirmation\n\u2705 AI analysis summary\n\u2705 Assigned contractor details\n\u2705 Estimated timeline\n\u2705 Temporary solutions (if applicable)\n\u2705 Safety notices (if relevant)\n\u2705 Habitability alerts (if urgent)\n\u2705 Emergency contact info\n\u2705 Update schedule\n\n**Dynamic Content:**\n- Emergency vs standard messaging\n- Safety warnings when flagged\n- Temp solutions from AI\n- Recurring issue notifications\n\nBuilds trust with transparency!"
      },
      "typeVersion": 1
    },
    {
      "id": "3317297d-26bd-470a-af8e-46244483f1aa",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        -64
      ],
      "parameters": {
        "width": 336,
        "height": 1040,
        "content": "\ud83d\udcca **GOOGLE SHEETS LOGGING**\n\n**Main Request Log:**\nTracks all maintenance requests with:\n- Request & work order IDs\n- Tenant details\n- Issue categorization\n- AI analysis results\n- Priority assessment\n- Contractor assignment\n- Cost estimates\n- Status tracking\n\n**Recurring Issues Tracker:**\nSeparate sheet for pattern analysis:\n- Unit number\n- Issue category\n- Occurrence dates\n- Preventive recommendations\n\n**Analytics Ready:**\n\u2713 Response time metrics\n\u2713 Contractor performance\n\u2713 Cost analysis\n\u2713 Recurring issue identification\n\u2713 Tenant satisfaction tracking\n\u2713 AI accuracy measurement\n\nConnect to Data Studio for dashboards!"
      },
      "typeVersion": 1
    },
    {
      "id": "7c773bbd-4bd0-427b-8a1c-e97c7822b1b3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -304,
        976
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5661c7cd-d26d-4170-9b40-f62a005ded25",
      "name": "Jotform Trigger",
      "type": "n8n-nodes-base.jotFormTrigger",
      "position": [
        -880,
        912
      ],
      "parameters": {
        "form": "252864531445460"
      },
      "credentials": {
        "jotFormApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Is Emergency?": {
      "main": [
        [
          {
            "node": "Emergency Email to Contractor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Standard Email to Contractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Jotform Trigger": {
      "main": [
        [
          {
            "node": "Parse Request Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Analysis": {
      "main": [
        [
          {
            "node": "Is Emergency?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Maintenance Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Request Data": {
      "main": [
        [
          {
            "node": "AI Maintenance Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract AI Response": {
      "main": [
        [
          {
            "node": "Merge AI Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Maintenance Analysis": {
      "main": [
        [
          {
            "node": "Extract AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Tenant Confirmation": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Track Recurring Issues",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Standard Email to Contractor": {
      "main": [
        [
          {
            "node": "Send Tenant Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Emergency Email to Contractor": {
      "main": [
        [
          {
            "node": "Send Tenant Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}