{
  "name": "Run email outreach campaigns from Telegram with Gmail and Google Sheets",
  "nodes": [
    {
      "id": "0952c637-9082-49df-a91f-761a904496be",
      "name": "Track Email Open",
      "type": "n8n-nodes-base.webhook",
      "position": [
        512,
        592
      ]
    },
    {
      "id": "779f275e-23c0-4393-847d-11386736bef5",
      "name": "Map Campaign Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1184,
        -128
      ]
    },
    {
      "id": "5097d9c0-c330-41ea-9594-c7918875fe37",
      "name": "Prompt Campaign via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        960,
        -128
      ]
    },
    {
      "id": "6a271b9c-0cb4-4ce4-84b0-01e67d23bb8e",
      "name": "Create Campaign Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1408,
        -128
      ]
    },
    {
      "id": "781e0cc2-65ab-4b00-bd32-e6cad5266bc2",
      "name": "Route by Sender Email",
      "type": "n8n-nodes-base.switch",
      "position": [
        960,
        192
      ]
    },
    {
      "id": "43c8ec29-b123-4bea-91bd-95f5f3f8cafb",
      "name": "Build HTML Template",
      "type": "n8n-nodes-base.html",
      "position": [
        2080,
        208
      ]
    },
    {
      "id": "7f6decf7-a101-4d71-9f58-d314c9436dd0",
      "name": "Extract Tracking Params",
      "type": "n8n-nodes-base.set",
      "position": [
        704,
        592
      ]
    },
    {
      "id": "cdfcc1e6-f51d-4081-9783-5a102df8efa4",
      "name": "Increment Open Count",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1744,
        608
      ]
    },
    {
      "id": "4f6cface-e987-49ab-b071-b8e7987eafd8",
      "name": "Lookup Campaign Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        912,
        592
      ]
    },
    {
      "id": "d25db34e-e0d5-4942-85c3-71ecae442f06",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        448
      ],
      "parameters": {
        "width": 1936,
        "height": 352,
        "content": "## 3. Track Email Opens\n\nWebhook receives open-tracking pixel hits. Looks up the campaign row,\nchecks if the open was already logged, increments the open counter,\nand writes to the logs sheet to preve"
      }
    },
    {
      "id": "6087ee53-bd39-4130-b87e-675a7d6417ab",
      "name": "Watch for New Campaigns",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        512,
        208
      ]
    },
    {
      "id": "a0ff6769-ad01-4211-91f4-901fb005d714",
      "name": "Send Email via Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2304,
        208
      ]
    },
    {
      "id": "4623b7e3-f19d-4634-a244-5ba7b93a5f14",
      "name": "If Status Is Draft",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        208
      ]
    },
    {
      "id": "4b63591e-eabc-4973-a0ea-e7faba12500a",
      "name": "Cap Lead Count",
      "type": "n8n-nodes-base.limit",
      "position": [
        1408,
        208
      ]
    },
    {
      "id": "58ae18d7-1059-4c39-890a-a03869761f3c",
      "name": "Wait Random Delay",
      "type": "n8n-nodes-base.wait",
      "position": [
        3200,
        208
      ]
    },
    {
      "id": "82813897-8576-4b5a-a804-607ca28501e8",
      "name": "Generate Random Delay",
      "type": "n8n-nodes-base.code",
      "position": [
        2976,
        208
      ]
    },
    {
      "id": "3aceaf2e-deb4-4151-881e-0b93c0d1311a",
      "name": "Handle Unsubscribe",
      "type": "n8n-nodes-base.webhook",
      "position": [
        528,
        976
      ]
    },
    {
      "id": "f178a7b6-eb73-434e-ba35-d2ac032fab48",
      "name": "Extract Unsubscribe ID",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        976
      ]
    },
    {
      "id": "f954125b-d20c-4f1c-a84d-041eda995b39",
      "name": "Mark as Unsubscribed",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1200,
        976
      ]
    },
    {
      "id": "199c2c58-053c-4148-b9d6-74c0310ce55e",
      "name": "Lookup Lead Record",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        976,
        976
      ]
    },
    {
      "id": "55d3860c-4d7f-4952-a1d1-04988d7355d2",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        832
      ],
      "parameters": {
        "width": 944,
        "height": 304,
        "content": "## 4. Handle Unsubscribe Requests\n\nWebhook endpoint receives unsubscribe clicks from email footers.\nLooks up the lead by ID and sets `Subscribe = no` to exclude\nthem from future campaigns."
      }
    },
    {
      "id": "0c52e8d5-52ef-42b8-b17b-be45ca564d3d",
      "name": "Listen for Telegram Commands",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        512,
        -128
      ]
    },
    {
      "id": "7556d447-a54d-4a14-a391-b782a399484f",
      "name": "If Outreach Command",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        -128
      ]
    },
    {
      "id": "7ccc8026-2329-4241-8411-09bc588f2eea",
      "name": "Map Lead Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1632,
        208
      ]
    },
    {
      "id": "1639bfb1-08fa-4b3b-894a-f16d13ff9250",
      "name": "Loop Over Leads",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1856,
        208
      ]
    },
    {
      "id": "42b0a806-733e-46ec-8362-7089fc6e8239",
      "name": "Mark Campaign Done",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2176,
        592
      ]
    },
    {
      "id": "ef4365b1-e123-47b4-9d52-d21a35c876c1",
      "name": "Update Send Stats",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2752,
        208
      ]
    },
    {
      "id": "f2be8c4a-b7af-410c-8331-49f0d5fadd86",
      "name": "Fetch Current Stats",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2528,
        208
      ]
    },
    {
      "id": "ba82b9ea-41d5-40f5-b3d5-8014851969ca",
      "name": "Fetch Subscribed Leads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1184,
        208
      ]
    },
    {
      "id": "10f4594e-0aae-42cd-9e6c-64f1873814f3",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -272
      ],
      "parameters": {
        "width": 1152,
        "height": 288,
        "content": "## 1. Launch Campaign from Telegram\n\nListens for the `/outreach` command from an authorized Telegram user.\nOpens a form to collect email sender, subject, content, and send cap.\nCreates a new campaign "
      }
    },
    {
      "id": "37e2406c-fb71-4e79-98a7-72f72f8dd7dd",
      "name": "If Not Already Logged",
      "type": "n8n-nodes-base.if",
      "position": [
        1504,
        592
      ]
    },
    {
      "id": "198d1795-4d8e-425d-b237-3c2d9b075449",
      "name": "Lookup Open Logs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1088,
        592
      ]
    },
    {
      "id": "d52309a7-3447-4ace-a129-85f89b17edcc",
      "name": "Log Open Event",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1936,
        608
      ]
    },
    {
      "id": "6c8f80c7-c6d2-43e3-93a8-1fa9769dd3dd",
      "name": "Check If Already Opened",
      "type": "n8n-nodes-base.code",
      "position": [
        1296,
        592
      ]
    },
    {
      "id": "2ae08e32-517d-42d2-b9df-8d4f467baca1",
      "name": "Sticky Note - Intro",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -272
      ],
      "parameters": {
        "width": 380,
        "height": 960,
        "content": "## Automated Email Outreach via Telegram and Google Sheets\n\n### **What it does:**\nLets you launch personalized email campaigns from Telegram, track opens, manage unsubscribes, and monitor send stats —"
      }
    },
    {
      "id": "9beda2ca-69c7-40b3-bbdd-9662c3c9f72c",
      "name": "Sticky Note - Send Emails",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        48
      ],
      "parameters": {
        "width": 2980,
        "height": 352,
        "content": "## 2. Send Email Campaign\n\nWhen a new campaign row appears on the Dashboard, filters for `draft` status,\nroutes by sender email, fetches subscribed leads, caps the batch, then loops\nthrough each lead "
      }
    },
    {
      "id": "44c39af3-e715-4b51-a4c2-ad2bc8da110b",
      "name": "Contact & Attribution",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3424,
        -240
      ],
      "parameters": {
        "width": 700,
        "height": 1268,
        "content": "## Was this helpful? Get in touch!\n\nI really hope this automation helped you. Your feedback is incredibly valuable and helps me create better resources for business and the n8n community.\n\n### **Have "
      }
    }
  ],
  "connections": {
    "Cap Lead Count": {
      "main": [
        [
          {
            "node": "Map Lead Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Leads": {
      "main": [
        [
          {
            "node": "Mark Campaign Done",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build HTML Template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Lead Fields": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Open Logs": {
      "main": [
        [
          {
            "node": "Check If Already Opened",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Track Email Open": {
      "main": [
        [
          {
            "node": "Extract Tracking Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Send Stats": {
      "main": [
        [
          {
            "node": "Generate Random Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Random Delay": {
      "main": [
        [
          {
            "node": "Loop Over Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Unsubscribe": {
      "main": [
        [
          {
            "node": "Extract Unsubscribe ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Status Is Draft": {
      "main": [
        [
          {
            "node": "Route by Sender Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Lead Record": {
      "main": [
        [
          {
            "node": "Mark as Unsubscribed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build HTML Template": {
      "main": [
        [
          {
            "node": "Send Email via Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Current Stats": {
      "main": [
        [
          {
            "node": "Update Send Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Outreach Command": {
      "main": [
        [
          {
            "node": "Prompt Campaign via Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Campaign Row": {
      "main": [
        [
          {
            "node": "Lookup Open Logs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Campaign Fields": {
      "main": [
        [
          {
            "node": "Create Campaign Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Increment Open Count": {
      "main": [
        [
          {
            "node": "Log Open Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email via Gmail": {
      "main": [
        [
          {
            "node": "Fetch Current Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Random Delay": {
      "main": [
        [
          {
            "node": "Wait Random Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Not Already Logged": {
      "main": [
        [],
        [
          {
            "node": "Increment Open Count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Sender Email": {
      "main": [
        [
          {
            "node": "Fetch Subscribed Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Unsubscribe ID": {
      "main": [
        [
          {
            "node": "Lookup Lead Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Subscribed Leads": {
      "main": [
        [
          {
            "node": "Cap Lead Count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check If Already Opened": {
      "main": [
        [
          {
            "node": "If Not Already Logged",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Tracking Params": {
      "main": [
        [
          {
            "node": "Lookup Campaign Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Watch for New Campaigns": {
      "main": [
        [
          {
            "node": "If Status Is Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Listen for Telegram Commands": {
      "main": [
        [
          {
            "node": "If Outreach Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prompt Campaign via Telegram": {
      "main": [
        [
          {
            "node": "Map Campaign Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}