{
  "nodes": [
    {
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -192,
        160
      ],
      "parameters": {
        "event": "rowAdded",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": "Form Responses 2",
        "documentId": "YOUR_SHEET_ID_HERE"
      },
      "typeVersion": 1
    },
    {
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        128,
        160
      ],
      "parameters": {
        "unit": "seconds",
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "name": "Create Email & Tag",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        416,
        160
      ],
      "parameters": {
        "modelId": "gpt-4o",
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a lead nurturing assistant. Write a friendly, professional email to a new lead of an AI consulting website. Your name is Kent and you work for BlueCrabAi. Do not use placeholders like [Lead's Name]. Only use the first name if the lead supplied a full name.\n\nLead data (from Google Sheets):\nName: {{ $('Google Sheets Trigger').item.json.Name }}\nEmail: {{ $('Google Sheets Trigger').item.json['Email Address'] }}\nPhone Number: {{ $('Google Sheets Trigger').item.json['Phone Number'] }}\nServices Interested In: {{ $('Google Sheets Trigger').item.json['Services Interested In'] }}\nBudget Range: {{ $('Google Sheets Trigger').item.json['Budget Range'] }}\nPreferred Contact Time: {{ $('Google Sheets Trigger').item.json['Preferred Contact Time (If specific, use \"other\" option'] }}\nProject Timeline: {{ $('Google Sheets Trigger').item.json['Project Timeline'] }}\nAdditional Comments: {{ $('Google Sheets Trigger').item.json['Additional Comments'] }}\n\nOutput STRICT JSON ONLY with exactly these keys:\n{\"Subject\":\"...\",\"Body\":\"...\",\"Tag\":\"High-Value Lead|Medium-Value Lead|Low-Value Lead\"}\n\nRules:\n- Subject must start with \"BlueCrabAi:\" then a concise topic.\n- Tag logic:\n  High-Value Lead: budget >= $4 or urgent/specific premium interest.\n  Medium-Value Lead: budget $2-$3 or standard services, moderate urgency.\n  Low-Value Lead: budget $0-$1 or vague/low intent.\n- Body: 3-6 sentences, personalized with services/budget/timeline/comments, and a clear CTA (reply or booking link)."
            }
          ]
        },
        "jsonOutput": true
      },
      "typeVersion": 1.8
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1040,
        -64
      ],
      "parameters": {
        "sendTo": "={{ $('Google Sheets Trigger').item.json['Email Address'] }}",
        "message": "={{ $json.Body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.Subject }}",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "name": "Update Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        192
      ],
      "parameters": {
        "columns": {
          "value": {
            "Tag": "={{ $json.Tag }}",
            "Name": "={{ $('Google Sheets Trigger').item.json.Name }}",
            "Status": "={{ $('Google Sheets Trigger').item.json.Name }} was contacted by email on {{ $now.toFormat('MMMM dd, yyyy, h:mm a') }}. The team has also been notified via Slack."
          },
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Name"
          ]
        },
        "options": {},
        "operation": "update",
        "sheetName": "Form Responses 2",
        "documentId": "YOUR_SHEET_ID_HERE"
      },
      "typeVersion": 4.7
    },
    {
      "name": "Notify Team",
      "type": "n8n-nodes-base.slack",
      "position": [
        1024,
        448
      ],
      "parameters": {
        "text": "=NEW {{$json.Tag}} Alert!\\nName: {{ $('Google Sheets Trigger').item.json.Name }}\\nInterest: {{ $('Google Sheets Trigger').item.json['Services Interested In'] }}\\nBudget: ${{ $('Google Sheets Trigger').item.json['Budget Range'] }}\\nSee the Google Sheet: https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID_HERE/edit",
        "select": "channel",
        "channel": "#your-slack-channel",
        "otherOptions": {
          "includeLinkToWorkflow": false
        },
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "name": "Sticky: Template overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -576
      ],
      "parameters": {
        "width": 1072,
        "height": 320,
        "content": "## Template overview\\n\\nThis workflow emails new leads, notifies your team, and updates your sheet.\\nAny form works as long as it writes a row into Google Sheets.\\nFlow: Sheets Trigger \u2192 (short Wait) \u2192 AI creates Subject/Body/Tag \u2192 Gmail sends \u2192 Slack notifies \u2192 Sheet logs status and lead type.\\nConnect your own Google Sheets, Gmail/SMTP, Slack, and OpenAI keys before running.\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: Trigger help",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        -144
      ],
      "parameters": {
        "color": 3,
        "width": 336,
        "height": 272,
        "content": "## Google Sheets Trigger\\nFires when a new row is added to your form responses tab.\\nPick the correct spreadsheet and tab name.\\nExpected headers: Timestamp, Name, Email Address, Phone Number, Services Interested In, Budget Range, Preferred Contact Time, Project Timeline, Additional Comments.\\nTip: submit a real form entry to test (do not paste rows).\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: Wait tip",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        304
      ],
      "parameters": {
        "color": 4,
        "width": 272,
        "height": 176,
        "content": "## Wait (buffer)\\nA 1\u20132 second pause so Google finishes writing the row before we read it.\\nYou can shorten or remove this once writes are stable.\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: AI help",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -176
      ],
      "parameters": {
        "color": 5,
        "height": 304,
        "content": "## Create Email & Tag (AI)\\nFeeds the row into OpenAI to produce three JSON fields: Subject, Body, Tag.\\nTag = High / Medium / Low using simple budget/services/timeline rules in the prompt.\\nIf it errors, check your OpenAI key, model name, and that the prompt asks for JSON only.\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: Email help",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        -304
      ],
      "parameters": {
        "color": 6,
        "height": 224,
        "content": "## Send Email\\nSends the model's Subject and Body to the lead's Email Address.\\nUse Gmail or SMTP with your own mailbox.\\nTest with your email first to confirm formatting and deliverability.\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: Sheet writeback",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        128
      ],
      "parameters": {
        "height": 256,
        "content": "## Update Status\\nWrites Status and Tag back to the same sheet so you can track outcomes.\\nCurrently matches by Name. If you have duplicates, switch to Timestamp or a unique ID.\\n"
      },
      "typeVersion": 1
    },
    {
      "name": "Sticky: Slack help",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        528
      ],
      "parameters": {
        "color": 3,
        "height": 208,
        "content": "## Notify Team (Slack)\\nPosts a short alert with the lead's name, services, budget, and a link to the sheet row.\\nSet the Slack channel you want and connect your Slack credential.\\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Create Email & Tag",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Email & Tag": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}