{
  "name": "Email Lead Qualifier",
  "nodes": [
    {
      "id": "t5-sticky-s0",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 1470,
        "height": 180,
        "content": "## Email Lead Qualifier\n\nReceive a lead form submission via webhook \u2192 score it **HOT / WARM / COLD** with Claude Haiku \u2192 route instantly: email alert for hot leads, Sheets log for warm leads, webhook response for all.\n\n**3-step setup:** \u2460 Add your **Anthropic API key** in the **Claude Haiku** sub-node \u00b7 \u2461 Enter your **notification email** in the **Alert: Email HOT Lead** node \u00b7 \u2462 Add your **Google Sheets document ID** in the **Log WARM Lead** node"
      },
      "typeVersion": 1
    },
    {
      "id": "t5-sticky-s1",
      "name": "Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        180,
        60
      ],
      "parameters": {
        "color": 4,
        "width": 730,
        "height": 824,
        "content": "## 1 \u2014 Receive Lead & Classify\nSend a **POST** request with: `name`, `email`, `company`, `message`\n\n**Claude Haiku** classifies the lead:\n- **HOT** \u2014 Urgent need, confirmed budget, decision-maker\n- **WARM** \u2014 Real interest, unclear need or no confirmed budget\n- **COLD** \u2014 Vague message, no identifiable need\n\n\u2192 Add your **Anthropic API key** in the **Claude Haiku** sub-node."
      },
      "typeVersion": 1
    },
    {
      "id": "t5-sticky-s2",
      "name": "Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        930,
        60
      ],
      "parameters": {
        "color": 6,
        "width": 720,
        "height": 680,
        "content": "## 2 \u2014 Route & Respond\n**HOT** \u2192 Instant Gmail alert with full lead details\n**WARM** \u2192 Lead logged to Google Sheets for follow-up\n**COLD** \u2192 No action taken, webhook response returned\n\n**Setup:**\n1. **Alert: Email HOT Lead** \u2014 enter your notification email in `Send To`\n2. **Log WARM Lead** \u2014 enter your Google Sheets document ID\n3. Connect **Gmail OAuth2** and **Google Sheets OAuth2** credentials"
      },
      "typeVersion": 1
    },
    {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "name": "Receive Lead",
      "type": "n8n-nodes-base.webhook",
      "position": [
        240,
        360
      ],
      "parameters": {
        "path": "lead-qualifier",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "name": "Set Lead Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        464,
        360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "field-name",
              "name": "name",
              "type": "string",
              "value": "={{ $json.body.name }}"
            },
            {
              "id": "field-email",
              "name": "email",
              "type": "string",
              "value": "={{ $json.body.email }}"
            },
            {
              "id": "field-company",
              "name": "company",
              "type": "string",
              "value": "={{ $json.body.company }}"
            },
            {
              "id": "field-message",
              "name": "message",
              "type": "string",
              "value": "={{ $json.body.message }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "name": "Score Lead with Claude",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        640,
        360
      ],
      "parameters": {
        "text": "={{ 'You are a B2B lead qualification expert.\\n\\nHere is the prospect information:\\nName: ' + $json.name + '\\nEmail: ' + $json.email + '\\nCompany: ' + $json.company + '\\nMessage: ' + $json.message + '\\n\\nClassify this lead as HOT, WARM, or COLD:\\n- HOT: urgent need, confirmed budget, decision-maker in direct contact, precise message\\n- WARM: real interest but vague need, no confirmed budget, or non-decision-maker\\n- COLD: vague message, no identifiable need\\n\\nRespond with a score (HOT, WARM, or COLD) and a one-sentence justification.' }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "d4e5f6a7-b8c9-0123-defa-234567890123",
      "name": "Claude Haiku",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        688,
        536
      ],
      "parameters": {
        "model": {
          "mode": "id",
          "value": "claude-haiku-4-5-20251001"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.5
    },
    {
      "id": "e5f6a7b8-c9d0-1234-efab-345678901234",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        688,
        664
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\"type\":\"object\",\"properties\":{\"score\":{\"type\":\"string\",\"enum\":[\"HOT\",\"WARM\",\"COLD\"]},\"justification\":{\"type\":\"string\"}},\"required\":[\"score\",\"justification\"]}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "f6a7b8c9-d0e1-2345-fabc-456789012345",
      "name": "Route by Score",
      "type": "n8n-nodes-base.switch",
      "position": [
        1000,
        360
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "HOT",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.score }}",
                    "rightValue": "HOT"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "WARM",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.score }}",
                    "rightValue": "WARM"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "a7b8c9d0-e1f2-3456-abcd-567890123456",
      "name": "Alert: Email HOT Lead",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1220,
        360
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<h2>New HOT Lead</h2><p><strong>Name:</strong> {{ $('Set Lead Fields').item.json.name }}</p><p><strong>Email:</strong> {{ $('Set Lead Fields').item.json.email }}</p><p><strong>Company:</strong> {{ $('Set Lead Fields').item.json.company }}</p><p><strong>Message:</strong> {{ $('Set Lead Fields').item.json.message }}</p><hr><p><strong>AI Score:</strong> HOT</p><p><strong>Justification:</strong> {{ $json.output.justification }}</p>",
        "options": {
          "appendAttribution": false
        },
        "subject": "=HOT Lead: {{ $('Set Lead Fields').item.json.name }} \u2014 {{ $('Set Lead Fields').item.json.company }}",
        "operation": "send"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b8c9d0e1-f2a3-4567-bcde-678901234567",
      "name": "Log WARM Lead",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1220,
        520
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $now.toISO() }}",
            "Name": "={{ $('Set Lead Fields').item.json.name }}",
            "Email": "={{ $('Set Lead Fields').item.json.email }}",
            "Status": "=WARM \u2014 {{ $json.output.justification }}",
            "Company": "={{ $('Set Lead Fields').item.json.company }}",
            "Message": "={{ $('Set Lead Fields').item.json.message }}"
          },
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "canBeUsedToMatch": false
            },
            {
              "id": "Name",
              "displayName": "Name",
              "canBeUsedToMatch": false
            },
            {
              "id": "Email",
              "displayName": "Email",
              "canBeUsedToMatch": false
            },
            {
              "id": "Company",
              "displayName": "Company",
              "canBeUsedToMatch": false
            },
            {
              "id": "Message",
              "displayName": "Message",
              "canBeUsedToMatch": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "mode": "id",
          "value": "0"
        },
        "documentId": {
          "mode": "id",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c9d0e1f2-a3b4-5678-cdef-789012345678",
      "name": "Return Score to Caller",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1440,
        420
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: true, score: $('Score Lead with Claude').item.json.output.score, justification: $('Score Lead with Claude').item.json.output.justification }) }}"
      },
      "typeVersion": 1.5
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  },
  "staticData": null,
  "connections": {
    "Claude Haiku": {
      "ai_languageModel": [
        [
          {
            "node": "Score Lead with Claude",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Receive Lead": {
      "main": [
        [
          {
            "node": "Set Lead Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log WARM Lead": {
      "main": [
        [
          {
            "node": "Return Score to Caller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Score": {
      "main": [
        [
          {
            "node": "Alert: Email HOT Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log WARM Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return Score to Caller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Lead Fields": {
      "main": [
        [
          {
            "node": "Score Lead with Claude",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert: Email HOT Lead": {
      "main": [
        [
          {
            "node": "Return Score to Caller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score Lead with Claude": {
      "main": [
        [
          {
            "node": "Route by Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Score Lead with Claude",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}