{
  "name": "JeffList Email Outreach",
  "nodes": [
    {
      "parameters": {},
      "id": "trigger",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [250, 300]
    },
    {
      "parameters": {
        "url": "https://files.residentliberal.com/claw/uploads/JeffList2.xlsx",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "fetch-excel",
      "name": "Fetch Excel File",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [450, 300],
      "credentials": {
        "httpBasicAuth": {
          "id": "FILEACTORY_AUTH",
          "name": "Fileactory Basic Auth"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "parse-excel",
      "name": "Parse Spreadsheet",
      "type": "n8n-nodes-base.spreadsheetFile",
      "typeVersion": 2,
      "position": [650, 300]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Get all items from spreadsheet\nconst items = $input.all();\n\n// Skip header row, extract relevant fields\nconst contacts = [];\n\nfor (let i = 1; i < items.length; i++) {\n  const row = items[i].json;\n  \n  // Columns: Contact Date, Days Remaining, STATUS, LAST ACT, NEXT ACT, NAME, NUMBER, EMAIL, LOC, COMPANY, STATUS, LAST, NOTES\n  const name = row['NAME'] || '';\n  const email = row['EMAIL'] || '';\n  const company = row['COMPANY'] || '';\n  const location = row['LOC'] || '';\n  \n  // Skip if no email or name\n  if (!email || !name) continue;\n  \n  // Generate personalized email\n  const firstName = name.split(' ')[0];\n  \n  // Personalized subject line\n  let subject = `Quick question for you, ${firstName}`;\n  if (company && company !== 'MA') {\n    subject = `Quick question about ${company}`;\n  }\n  \n  // Personalized body (under 100 words)\n  let body = `Hi ${firstName},\\n\\n`;\n  \n  if (company && location) {\n    body += `Saw ${company}'s work in ${location} — caught my attention.\\n\\n`;\n  } else if (company) {\n    body += `Saw what ${company} is doing — caught my attention.\\n\\n`;\n  } else if (location) {\n    body += `Noticed you're based in ${location}.\\n\\n`;\n  } else {\n    body += `I came across your info and wanted to reach out.\\n\\n`;\n  }\n  \n  body += `I help businesses like yours with print and document solutions. Not here to sell anything today — just wanted to introduce myself in case it's ever useful to have a Xerox contact in your corner.\\n\\n`;\n  body += `Worth a brief call at some point?\\n\\n`;\n  body += `Best,\\nMark Mazza\\nABS - Xerox NE\\n860-888-2819`;\n  \n  contacts.push({\n    json: {\n      name: name,\n      email: email,\n      company: company,\n      location: location,\n      subject: subject,\n      body: body\n    }\n  });\n}\n\nreturn contacts;"
      },
      "id": "generate-emails",
      "name": "Generate Personalized Emails",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [850, 300]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "to",
              "value": "={{ $json.email }}"
            },
            {
              "name": "subject",
              "value": "={{ $json.subject }}"
            }
          ],
          "string_1": [
            {
              "name": "text",
              "value": "={{ $json.body }}"
            }
          ]
        },
        "options": {}
      },
      "id": "set-email-fields",
      "name": "Set Email Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [1050, 300]
    },
    {
      "parameters": {
        "fromEmail": "mmazza@gmail.com",
        "toEmail": "={{ $json.email }}",
        "subject": "={{ $json.subject }}",
        "text": "={{ $json.body }}",
        "options": {}
      },
      "id": "send-email",
      "name": "Send via SMTP",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [1250, 300],
      "credentials": {
        "smtp": {
          "id": "GMAIL_SMTP",
          "name": "Gmail SMTP"
        }
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Fetch Excel File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Excel File": {
      "main": [
        [
          {
            "node": "Parse Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Spreadsheet": {
      "main": [
        [
          {
            "node": "Generate Personalized Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Personalized Emails": {
      "main": [
        [
          {
            "node": "Set Email Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Email Fields": {
      "main": [
        [
          {
            "node": "Send via SMTP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}