{
  "nodes": [
    {
      "id": "1531b0b2-6323-4446-ac4a-aabbd37eb1bb",
      "name": "Main Sticky",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        496
      ],
      "parameters": {
        "color": 2,
        "width": 500,
        "height": 664,
        "content": "## Automate Cold Email Follow-ups\nStreamline your outreach sequence by automatically sending personalized follow-ups based on lead status.\n\n\n### How it works\n1. Schedule daily trigger execution.\n2. Fetch leads from Google Sheets.\n3. Filter active, non-replied leads.\n4. Route leads to specific email stages.\n5. Send personalized emails via ZeptoMail.\n6. Update sheet status and next steps.\n\n\n### Setup\n1. Connect your Google Sheets account.\n2. Connect your Zoho ZeptoMail account.\n3. Update Google Sheet ID and Range.\n4. Set your custom calendar link in Code nodes.\n5. Install required community nodes (see Important section).\n\n\n### Customization\nConsolidate user-specific values in a Set node at the workflow start for easy configuration.\n\n\n### Important\n\u26a0\ufe0f This workflow requires a self-hosted n8n instance. Community nodes used: n8n-nodes-zohozeptomail.zohoZeptomail"
      },
      "typeVersion": 1
    },
    {
      "id": "6cf6444e-d3bd-474a-9cf8-53b34c02b284",
      "name": "Run Daily",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -48,
        608
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "02f41a15-03a5-4f55-b421-f487911940fe",
      "name": "Read Tracking Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        176,
        608
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        }
      },
      "typeVersion": 4.7,
      "continueOnFail": true,
      "alwaysOutputData": true
    },
    {
      "id": "e0e32193-5f2c-4e1d-bc4b-fd9acb703519",
      "name": "Filter Active Leads",
      "type": "n8n-nodes-base.filter",
      "position": [
        400,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "completed"
            },
            {
              "id": "c2",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "replied"
            },
            {
              "id": "c3",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "unsubscribed"
            },
            {
              "id": "c4",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.Email }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "fc5d92d7-2de1-48c1-bac0-91fa046c555d",
      "name": "Filter Due Today",
      "type": "n8n-nodes-base.filter",
      "position": [
        624,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "d1",
              "operator": {
                "type": "dateTime",
                "operation": "beforeOrEqual"
              },
              "leftValue": "={{ $json.follow_up_date }}",
              "rightValue": "={{ $now.toISODate() }}"
            },
            {
              "id": "3e923d5e-3fb7-4b7c-9b68-66da9ed1e1e2",
              "operator": {
                "type": "dateTime",
                "operation": "beforeOrEquals"
              },
              "leftValue": "={{ $json.follow_up_date }}",
              "rightValue": "={{ $now.toISODate() }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "518b8dc7-b6c0-40f9-abeb-9a0ea4c34e7d",
      "name": "Loop Over Leads",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        848,
        608
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5c8c3792-3b83-4c2d-8ddc-f59f724554d4",
      "name": "Route by Follow-up Stage",
      "type": "n8n-nodes-base.switch",
      "position": [
        1088,
        592
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "r1",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "sent"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "r2",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "followup_1"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "r3",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "followup_2"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d25ba314-aa10-4e1a-838f-d439ea992289",
      "name": "Build Follow-up 1 Email",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        528
      ],
      "parameters": {
        "jsCode": "// BUILD FOLLOW-UP 1 EMAIL - personalised by partner type\nfunction getTemplate(type) {\n  const t = (type || '').toLowerCase();\n  if (t.includes('college') || t.includes('university')) return {\n    subject: (fn) => 'Following up \u2014 campus partnership with [YOUR COMPANY], ' + fn,\n    color: '#1D4ED8',\n    body: (fn, d) => 'Just checking in on my last email about a campus partnership between <strong>' + (d.name || 'your institution') + '</strong> and <strong>[YOUR COMPANY]</strong>.<br><br>We\\'d love to bring value to your students \u2014 through workshops, internships, or hackathons. Would a 15-minute call this week work?'\n  };\n  if (t.includes('influencer')) return {\n    subject: (fn) => 'Hey ' + fn + ', still keen on the collab?',\n    color: '#7C3AED',\n    body: () => 'Just following up on the collab idea I sent over! I genuinely think your audience would love <strong>[YOUR PRODUCT]</strong> \u2014 and the deal is flexible to match your style.<br><br>Would love to hop on a quick call \u2014 totally casual, no pressure.'\n  };\n  if (t.includes('brand')) return {\n    subject: (fn) => 'Quick follow-up \u2014 brand partnership with [YOUR COMPANY], ' + fn,\n    color: '#059669',\n    body: () => 'Following up on the brand partnership opportunity I shared earlier. We\\'ve had great results with partners in your space.<br><br>Would a 15-minute call this week work?'\n  };\n  return {\n    subject: (fn) => 'Quick follow-up \u2014 ' + fn + ', still interested in partnering?',\n    color: '#374151',\n    body: () => 'Just following up on my last email about partnering with <strong>[YOUR COMPANY]</strong>. Would a quick 15-minute call work?'\n  };\n}\n\nconst d = $input.first().json;\nconst firstName = (d.name || 'there').split(' ')[0];\nconst tpl = getTemplate(d.partner_type);\n\nconst emailBody = '<!DOCTYPE html><html><body style=\"font-family:Arial,sans-serif;max-width:600px;margin:0 auto;color:#333;line-height:1.6\">'\n  + '<p>Hi ' + firstName + ',</p>'\n  + '<p>' + tpl.body(firstName, d) + '</p>'\n  + '<p style=\"margin-top:20px\"><a href=\"https://calendly.com/REPLACE_WITH_CALENDAR_LINK\" style=\"background:' + tpl.color + ';color:#fff;padding:12px 24px;border-radius:6px;text-decoration:none;display:inline-block;font-weight:bold\">Pick a Time</a></p>'\n  + '<p style=\"margin-top:20px\">If the timing is not right, just say the word \u2014 no hard feelings.<br><br>Best,<br><strong>[YOUR NAME]</strong><br>[YOUR COMPANY] \u00b7 [YOUR EMAIL]</p>'\n  + '<hr style=\"border:none;border-top:1px solid #eee;margin:28px 0\">'\n  + '<p style=\"font-size:11px;color:#999\"><a href=\"mailto:[YOUR EMAIL]?subject=Unsubscribe\" style=\"color:#999\">Unsubscribe</a></p>'\n  + '</body></html>';\n\n\n// Threading headers for email client grouping\nconst inReplyTo = d.message_id ? '<' + d.message_id + '>' : '';\nconst references = d.thread_id ? '<' + d.thread_id + '>' : '';\nconst threadSubject = d.original_subject || tpl.subject(firstName);\nreturn [{ json: { ...d, emailSubject: threadSubject, emailBody, inReplyTo, references } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "db9645e2-e921-4bee-a633-d38aa4c8c9fd",
      "name": "Update Status \u2192 followup_1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        608
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $('Build Follow-up 1 Email').item.json.Name }}",
            "Email": "={{ $('Build Follow-up 1 Email').item.json.Email }}",
            "status": "=followup_1",
            "sent_date": "={{ $now.plus({days: 5}).toISODate() }}",
            "thread_id": "={{ $('Loop Over Leads').item.json.thread_id }}",
            "email_type": "={{ $('Build Follow-up 1 Email').item.json.email_type }}",
            "message_id": "={{ $('Send Follow-up 1').item.json.data[0].request_id }}",
            "row_number": "={{ $('Build Follow-up 1 Email').item.json.row_number }}",
            "partner_type": "={{ $('Build Follow-up 1 Email').item.json.partner_type }}",
            "follow_up_date": "={{ $('Build Follow-up 1 Email').item.json.follow_up_date }}"
          },
          "schema": [
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "partner_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "partner_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sent_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow_up_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow_up_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "thread_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "thread_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "original_subject",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "original_subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "98b6ef5d-371f-471e-894d-a8b580f661bf",
      "name": "Build Follow-up 2 Email",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        672
      ],
      "parameters": {
        "jsCode": "// BUILD FOLLOW-UP 2 EMAIL - second nudge (middle of sequence)\nfunction getTemplate(type) {\n  const t = (type || '').toLowerCase();\n  if (t.includes('college') || t.includes('university')) return {\n    subject: (fn) => 'Still worth a chat \\u2014 campus partnership, ' + fn,\n    color: '#1D4ED8',\n    body: (fn, d) => 'I wanted to follow up once more about the campus partnership between <strong>' + (d.name || 'your institution') + '</strong> and <strong>[YOUR COMPANY]</strong>.<br><br>Even a short 10-minute call could open a lot of doors for your students. Happy to work around your schedule.'\n  };\n  if (t.includes('influencer')) return {\n    subject: (fn) => fn + ', the collab offer is still open \\ud83d\\ude4c',\n    color: '#7C3AED',\n    body: () => 'Circling back one more time \\u2014 I genuinely think this collab would resonate well with your audience.<br><br>No pressure at all, just happy to jump on a quick call whenever works for you.'\n  };\n  if (t.includes('brand')) return {\n    subject: (fn) => 'One more thought on our partnership, ' + fn,\n    color: '#059669',\n    body: () => 'Just one more follow-up on the brand partnership idea. We have had great traction with similar brands recently and I think there is a real fit here.<br><br>Would love to show you some numbers on a quick call.'\n  };\n  return {\n    subject: (fn) => 'Checking in once more \\u2014 ' + fn,\n    color: '#374151',\n    body: () => 'One more follow-up about partnering with <strong>[YOUR COMPANY]</strong>. Still happy to connect whenever the timing works.'\n  };\n}\n\nconst d = $input.first().json;\nconst firstName = (d.name || 'there').split(' ')[0];\nconst tpl = getTemplate(d.partner_type);\n\nconst emailBody = '<!DOCTYPE html><html><body style=\"font-family:Arial,sans-serif;max-width:600px;margin:0 auto;color:#333;line-height:1.6\">'\n  + '<p>Hi ' + firstName + ',</p>'\n  + '<p>' + tpl.body(firstName, d) + '</p>'\n  + '<p style=\"margin-top:20px\"><a href=\"https://calendly.com/REPLACE_WITH_CALENDAR_LINK\" style=\"background:' + tpl.color + ';color:#fff;padding:12px 24px;border-radius:6px;text-decoration:none;display:inline-block;font-weight:bold\">Pick a Time</a></p>'\n  + '<p style=\"margin-top:20px\">Best,<br><strong>[YOUR NAME]</strong><br>[YOUR COMPANY] \\u00b7 [YOUR EMAIL]</p>'\n  + '<hr style=\"border:none;border-top:1px solid #eee;margin:28px 0\">'\n  + '<p style=\"font-size:11px;color:#999\"><a href=\"mailto:[YOUR EMAIL]?subject=Unsubscribe\" style=\"color:#999\">Unsubscribe</a></p>'\n  + '</body></html>';\n\n\n// Threading headers for email client grouping\nconst inReplyTo = d.message_id ? '<' + d.message_id + '>' : '';\nconst references = d.thread_id ? '<' + d.thread_id + '>' : '';\nconst threadSubject = d.original_subject || tpl.subject(firstName);\nreturn [{ json: { ...d, emailSubject: threadSubject, emailBody, inReplyTo, references } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "34e5bfa0-bbe9-42a5-b9c2-89cbabd493cf",
      "name": "Update Status \u2192 followup_2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        784
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $('Loop Over Leads').item.json.Name }}",
            "Email": "={{ $('Loop Over Leads').item.json.Email }}",
            "status": "followup_2",
            "sent_date": "={{ $now.toFormat('yyyy-MM-dd') }}",
            "thread_id": "={{ $('Loop Over Leads').item.json.thread_id }}",
            "email_type": "={{ $('Build Follow-up 2 Email').item.json.email_type }}",
            "message_id": "={{ $('Send Follow-up 2').item.json.data[0].request_id }}",
            "row_number": "={{ $('Loop Over Leads').item.json.row_number }}",
            "partner_type": "={{ $('Loop Over Leads').item.json.partner_type }}",
            "follow_up_date": "={{ $now.plus({days: 8}).toISODate() }}"
          },
          "schema": [
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "partner_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "partner_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sent_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow_up_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "follow_up_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "thread_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "thread_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "original_subject",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "original_subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "49e290a8-79f3-44b8-b6fe-1d68e1b6e070",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1584,
        608
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "22f31b78-9b17-4ae7-9acd-9bb8cc112240",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        1584,
        752
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "8e1f696d-69a2-4ee6-8287-3958a02c0a0e",
      "name": "Build Follow-up 3 Email",
      "type": "n8n-nodes-base.code",
      "position": [
        1312,
        816
      ],
      "parameters": {
        "jsCode": "// BUILD FOLLOW-UP 3 (FINAL) EMAIL - personalised by partner type\nfunction getTemplate(type) {\n  const t = (type || '').toLowerCase();\n  if (t.includes('college') || t.includes('university')) return {\n    subject: (fn) => 'Last note \\u2014 campus collab with [YOUR COMPANY], ' + fn,\n    body: () => 'I\\'ll keep this short \\u2014 this is my last outreach about a campus partnership with <strong>[YOUR COMPANY]</strong>.<br><br>If the timing is not right, no worries at all. We\\'d love to reconnect whenever you\\'re planning for the next semester.'\n  };\n  if (t.includes('influencer')) return {\n    subject: (fn) => 'Last message \\u2014 the collab offer stands, ' + fn,\n    body: () => 'I won\\'t keep nudging \\u2014 promise this is the last one! The collab offer is still open whenever you\\'re ready.'\n  };\n  if (t.includes('brand')) return {\n    subject: (fn) => 'Closing the loop \\u2014 brand partnership, ' + fn,\n    body: () => 'Last note from me on the brand partnership with <strong>[YOUR COMPANY]</strong>. If it\\'s not the right fit, completely understand \\u2014 my inbox is always open.'\n  };\n  return {\n    subject: (fn) => 'Last note from me \\u2014 ' + fn,\n    body: () => 'This is my last note about partnering with <strong>[YOUR COMPANY]</strong>. Feel free to reach out whenever.'\n  };\n}\n\nconst d = $input.first().json;\nconst firstName = (d.name || 'there').split(' ')[0];\nconst tpl = getTemplate(d.partner_type);\n\nconst emailBody = '<!DOCTYPE html><html><body style=\"font-family:Arial,sans-serif;max-width:600px;margin:0 auto;color:#333;line-height:1.6\">'\n  + '<p>Hi ' + firstName + ',</p>'\n  + '<p>' + tpl.body(firstName, d) + '</p>'\n  + '<p>If you ever want to reconnect, I\\'m always reachable at <a href=\"mailto:[YOUR EMAIL]\">[YOUR EMAIL]</a>.</p>'\n  + '<p>Wishing you all the best!</p>'\n  + '<p>\\u2014 <strong>[YOUR NAME]</strong><br>[YOUR COMPANY]</p>'\n  + '<hr style=\"border:none;border-top:1px solid #eee;margin:28px 0\">'\n  + '<p style=\"font-size:11px;color:#999\"><a href=\"mailto:[YOUR EMAIL]?subject=Unsubscribe\" style=\"color:#999\">Unsubscribe</a></p>'\n  + '</body></html>';\n\n\n// Threading headers for email client grouping\nconst inReplyTo = d.message_id ? '<' + d.message_id + '>' : '';\nconst references = d.thread_id ? '<' + d.thread_id + '>' : '';\nconst threadSubject = d.original_subject || tpl.subject(firstName);\nreturn [{ json: { ...d, emailSubject: threadSubject, emailBody, inReplyTo, references } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "2b29f9c5-9485-46c1-90d5-336a33b11535",
      "name": "Wait2",
      "type": "n8n-nodes-base.wait",
      "position": [
        1584,
        896
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "fdcd93ea-8a90-47cd-b4ab-dc590a7abd15",
      "name": "Update Status \u2192 completed",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        960
      ],
      "parameters": {
        "columns": {
          "value": {
            "Name": "={{ $('Build Follow-up 3 Email').item.json.Name }}",
            "Email": "={{ $('Build Follow-up 3 Email').item.json.Email }}",
            "status": "completed",
            "sent_date": "={{ $now.toFormat('yyyy-MM-dd') }}",
            "thread_id": "={{ $('Loop Over Leads').item.json.thread_id }}",
            "email_type": "={{ $('Build Follow-up 3 Email').item.json.email_type }}",
            "message_id": "={{ $('Send Follow-up 3').item.json.data[0].request_id }}",
            "row_number": "={{ $('Build Follow-up 3 Email').item.json.row_number }}",
            "partner_type": "={{ $('Build Follow-up 3 Email').item.json.partner_type }}",
            "follow_up_date": "={{ $now.plus({days: 18}).toISODate() }}"
          },
          "schema": [
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "partner_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "partner_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sent_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow_up_date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "follow_up_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "thread_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "thread_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "message_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "original_subject",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "original_subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RESOURCE_ID_HERE"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "aa147bec-7e1d-49f0-b172-6ad84fd60792",
      "name": "Send Follow-up 1",
      "type": "n8n-nodes-zohozeptomail.zohoZeptomail",
      "position": [
        1792,
        608
      ],
      "parameters": {
        "subject": "={{ $json.emailSubject }}",
        "htmlbody": "={{ $json.emailBody }}",
        "mailagent": "555046c28339d27e",
        "toaddress": "={{ $json.Email }}",
        "attachment": {},
        "fromaddress": {
          "name": "Think Sage",
          "address": "YOUR_EMAIL_HERE"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "5b565fab-2aa4-4182-a42d-869395768a1c",
      "name": "Send Follow-up 2",
      "type": "n8n-nodes-zohozeptomail.zohoZeptomail",
      "position": [
        1792,
        768
      ],
      "parameters": {
        "subject": "={{ $json.emailSubject }}",
        "htmlbody": "={{ $json.emailBody }}",
        "mailagent": "555046c28339d27e",
        "toaddress": "={{ $json.Email }}",
        "attachment": {},
        "fromaddress": {
          "name": "Think Sage",
          "address": "YOUR_EMAIL_HERE"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "56a51666-67cc-4eb8-9343-cbe0960d17cb",
      "name": "Send Follow-up 3",
      "type": "n8n-nodes-zohozeptomail.zohoZeptomail",
      "position": [
        1792,
        912
      ],
      "parameters": {
        "subject": "={{ $json.emailSubject }}",
        "htmlbody": "={{ $json.emailBody }}",
        "mailagent": "555046c28339d27e",
        "toaddress": "={{ $json.Email }}",
        "attachment": {},
        "fromaddress": {
          "name": "Think Sage",
          "address": "YOUR_EMAIL_HERE"
        }
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "dac740e2-792d-4a50-b631-6ec4840e4254",
      "name": "Data Fetch",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 296,
        "content": "## 1. Trigger & Data Sync\nFetch daily leads and filter by status."
      },
      "typeVersion": 1
    },
    {
      "id": "eed6114b-6ba2-408e-8e09-55d6159fc98e",
      "name": "Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 872,
        "height": 520,
        "content": "## 2. Processing & Routing\nEvaluate lead stage and build dynamic email templates."
      },
      "typeVersion": 1
    },
    {
      "id": "99ede930-151b-480c-8c08-53ee9b9ee308",
      "name": "Output",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 668,
        "height": 664,
        "content": "## 3. Delivery & Updates\nSend emails via ZeptoMail and update sheet logs."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Send Follow-up 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Send Follow-up 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Send Follow-up 3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Daily": {
      "main": [
        [
          {
            "node": "Read Tracking Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Leads": {
      "main": [
        [],
        [
          {
            "node": "Route by Follow-up Stage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Due Today": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-up 1": {
      "main": [
        [
          {
            "node": "Update Status \u2192 followup_1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-up 2": {
      "main": [
        [
          {
            "node": "Update Status \u2192 followup_2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Follow-up 3": {
      "main": [
        [
          {
            "node": "Update Status \u2192 completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Active Leads": {
      "main": [
        [
          {
            "node": "Filter Due Today",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Tracking Sheet": {
      "main": [
        [
          {
            "node": "Filter Active Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Follow-up 1 Email": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Follow-up 2 Email": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Follow-up 3 Email": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Follow-up Stage": {
      "main": [
        [
          {
            "node": "Build Follow-up 1 Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Follow-up 2 Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Follow-up 3 Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Status \u2192 completed": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Status \u2192 followup_1": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Status \u2192 followup_2": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}