{ "name": "Lead Classifier", "nodes": [ { "parameters": {}, "id": "1efd4a3a-08e0-4ee6-b499-9d9c6a29fe05", "name": "Start", "type": "n8n-nodes-base.manualTrigger", "typeVersion": 1, "position": [ 192, -144 ] }, { "parameters": { "promptType": "define", "text": "=Classify this lead as hot, warm, or cold based on the following criteria:\nHOT: High budget (>$25k), immediate timeline (within 1-3 months), high engagement, decision maker involved\nWARM: Medium budget ($10k-$25k), timeline 3-6 months, moderate engagement, some decision maker contact\nCOLD: Low budget (<$10k), timeline >6 months or unclear, low engagement, no decision maker contact\n\nLead Details:\nName: {{ $json.Name }}\nCompany: {{ $json.Company }}\nRole: {{ $json.Role }}\nBudget Range: {{ $json[\"Budget Range\"] }}\nTimeline: {{ $json.Timeline }}\nInquiry: {{ $json.Inquiry }}\nIntent Signals: {{ $json[\"Intent Signals\"] }}\nIndustry: {{ $json.Industry }}\nEmployees: {{ $json.Employees }}\n\nProvide classification (hot/warm/cold), confidence score (0-1), and brief reasoning.\n\nAlso include these fields in your response exactly as provided:\nname: {{ $json.Name }}\nemail: {{ $json.Email }}\ncompany: {{ $json.Company }}\nrole: {{ $json.Role }}", "hasOutputParser": true, "options": { "systemMessage": "You are a sales lead qualification expert. Analyze leads objectively and classify them accurately based on the provided criteria." } }, "id": "d55512c3-1e0a-40e6-90d1-fa8b85c48518", "name": "Classify Lead", "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 3.1, "position": [ 864, -144 ] }, { "parameters": { "model": { "__rl": true, "value": "gpt-5-mini", "mode": "list", "cachedResultName": "gpt-5-mini" }, "builtInTools": {}, "options": {} }, "id": "09f398bc-df03-4f63-8696-729c098d36ae", "name": "OpenAI Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "typeVersion": 1.3, "position": [ 864, 160 ], "credentials": { "openAiApi": { "id": "8TsZKHzHiFGz3qUr", "name": "n8n free OpenAI API credits" } } }, { "parameters": { "jsonSchemaExample": "{\n \"classification\": \"hot\",\n \"confidence\": 0.95,\n \"reasoning\": \"High budget, immediate timeline, and high engagement indicate strong buying intent\",\n \"name\": \"Rahul Sharma\",\n \"email\": \"rahul@acme.com\",\n \"company\": \"Acme Tech\",\n \"role\": \"CTO\"\n}" }, "id": "a17eb058-82b8-4719-85ee-e764d46fc237", "name": "Classification Parser", "type": "@n8n/n8n-nodes-langchain.outputParserStructured", "typeVersion": 1.3, "position": [ 1008, 80 ] }, { "parameters": { "operation": "download", "fileId": { "__rl": true, "value": "15RRzm7-y-NVKdqcCHkH8KAoy3rMBy0CM", "mode": "list", "cachedResultName": "sample_lead_classifier_dataset (1).xlsx", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/15RRzm7-y-NVKdqcCHkH8KAoy3rMBy0CM/edit?usp=drivesdk&ouid=116344764654877516442&rtpof=true&sd=true" }, "options": { "googleFileConversion": { "conversion": { "sheetsToFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" } } } }, "id": "358ded0f-5690-4c34-8ac9-3982f6640cff", "name": "Download Spreadsheet", "type": "n8n-nodes-base.googleDrive", "typeVersion": 3, "position": [ 416, -144 ], "credentials": { "googleDriveOAuth2Api": { "id": "mXbUEmkgYiOKdmU3", "name": "Google Drive account" } } }, { "parameters": { "operation": "xlsx", "options": { "headerRow": true } }, "id": "a0c768d9-ca9f-4780-a99f-4a255f5e2bc1", "name": "Extract Leads", "type": "n8n-nodes-base.extractFromFile", "typeVersion": 1.1, "position": [ 640, -144 ] }, { "parameters": { "jsCode": "const items = $input.all();\n\nconst leads = items.map(item => {\n const o = item.json.output || {};\n return {\n name: o.name || '-',\n company: o.company || '-',\n role: o.role || '-',\n email: o.email || '-',\n classification: o.classification || '-',\n confidence: o.confidence || 0,\n reasoning: o.reasoning || '-'\n };\n});\n\nconst hotLeads = leads.filter(l => l.classification === 'hot');\nconst warmLeads = leads.filter(l => l.classification === 'warm');\nconst coldLeads = leads.filter(l => l.classification === 'cold');\n\nconst renderRows = (arr) => arr.map(l => `\n \n ${l.name}\n ${l.company}\n ${l.role}\n ${l.email}\n ${Math.round(l.confidence * 100)}%\n ${l.reasoning}\n `).join('');\n\nconst header = `\n Name\n Company\n Role\n Email\n Confidence\n Reasoning\n`;\n\nconst html = `\n\n

Lead Classification Dashboard

\n
\n
🔥 Hot: ${hotLeads.length}
\n
☀️ Warm: ${warmLeads.length}
\n
❄️ Cold: ${coldLeads.length}
\n
\n

🔥 Hot Leads

\n \n ${header}${renderRows(hotLeads)}\n
\n

☀️ Warm Leads

\n \n ${header}${renderRows(warmLeads)}\n
\n

❄️ Cold Leads

\n \n ${header}${renderRows(coldLeads)}\n
\n`;\n\nreturn [{ json: { html, hotLeads, warmLeads, coldLeads, total: leads.length } }];" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1216, -144 ], "id": "abbeba88-805a-445b-ac95-f5911e504397", "name": "Code in JavaScript" }, { "parameters": { "html": "{{ $json.html }}" }, "type": "n8n-nodes-base.html", "typeVersion": 1.2, "position": [ 1440, -144 ], "id": "d2ad6204-b718-49fb-aaa2-c1fa0a680fb1", "name": "HTML" }, { "parameters": { "sendTo": "dhanj.pal@gmail.com", "subject": "Lead report", "message": "={{ $('HTML').item.json.html }}", "options": {} }, "type": "n8n-nodes-base.gmail", "typeVersion": 2.2, "position": [ 1648, -144 ], "id": "5142c865-597d-4a80-8664-5a6d0fc659cf", "name": "Send a message", "webhookId": "5fa2c38c-0a3e-4e93-a69e-d5f461c6e6f4", "credentials": { "gmailOAuth2": { "id": "i7qWga8Bii2LQLfh", "name": "Gmail account" } } } ], "pinData": {}, "connections": { "Start": { "main": [ [ { "node": "Download Spreadsheet", "type": "main", "index": 0 } ] ] }, "Classify Lead": { "main": [ [ { "node": "Code in JavaScript", "type": "main", "index": 0 } ] ] }, "OpenAI Model": { "ai_languageModel": [ [ { "node": "Classify Lead", "type": "ai_languageModel", "index": 0 } ] ] }, "Classification Parser": { "ai_outputParser": [ [ { "node": "Classify Lead", "type": "ai_outputParser", "index": 0 } ] ] }, "Download Spreadsheet": { "main": [ [ { "node": "Extract Leads", "type": "main", "index": 0 } ] ] }, "Extract Leads": { "main": [ [ { "node": "Classify Lead", "type": "main", "index": 0 } ] ] }, "Code in JavaScript": { "main": [ [ { "node": "HTML", "type": "main", "index": 0 } ] ] }, "HTML": { "main": [ [ { "node": "Send a message", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1", "binaryMode": "separate", "availableInMCP": false }, "versionId": "934e08a2-e411-41d5-a8ae-b355a6708dc5", "meta": { "templateCredsSetupCompleted": true, "instanceId": "d8972de2604eaae03f05ec7a0c35a421b929068460901453fd43a7f193028d62" }, "nodeGroups": [], "id": "4cHirOKqxvgCln1u", "tags": [] }