{
  "id": "GxfV0AX4mkzLifrT",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Lead Reply Automation \u2014 Groq AI",
  "tags": [
    {
      "id": "5jV6xDw8CXAtNMwe",
      "name": "Groq Ai",
      "createdAt": "2026-06-10T12:21:16.318Z",
      "updatedAt": "2026-06-10T12:21:16.318Z"
    },
    {
      "id": "PnVycSeBp5G56OcQ",
      "name": "AI",
      "createdAt": "2026-05-16T07:46:05.730Z",
      "updatedAt": "2026-05-16T07:46:05.730Z"
    },
    {
      "id": "W1QWkfFU7LHWsplW",
      "name": "Groq",
      "createdAt": "2026-05-26T11:17:56.006Z",
      "updatedAt": "2026-05-26T11:17:56.006Z"
    },
    {
      "id": "isc5mcRgi7ZrLc01",
      "name": "Lead Reply",
      "createdAt": "2026-06-13T08:42:32.663Z",
      "updatedAt": "2026-06-13T08:42:32.663Z"
    },
    {
      "id": "tIPFdZOrROXKwsDk",
      "name": "Automation",
      "createdAt": "2026-05-16T07:46:05.819Z",
      "updatedAt": "2026-05-16T07:46:05.819Z"
    }
  ],
  "nodes": [
    {
      "id": "02a397c0-8058-4c54-975b-71a683fcd97d",
      "name": "Lead Form Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -224,
        400
      ],
      "parameters": {
        "path": "new-lead",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "a5120fb0-b7af-45be-860c-673ce4359c7a",
      "name": "Parse Form Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        400
      ],
      "parameters": {
        "jsCode": "const body = $input.first().json.body || $input.first().json;\n\nconst name = body.name || body.full_name || 'there';\nconst email = body.email || '';\nconst message = body.message || body.inquiry || body.notes || '';\nconst service = body.service || body.service_interest || body.subject || 'your inquiry';\nconst phone = body.phone || body.telephone || '';\nconst company = body.company || body.business || '';\n\nif (!email) throw new Error('No email found in form submission');\n\nreturn [{\n  json: {\n    name,\n    email,\n    message,\n    service,\n    phone,\n    company,\n    submitted_at: new Date().toISOString(),\n    raw: body\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "31ca29ba-c5dd-40da-b568-f5960f555074",
      "name": "Groq \u2014 Qualify & Draft Reply",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        224,
        400
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"llama-3.3-70b-versatile\",\n  \"max_tokens\": 600,\n  \"temperature\": 0.4,\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"You are a lead qualification AI for a small business. Analyze the lead and respond ONLY with valid JSON \u2014 no markdown, no backticks, no explanation. Return this exact structure:\\n{\\n  \\\"score\\\": <integer 1-10>,\\n  \\\"tier\\\": \\\"hot\\\" | \\\"warm\\\" | \\\"cold\\\",\\n  \\\"intent_summary\\\": \\\"<one sentence>\\\",\\n  \\\"urgency\\\": \\\"high\\\" | \\\"medium\\\" | \\\"low\\\",\\n  \\\"reply_email\\\": {\\n    \\\"subject\\\": \\\"<subject line>\\\",\\n    \\\"body\\\": \\\"<full email body, friendly, 3-4 short paragraphs, signed off naturally>\\\"\\n  },\\n  \\\"slack_note\\\": \\\"<one line for Slack alert, plain text>\\\"\\n}\\n\\nScoring: 8-10 = clear buying intent + timeline/budget. 5-7 = general interest. 1-4 = vague or spam.\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"Lead details:\\nName: {{ $json.name }}\\nEmail: {{ $json.email }}\\nService interest: {{ $json.service }}\\nMessage: {{ $json.message }}\\nPhone: {{ $json.phone }}\\nCompany: {{ $json.company }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "920948c3-2f1d-49fe-b0dd-21df229ae6a9",
      "name": "Parse Groq Response",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        400
      ],
      "parameters": {
        "jsCode": "const raw = $input.first().json.choices[0].message.content;\n\nlet parsed;\ntry {\n  parsed = JSON.parse(raw);\n} catch (e) {\n  // strip any accidental markdown fences\n  const cleaned = raw.replace(/```json|```/g, '').trim();\n  parsed = JSON.parse(cleaned);\n}\n\nconst lead = $('Parse Form Fields').first().json;\n\nreturn [{\n  json: {\n    ...lead,\n    score: parsed.score,\n    tier: parsed.tier,\n    intent_summary: parsed.intent_summary,\n    urgency: parsed.urgency,\n    email_subject: parsed.reply_email.subject,\n    email_body: parsed.reply_email.body,\n    slack_note: parsed.slack_note,\n    is_hot: parsed.score >= 8\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "66edff45-e4c6-4392-83f4-d6b849ce2d90",
      "name": "Send Reply Email",
      "type": "n8n-nodes-base.gmail",
      "notes": "Replace with SMTP node if not using Gmail",
      "position": [
        656,
        240
      ],
      "parameters": {
        "sendTo": "={{ $json.email }}",
        "message": "={{ $json.email_body }}",
        "options": {
          "replyTo": "your@business.com"
        },
        "subject": "={{ $json.email_subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "f14fbe42-7271-4134-8815-416b918857eb",
      "name": "Create CRM Record (Google Sheets)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        400
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $json.name }}",
            "Tier": "={{ $json.tier }}",
            "Email": "={{ $json.email }}",
            "Phone": "={{ $json.phone }}",
            "Status": "New",
            "Message": "={{ $json.message }}",
            "Urgency": "={{ $json.urgency }}",
            "AI Summary": "={{ $json.intent_summary }}",
            "Lead Score": "={{ $json.score }}",
            "Submitted At": "={{ $json.submitted_at }}",
            "Service Interest": "={{ $json.service }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Service Interest",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Service Interest",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Lead Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tier",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Tier",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Urgency",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Urgency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI Summary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI Summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Submitted At",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Submitted At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1383982307,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y_LrekrIwrNs2UJKbrLMVMbwVDO36fOgezIs2rTk_lU/edit#gid=1383982307",
          "cachedResultName": "Leads-CRM"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Y_LrekrIwrNs2UJKbrLMVMbwVDO36fOgezIs2rTk_lU",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Y_LrekrIwrNs2UJKbrLMVMbwVDO36fOgezIs2rTk_lU/edit?usp=drivesdk",
          "cachedResultName": "Leads"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "aa44ecd5-1e62-43c9-ba2e-4cc429f64433",
      "name": "Slack Team Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        656,
        576
      ],
      "parameters": {
        "text": "={{ $json.is_hot ? '\ud83d\udd25 HOT LEAD' : ($json.tier === 'warm' ? '\ud83d\udfe1 Warm lead' : '\u26aa New lead') }} \u2014 Score: {{ $json.score }}/10\n\n*{{ $json.name }}* ({{ $json.email }}{{ $json.phone ? ' \u00b7 ' + $json.phone : '' }})\n*Service:* {{ $json.service }}\n*AI note:* {{ $json.slack_note }}\n\n{{ $json.is_hot ? '\ud83d\udc46 Follow up today!' : 'Added to CRM.' }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#leads"
        },
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "fdb1f340-0285-446c-89c7-3e522b7ff747",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        880,
        400
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ status: 'ok', message: 'Lead received' }) }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ac835d80-3175-4a4c-83fb-a6e22bfc0de8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        336
      ],
      "parameters": {
        "width": 400,
        "height": 432,
        "content": "## \ud83d\udd25 LEAD REPLY AUTOMATION\n\nHOW IT WORKS\nA lead submits your contact form \u2192 \nGroq AI qualifies them in seconds \u2192 \nPersonalized email fires automatically \u2192 \nCRM record created \u2192 Team gets Slack alert\n\nHOW TO SET UP\n1. Add Groq API key in HTTP node\n2. Connect Gmail OAuth\n3. Paste Google Sheet ID\n4. Connect Slack account + set channel\n5. Activate workflow\n\nCUSTOMIZATION\n- Change scoring threshold (default: 8 = hot)\n- Edit the AI prompt to match your business\n- Add more branches for different lead tiers"
      },
      "typeVersion": 1
    },
    {
      "id": "a69fd6ad-c413-431e-9349-ccf8d152c0cd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 224,
        "content": "## \ud83d\udce5 Intake"
      },
      "typeVersion": 1
    },
    {
      "id": "982e3b65-2118-4051-b9b1-9ff9599c4cd0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        320
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 272,
        "content": "## \ud83e\udd16 AI Engine"
      },
      "typeVersion": 1
    },
    {
      "id": "c3ced6bc-60b9-4881-98a7-a0e0377bfa34",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "height": 592,
        "content": "## \ud83d\udce4 Actions"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "f420becd-8105-498a-ac40-cc8f54d5f530",
  "connections": {
    "Send Reply Email": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Form Webhook": {
      "main": [
        [
          {
            "node": "Parse Form Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Form Fields": {
      "main": [
        [
          {
            "node": "Groq \u2014 Qualify & Draft Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Groq Response": {
      "main": [
        [
          {
            "node": "Send Reply Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create CRM Record (Google Sheets)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack Team Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Groq \u2014 Qualify & Draft Reply": {
      "main": [
        [
          {
            "node": "Parse Groq Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}