{
  "name": "Speed-to-Lead Responder (Helm Systems)",
  "nodes": [
    {
      "parameters": {
        "content": "## Speed-to-Lead Responder\n1. Open **Settings** and fill in your business, your name, your email and the next step you want to offer.\n2. Connect your credentials on Gmail, Google Sheets and the AI model.\n3. Pick your Google Sheet on **Log lead**. Columns: Date, Name, Email, Phone, Message, Source, Urgency, Summary.\n4. Copy the **Production URL** from the Webhook node into your website form, Facebook lead form or Zapier/Make hook. Send it JSON like {\"name\",\"email\",\"phone\",\"message\",\"source\"}.\n5. Leave **autoSend** off until you have read 10 drafts. Then turn it on.\nMade by Helm Systems: helmsystems.biz/field-kit",
        "width": 420,
        "height": 280,
        "color": 4
      },
      "id": "364096dd-950e-424b-a36c-90f10edb8394",
      "name": "Note 1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -304
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "new-lead",
        "options": {}
      },
      "id": "cc18bcb9-ae45-43bf-aa9d-dccc0ae7abdc",
      "name": "New lead (webhook)",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "ff089c3f-c417-4328-a6da-ecc0478a58b7"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "700bd8cb-6a5a-4276-afc4-e0795160ed89",
              "name": "business",
              "value": "Your Business Name",
              "type": "string"
            },
            {
              "id": "e43ab348-524f-454d-a876-5e3451843d22",
              "name": "owner",
              "value": "Your Name",
              "type": "string"
            },
            {
              "id": "f4f9461c-6f77-435b-a3be-fe1ef2755e3f",
              "name": "ownerEmail",
              "value": "you@yourbusiness.com",
              "type": "string"
            },
            {
              "id": "32a9d206-4360-455e-ab86-f10d51cbd968",
              "name": "autoSend",
              "value": false,
              "type": "boolean"
            },
            {
              "id": "6f117980-1aa7-4d44-a962-2c428c578877",
              "name": "nextStep",
              "value": "inviting them to reply with a good time for a quick call",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "1afc51e7-de5c-4229-a6f4-41c56ac63382",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const b = $json.body ?? $json;\nconst s = $('Settings').first().json;\nconst name = b.name || b.full_name || [b.first_name, b.last_name].filter(Boolean).join(' ') || 'there';\nreturn [{ json: {\n  name,\n  email: String(b.email || b.Email || '').trim(),\n  phone: String(b.phone || b.Phone || b.phone_number || '').trim(),\n  message: String(b.message || b.Message || b.comments || b.details || '').slice(0, 2000),\n  source: b.source || b.utm_source || 'website',\n  now: $now.toFormat('cccc h:mm a'),\n  business: s.business, owner: s.owner, nextStep: s.nextStep,\n} }];"
      },
      "id": "bdf4990e-cd7f-4ac4-aebe-6cf927e8947a",
      "name": "Shape",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=New inquiry:\nName: {{ $json.name }}\nMessage: {{ $json.message }}\nSource: {{ $json.source }}\nIt is currently {{ $json.now }}.\n\nReturn JSON with these keys:\nurgency: \"hot\", \"warm\" or \"cold\" (\"hot\" means they want service soon or mention an emergency or a deadline)\nsummary: one sentence for the owner\nsubject: a short email subject\nemail: the reply email body, signed \"{{ $json.owner }}, {{ $json.business }}\"\nsms: the same reply as a text message, under 300 characters",
        "hasOutputParser": false,
        "messages": {
          "messageValues": [
            {
              "message": "=You write first replies for {{ $json.business }}, a small service business. You answer new inquiries on the owner's behalf.\n\nRules:\n- 2 to 4 short sentences. Warm and plain. No hype, no exclamation marks.\n- Refer to what they actually asked about.\n- Never quote a price, a date or a promise you were not given. Never invent facts about the business.\n- End with one simple next step: {{ $json.nextStep }}.\nReturn only JSON."
            }
          ]
        }
      },
      "id": "b1702bf9-b5e2-4b6c-a2af-5208e8b4ce9d",
      "name": "Draft the reply",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        780,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5-mini",
          "mode": "list",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "id": "88fdbfeb-ef0b-486f-a424-c5051859acba",
      "name": "Draft the reply model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        780,
        266
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const raw = String($json.text ?? '').trim().replace(/^```(?:json)?/i, '').replace(/```$/, '').trim();\nlet out = {};\nlet ok = true;\ntry { out = JSON.parse(raw); } catch (e) { ok = false; }\nconst needs = [\"urgency\",\"summary\",\"subject\",\"email\",\"sms\"];\nif (ok && !needs.every((k) => out[k] !== undefined && out[k] !== null)) ok = false;\nconst base = $('Shape').item.json;\nif (ok && out['email'] !== undefined) out['body'] = out['email'];\nif (!ok) {\n  out = { ...out, subject: out.subject || 'Check this one: the AI reply could not be read', body: out.body || ('Original AI output:\\n' + raw) };\n}\nreturn { json: { ...base, ...out, canSend: ok } };"
      },
      "id": "883295e5-dd67-4b0a-ab6c-b3fcdd576053",
      "name": "Read the reply",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1040,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "4b315080-86f5-43f8-a078-62b097f67e54",
              "leftValue": "={{ $json.email }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "f980d891-f6fb-4d7a-a972-473cf4949c0d",
      "name": "Has email?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1300,
        133
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "18217c17-f6b9-47fe-a197-9cb63e08ff68",
              "leftValue": "={{ $json.canSend && $('Settings').first().json.autoSend }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "135728c7-7243-4810-aa34-8a22347906ba",
      "name": "Auto-send on?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1560,
        133
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $json.email }}",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.body }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "bed0cce4-b2cb-4f10-ab52-3a61ae70ab03",
      "name": "Send email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1820,
        47.49999999999999
      ]
    },
    {
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.body }}",
        "options": {
          "sendTo": "={{ $json.email }}"
        }
      },
      "id": "87cc8d31-7611-431f-a07c-5e1d2d4a998b",
      "name": "Save as Gmail draft",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1820,
        218.49999999999997
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Settings').first().json.ownerEmail }}",
        "subject": "={{ '[' + String($json.urgency).toUpperCase() + '] New lead: ' + $json.name }}",
        "emailType": "text",
        "message": "={{ $json.summary + '\\n\\nThey wrote:\\n' + $json.message + '\\n\\nContact: ' + ($json.email || 'no email') + ' / ' + ($json.phone || 'no phone') + '\\nSource: ' + $json.source + '\\n\\nSuggested text message:\\n' + $json.sms }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "c820983f-1a0e-4dc2-aa2f-b0e0e23b9372",
      "name": "Alert the owner",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1300,
        -133
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $now.toFormat('yyyy-LL-dd') }}",
            "Name": "={{ $json.name }}",
            "Email": "={{ $json.email }}",
            "Phone": "={{ $json.phone }}",
            "Message": "={{ $json.message }}",
            "Source": "={{ $json.source }}",
            "Urgency": "={{ $json.urgency }}",
            "Summary": "={{ $json.summary }}"
          },
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "7bb15a68-d198-4149-a76d-447c2b9a8f2f",
      "name": "Log lead",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1300,
        380
      ]
    }
  ],
  "connections": {
    "Draft the reply model": {
      "ai_languageModel": [
        [
          {
            "node": "Draft the reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Has email?": {
      "main": [
        [
          {
            "node": "Auto-send on?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto-send on?": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save as Gmail draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New lead (webhook)": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Shape",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shape": {
      "main": [
        [
          {
            "node": "Draft the reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft the reply": {
      "main": [
        [
          {
            "node": "Read the reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the reply": {
      "main": [
        [
          {
            "node": "Alert the owner",
            "type": "main",
            "index": 0
          },
          {
            "node": "Has email?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
