-
-
Save hervehobbes/5e67138707549a00382e8af8e0e10aee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "CRM", | |
| "nodes": [ | |
| { | |
| "parameters": { | |
| "httpMethod": "POST", | |
| "path": "19abde58-165d-4c1b-a955-d1dd41cb1235", | |
| "options": {} | |
| }, | |
| "type": "n8n-nodes-base.webhook", | |
| "typeVersion": 2.1, | |
| "position": [ | |
| -416, | |
| -80 | |
| ], | |
| "id": "99f50a56-9317-4494-81d0-da821b1bf4c6", | |
| "name": "Webhook", | |
| "webhookId": "19abde58-165d-4c1b-a955-d1dd41cb1235" | |
| }, | |
| { | |
| "parameters": { | |
| "modelId": { | |
| "__rl": true, | |
| "value": "models/gemini-2.5-flash-lite", | |
| "mode": "list", | |
| "cachedResultName": "models/gemini-2.5-flash-lite" | |
| }, | |
| "messages": { | |
| "values": [ | |
| { | |
| "content": "=You are a lead scoring expert for a digital automation agency.\n\nLead information from their enquiry form:\n- Name: {{ $json.name }}\n- Email: {{ $json.email }}\n- Company: {{ $json.company }}\n- Company size: {{ $json.size }}\n- Budget: {{ $json.budget }}\n- What they need: {{ $json.need }}\n\nScore this lead 1 to 10 and respond ONLY in this JSON format:\n{\n \"score\": 8,\n \"tier\": \"hot\",\n \"reason\": \"One sentence explanation\",\n \"suggested_action\": \"One sentence on what to do next\"\n}\n\nTier rules:\n- 7-10 = hot\n- 4-6 = warm\n- 1-3 = cold" | |
| } | |
| ] | |
| }, | |
| "builtInTools": {}, | |
| "options": {} | |
| }, | |
| "type": "@n8n/n8n-nodes-langchain.googleGemini", | |
| "typeVersion": 1.1, | |
| "position": [ | |
| 32, | |
| -80 | |
| ], | |
| "id": "743a8b0d-2975-494e-bddf-0a385e1ada63", | |
| "name": "Message a model", | |
| "credentials": { | |
| "googlePalmApi": { | |
| "id": "MBzpZF21WekU4cpL", | |
| "name": "Google Gemini(PaLM) Api account 2" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "mode": "runOnceForEachItem", | |
| "jsCode": "// Target the specific path where Gemini stores the message\nconst rawText = $json.content.parts[0].text.replace(/```json/gi, '').replace(/```/gi, '').trim();\n\nlet parsed;\ntry {\n parsed = JSON.parse(rawText);\n} catch(e) {\n parsed = {\n score: 5,\n tier: \"warm\",\n reason: \"Could not parse AI response\",\n suggested_action: \"Manual review needed\"\n };\n}\n\n// Map back to your original data from the FIRST code node\n// NOTE: Make sure your first code node is named exactly \"Code\"\nreturn {\n json: {\n name: $('Code').item.json.name,\n email: $('Code').item.json.email,\n company: $('Code').item.json.company,\n score: parsed.score,\n tier: parsed.tier,\n reason: parsed.reason,\n suggested_action: parsed.suggested_action\n }\n};" | |
| }, | |
| "type": "n8n-nodes-base.code", | |
| "typeVersion": 2, | |
| "position": [ | |
| 384, | |
| -80 | |
| ], | |
| "id": "2617ab0f-1b99-4611-ac2d-3938de9c5a2d", | |
| "name": "Code2" | |
| }, | |
| { | |
| "parameters": { | |
| "mode": "runOnceForEachItem", | |
| "jsCode": "return {\n json: {\n name: $json.body.name,\n email: $json.body.email,\n company: $json.body.company,\n size: $json.body.size,\n budget: $json.body.budget,\n need: $json.body.need,\n enriched: false\n }\n};" | |
| }, | |
| "type": "n8n-nodes-base.code", | |
| "typeVersion": 2, | |
| "position": [ | |
| -192, | |
| -80 | |
| ], | |
| "id": "d919f27f-75cb-4d70-844b-45d06613535e", | |
| "name": "Code" | |
| }, | |
| { | |
| "parameters": { | |
| "rules": { | |
| "values": [ | |
| { | |
| "conditions": { | |
| "options": { | |
| "caseSensitive": true, | |
| "leftValue": "", | |
| "typeValidation": "strict", | |
| "version": 3 | |
| }, | |
| "conditions": [ | |
| { | |
| "leftValue": "={{ $json.tier }}", | |
| "rightValue": "hot", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| }, | |
| "id": "67f6e03f-9090-45d4-9197-d94f74b7c831" | |
| } | |
| ], | |
| "combinator": "and" | |
| } | |
| }, | |
| { | |
| "conditions": { | |
| "options": { | |
| "caseSensitive": true, | |
| "leftValue": "", | |
| "typeValidation": "strict", | |
| "version": 3 | |
| }, | |
| "conditions": [ | |
| { | |
| "id": "fd9f855c-33b6-4548-8931-1da1b2fbaac0", | |
| "leftValue": "={{ $json.tier }}", | |
| "rightValue": "warm", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| } | |
| } | |
| ], | |
| "combinator": "and" | |
| } | |
| }, | |
| { | |
| "conditions": { | |
| "options": { | |
| "caseSensitive": true, | |
| "leftValue": "", | |
| "typeValidation": "strict", | |
| "version": 3 | |
| }, | |
| "conditions": [ | |
| { | |
| "id": "b0eb651d-6ef5-4310-9fc0-cc7a91ee6dd1", | |
| "leftValue": "={{ $json.tier }}", | |
| "rightValue": "cold", | |
| "operator": { | |
| "type": "string", | |
| "operation": "equals" | |
| } | |
| } | |
| ], | |
| "combinator": "and" | |
| } | |
| } | |
| ] | |
| }, | |
| "options": {} | |
| }, | |
| "type": "n8n-nodes-base.switch", | |
| "typeVersion": 3.4, | |
| "position": [ | |
| 608, | |
| -96 | |
| ], | |
| "id": "d4f2c729-11d8-4577-a2a3-55e980454ec0", | |
| "name": "Switch" | |
| }, | |
| { | |
| "parameters": { | |
| "authentication": "appToken", | |
| "email": "={{ $('Code2').item.json.email }}", | |
| "additionalFields": { | |
| "companyName": "={{ $('Code2').item.json.company }}", | |
| "firstName": "={{ $('Code2').item.json.name }}", | |
| "message": "={{ $('Code2').item.jso$('Code2').item.json.suggested_actionn.reason }}{{ $('Code2').item.json.score }}" | |
| }, | |
| "options": {} | |
| }, | |
| "type": "n8n-nodes-base.hubspot", | |
| "typeVersion": 2.2, | |
| "position": [ | |
| 832, | |
| -176 | |
| ], | |
| "id": "a9485e48-e5ac-4266-8144-247c71c984eb", | |
| "name": "Create or update a contact", | |
| "credentials": { | |
| "hubspotAppToken": { | |
| "id": "yTh359gKRTGh0867", | |
| "name": "HubSpot App Token account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "sendTo": "aloshiousvincent2024@gmail.com", | |
| "subject": "=🔥 Hot lead — {{ $('Code2').item.json.name }}(Score: {{ $('Code2').item.json.score }}", | |
| "message": "=Name: {{ $('Code2').item.json.name }} Email: {{ $('Code2').item.json.email }} Company: {{ $('Code2').item.json.company }} Score: {{ $('Code2').item.json.score }}/10 Why: {{ $('Code2').item.json.reason }} Action: {{ $('Code2').item.json.suggested_action }} Added to HubSpot automatically.", | |
| "options": { | |
| "appendAttribution": false | |
| } | |
| }, | |
| "type": "n8n-nodes-base.gmail", | |
| "typeVersion": 2.2, | |
| "position": [ | |
| 1056, | |
| -176 | |
| ], | |
| "id": "7c490726-d45d-429b-919d-c09b2c95d914", | |
| "name": "Send a message", | |
| "webhookId": "cfba255a-9a72-4487-a4ae-73f5ecc28b1b", | |
| "credentials": { | |
| "gmailOAuth2": { | |
| "id": "6pcmpPNyaOCTueTI", | |
| "name": "Gmail account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "operation": "append", | |
| "documentId": { | |
| "__rl": true, | |
| "value": "18nicGOFhUOHpOsJAmIBiKKm59xOuPr9fqoByJYKWrmk", | |
| "mode": "list", | |
| "cachedResultName": "lead info", | |
| "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18nicGOFhUOHpOsJAmIBiKKm59xOuPr9fqoByJYKWrmk/edit?usp=drivesdk" | |
| }, | |
| "sheetName": { | |
| "__rl": true, | |
| "value": "gid=0", | |
| "mode": "list", | |
| "cachedResultName": "Sheet1", | |
| "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18nicGOFhUOHpOsJAmIBiKKm59xOuPr9fqoByJYKWrmk/edit#gid=0" | |
| }, | |
| "columns": { | |
| "mappingMode": "defineBelow", | |
| "value": { | |
| "Name": "={{ $json.name }}", | |
| "Email": "={{ $json.email }}", | |
| "Company": "={{ $json.company }}", | |
| "Score": "={{ $json.score }}", | |
| "Tier": "={{ $json.tier }}", | |
| "Reason": "={{ $json.reason }}", | |
| "Action": "={{ $json.suggested_action }}" | |
| }, | |
| "matchingColumns": [], | |
| "schema": [ | |
| { | |
| "id": "Name", | |
| "displayName": "Name", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Email", | |
| "displayName": "Email", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Company", | |
| "displayName": "Company", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Score", | |
| "displayName": "Score", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Tier", | |
| "displayName": "Tier", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Reason", | |
| "displayName": "Reason", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| }, | |
| { | |
| "id": "Action", | |
| "displayName": "Action", | |
| "required": false, | |
| "defaultMatch": false, | |
| "display": true, | |
| "type": "string", | |
| "canBeUsedToMatch": true | |
| } | |
| ], | |
| "attemptToConvertTypes": false, | |
| "convertFieldsToString": false | |
| }, | |
| "options": {} | |
| }, | |
| "type": "n8n-nodes-base.googleSheets", | |
| "typeVersion": 4.7, | |
| "position": [ | |
| 832, | |
| 16 | |
| ], | |
| "id": "f6c5c8b2-0c55-4eb2-a896-8f30b35fefcd", | |
| "name": "Append row in sheet", | |
| "credentials": { | |
| "googleSheetsOAuth2Api": { | |
| "id": "uNie1SOdm1c6AD5M", | |
| "name": "Google Sheets account" | |
| } | |
| } | |
| }, | |
| { | |
| "parameters": { | |
| "sendTo": "={{ $json.Email }}", | |
| "subject": "=Thanks for reaching out, {{ $json.Name }}", | |
| "message": "=Hi {{ $json.Name }}, Thanks for filling out our form. We've received your enquiry about {{ $('Code').item.json.need }}. We'll review your requirements and get back to you within 24 hours. Best, Managment Team", | |
| "options": { | |
| "appendAttribution": false | |
| } | |
| }, | |
| "type": "n8n-nodes-base.gmail", | |
| "typeVersion": 2.2, | |
| "position": [ | |
| 1056, | |
| 16 | |
| ], | |
| "id": "f3ec9e03-a775-453f-b8a1-0f603a544e68", | |
| "name": "Send a message1", | |
| "webhookId": "99d6a795-52f0-4f31-ac8b-23442869bb8d", | |
| "credentials": { | |
| "gmailOAuth2": { | |
| "id": "6pcmpPNyaOCTueTI", | |
| "name": "Gmail account" | |
| } | |
| } | |
| } | |
| ], | |
| "pinData": {}, | |
| "connections": { | |
| "Webhook": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Code", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Message a model": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Code2", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Code": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Message a model", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Code2": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Switch", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Switch": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Create or update a contact", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ], | |
| [ | |
| { | |
| "node": "Append row in sheet", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ], | |
| [ | |
| { | |
| "node": "Append row in sheet", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Create or update a contact": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Send a message", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| }, | |
| "Append row in sheet": { | |
| "main": [ | |
| [ | |
| { | |
| "node": "Send a message1", | |
| "type": "main", | |
| "index": 0 | |
| } | |
| ] | |
| ] | |
| } | |
| }, | |
| "active": false, | |
| "settings": { | |
| "executionOrder": "v1", | |
| "binaryMode": "separate" | |
| }, | |
| "versionId": "398ff1b9-fe83-4533-9d3a-86a8999faa39", | |
| "meta": { | |
| "templateCredsSetupCompleted": true, | |
| "instanceId": "916f0f825fc749421ece51af670592c323db1c88ecfb164d550f825225a10598" | |
| }, | |
| "id": "iOgc5gJ6H0bKSoCT", | |
| "tags": [] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment