{
  "name": "Quote Requests — AI Triage",
  "nodes": [
    {
      "parameters": {
        "pollTimes": { "item": [ { "mode": "everyMinute" } ] },
        "simple": false,
        "filters": { "labelIds": [ "Label_4419273" ] },
        "options": {}
      },
      "id": "a1f0c2d4-1111-4a6b-9c01-5e2f7a9b0c01",
      "name": "New email in Quotes",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [0, 300],
      "credentials": { "gmailOAuth2": { "id": "gm01HRT", "name": "Gmail – quotes@hartley" } }
    },
    {
      "parameters": {
        "modelId": { "__rl": true, "value": "gpt-4.1-mini", "mode": "list", "cachedResultName": "GPT-4.1-MINI" },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are the intake assistant for Hartley Renovations, Dublin. From the customer email, extract: name, phone, email, address, project_type (bathroom | kitchen | extension | other), budget_eur (number or null), urgency (low | medium | high), is_quote_request (true/false). Then score the lead from 0 to 100 (fit, budget, urgency). Our typical prices: bathroom refit from €6,500; kitchen from €12,000; extension from €45,000. Reply with JSON only."
            },
            {
              "content": "=Subject: {{ $json.subject }}\n\n{{ $json.text }}"
            }
          ]
        },
        "options": { "temperature": 0.2 }
      },
      "id": "a1f0c2d4-2222-4a6b-9c01-5e2f7a9b0c02",
      "name": "Extract & score request",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [220, 300],
      "credentials": { "openAiApi": { "id": "oa01HRT", "name": "OpenAI – Hartley" } }
    },
    {
      "parameters": {
        "jsCode": "// Turn the AI answer into fields\nconst email = $('New email in Quotes').item.json;\nconst data = JSON.parse($json.message.content);\n\ndata.priority = data.score >= 70 ? 'hot' : 'normal';\ndata.threadId = email.threadId;\ndata.messageId = email.id;\ndata.receivedAt = new Date().toISOString();\n\nreturn [{ json: data }];"
      },
      "id": "a1f0c2d4-3333-4a6b-9c01-5e2f7a9b0c03",
      "name": "Parse AI answer",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [440, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [
            {
              "id": "c0a1",
              "leftValue": "={{ $json.is_quote_request }}",
              "rightValue": true,
              "operator": { "type": "boolean", "operation": "true", "singleValue": true }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1f0c2d4-4444-4a6b-9c01-5e2f7a9b0c04",
      "name": "Is it a quote request?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [660, 300]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": { "__rl": true, "value": "1Hk7TqZ0bX3mRrLeadsHartley2026", "mode": "id" },
        "sheetName": { "__rl": true, "value": "gid=0", "mode": "list", "cachedResultName": "Leads" },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $json.receivedAt }}",
            "Name": "={{ $json.name }}",
            "Phone": "={{ $json.phone }}",
            "Email": "={{ $json.email }}",
            "Address": "={{ $json.address }}",
            "Project": "={{ $json.project_type }}",
            "Budget (€)": "={{ $json.budget_eur }}",
            "Urgency": "={{ $json.urgency }}",
            "Score": "={{ $json.score }}",
            "Priority": "={{ $json.priority }}",
            "Status": "New"
          }
        },
        "options": {}
      },
      "id": "a1f0c2d4-5555-4a6b-9c01-5e2f7a9b0c05",
      "name": "Add lead to CRM sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [880, 200],
      "credentials": { "googleSheetsOAuth2Api": { "id": "gs01HRT", "name": "Google Sheets – Hartley" } }
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [
            {
              "id": "c0a2",
              "leftValue": "={{ $('Parse AI answer').item.json.score }}",
              "rightValue": 70,
              "operator": { "type": "number", "operation": "gte" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1f0c2d4-6666-4a6b-9c01-5e2f7a9b0c06",
      "name": "High priority?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [1100, 100]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": { "__rl": true, "value": "C07HRTLY2Q1", "mode": "id" },
        "text": "=🔥 Hot lead: {{ $('Parse AI answer').item.json.name }} — {{ $('Parse AI answer').item.json.project_type }} — €{{ $('Parse AI answer').item.json.budget_eur }} — score {{ $('Parse AI answer').item.json.score }}",
        "otherOptions": {}
      },
      "id": "a1f0c2d4-7777-4a6b-9c01-5e2f7a9b0c07",
      "name": "Alert sales on Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [1320, 100],
      "credentials": { "slackOAuth2Api": { "id": "sl01HRT", "name": "Slack – Hartley" } }
    },
    {
      "parameters": {
        "modelId": { "__rl": true, "value": "gpt-4.1-mini", "mode": "list", "cachedResultName": "GPT-4.1-MINI" },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Write a short, warm reply on behalf of Hartley Renovations, in the customer's language. Thank them, confirm we received their request, propose a free site visit next week, and give our typical price range for their project: bathroom refit from €6,500; kitchen from €12,000; extension from €45,000. Sign as 'The Hartley team'."
            },
            {
              "content": "=Customer: {{ $('Parse AI answer').item.json.name }}\nProject: {{ $('Parse AI answer').item.json.project_type }}\nBudget: {{ $('Parse AI answer').item.json.budget_eur }}"
            }
          ]
        },
        "options": { "temperature": 0.6 }
      },
      "id": "a1f0c2d4-8888-4a6b-9c01-5e2f7a9b0c08",
      "name": "Write reply with AI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [1100, 300],
      "credentials": { "openAiApi": { "id": "oa01HRT", "name": "OpenAI – Hartley" } }
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "=Re: your renovation request",
        "message": "={{ $json.message.content }}",
        "options": {
          "threadId": "={{ $('Parse AI answer').item.json.threadId }}",
          "sendTo": "={{ $('Parse AI answer').item.json.email }}"
        }
      },
      "id": "a1f0c2d4-9999-4a6b-9c01-5e2f7a9b0c09",
      "name": "Save reply as Gmail draft",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1320, 300],
      "credentials": { "gmailOAuth2": { "id": "gm01HRT", "name": "Gmail – quotes@hartley" } }
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Parse AI answer').item.json.messageId }}",
        "labelIds": [ "Label_7781020" ]
      },
      "id": "a1f0c2d4-aaaa-4a6b-9c01-5e2f7a9b0c10",
      "name": "Label as Other",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [880, 420],
      "credentials": { "gmailOAuth2": { "id": "gm01HRT", "name": "Gmail – quotes@hartley" } }
    },
    {
      "parameters": {
        "content": "## Quote triage (v2)\n- New emails in **Quotes** are read by AI and scored.\n- Hot leads (70+) go to #sales-hot on Slack.\n- Customers get an instant AI reply (sent automatically).",
        "height": 200,
        "width": 520
      },
      "id": "a1f0c2d4-bbbb-4a6b-9c01-5e2f7a9b0c11",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [0, 0]
    }
  ],
  "pinData": {},
  "connections": {
    "New email in Quotes": { "main": [ [ { "node": "Extract & score request", "type": "main", "index": 0 } ] ] },
    "Extract & score request": { "main": [ [ { "node": "Parse AI answer", "type": "main", "index": 0 } ] ] },
    "Parse AI answer": { "main": [ [ { "node": "Is it a quote request?", "type": "main", "index": 0 } ] ] },
    "Is it a quote request?": {
      "main": [
        [ { "node": "Add lead to CRM sheet", "type": "main", "index": 0 } ],
        [ { "node": "Label as Other", "type": "main", "index": 0 } ]
      ]
    },
    "Add lead to CRM sheet": {
      "main": [
        [
          { "node": "High priority?", "type": "main", "index": 0 },
          { "node": "Write reply with AI", "type": "main", "index": 0 }
        ]
      ]
    },
    "High priority?": { "main": [ [ { "node": "Alert sales on Slack", "type": "main", "index": 0 } ], [] ] },
    "Write reply with AI": { "main": [ [ { "node": "Save reply as Gmail draft", "type": "main", "index": 0 } ] ] }
  },
  "active": true,
  "settings": { "executionOrder": "v1" },
  "versionId": "3a91f0c2-7d5e-4b8a-a1c3-2f9e6d4b8c70",
  "id": "QtR8hartleyAI01",
  "tags": [ { "name": "client: Hartley" } ]
}
