{
  "name": "Enrich Leads from Google Sheets with OpenAI and Draft Gmail",
  "nodes": [
    {
      "id": "9e6cf93b-2d67-4e47-90f6-b20c8a3d31a7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        64
      ],
      "parameters": {
        "width": 480,
        "height": 800,
        "content": "## Enrich Leads from Google Sheets with OpenAI and Draft Gmail\n\n### How it works\n\nThis workflow watches a Google Sheet for new or updated lead rows, sends the lead details to OpenAI for analysis, then uses the result to create a Gmail draft. After the draft is created, it updates the original Google Sheet row with a status so the lead can be tracked as processed.\n\n### Setup steps\n\n- Connect Google Sheets credentials for both the trigger and update nodes, and select the spreadsheet, sheet, and row-matching fields to monitor and update.\n- Connect OpenAI credentials and configure the prompt/model to analyze the lead data from the sheet columns.\n- Connect Gmail credentials and configure the draft recipient, subject, and email body using fields from the sheet and OpenAI output.\n- Confirm the final Google Sheets update writes an appropriate status, timestamp, or draft reference back to the correct row.\n\n### Customization\n\nAdjust the OpenAI prompt to change the lead scoring, personalization, or email tone, and modify the Gmail draft fields to match your outreach template."
      },
      "typeVersion": 1
    },
    {
      "id": "131c1193-d024-413e-87ee-3adf968b5140",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## Capture and analyze lead\n\nThis left-side cluster starts the workflow from Google Sheets and enriches the incoming lead row with OpenAI analysis."
      },
      "typeVersion": 1
    },
    {
      "id": "82ea70f0-ece7-4408-931c-ab91bdb673cb",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 336,
        "content": "## Draft and update status\n\nThis right-side cluster creates a Gmail draft from the analyzed lead information, then records the processing status back in Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
      "name": "When Sheet Updated",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        700,
        240
      ],
      "parameters": {
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2b3c4d5e-6f7a-8b9c-0d1e-2f3a4b5c6d7e",
      "name": "OpenAI Lead Insights",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        920,
        240
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "=Analyze this lead company: {{ $json.Company }} in industry {{ $json.Industry }}. Write a short 2-sentence summary of what they do and suggest a value proposition for an automation solution."
            }
          ]
        },
        "resource": "chat"
      },
      "typeVersion": 1
    },
    {
      "id": "3c4d5e6f-7a8b-9c0d-1e2f-3a4b5c6d7e8f",
      "name": "Draft Gmail Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1168,
        240
      ],
      "parameters": {
        "message": "=Hi {{ $json.FirstName }},\n\nI noticed your work at {{ $json.Company }}.\n\n{{ $json.output }}\n\nWould you be open to a brief chat this week?\n\nBest regards,\nAdetunji",
        "options": {},
        "subject": "=Exploring Automation Opportunities for {{ $json.Company }}",
        "resource": "draft",
        "emailType": "text"
      },
      "typeVersion": 2.1
    },
    {
      "id": "4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9a",
      "name": "Update Sheet Status in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1392,
        240
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Draft Created",
            "AI Summary": "={{ $json.output }}"
          },
          "mappingMode": "defineBelow"
        },
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.5
    }
  ],
  "connections": {
    "Draft Gmail Reply": {
      "main": [
        [
          {
            "node": "Update Sheet Status in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Sheet Updated": {
      "main": [
        [
          {
            "node": "OpenAI Lead Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Lead Insights": {
      "main": [
        [
          {
            "node": "Draft Gmail Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {},
  "active": false
}
