{
  "name": "Re-engage HubSpot leads using Azure OpenAI GPT-4o, Gmail and Slack",
  "nodes": [
    {
      "id": "69cfc7e6-4462-4b01-9818-dd24dea2c3fa",
      "name": "Daily Trigger (Every 24h)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1264,
        640
      ]
    },
    {
      "id": "0aa45b52-1a96-4c4a-8fd5-92a27a494f77",
      "name": "HubSpot: Fetch Recent Leads + Activity Fields",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        -1056,
        640
      ]
    },
    {
      "id": "accf270a-21e1-4113-8f1d-3bfe72a6a7d9",
      "name": "Filter: Lead Status = BAD_TIMING",
      "type": "n8n-nodes-base.if",
      "position": [
        -848,
        640
      ]
    },
    {
      "id": "2b7c4f34-4602-481f-8026-96340e2ccb13",
      "name": "Batch Leads (Split In Batches)",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -448,
        624
      ]
    },
    {
      "id": "55062cd6-fcb4-4645-9957-83b424f75501",
      "name": "AI: Generate Re-Engagement Follow-Up Email Body",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -80,
        640
      ]
    },
    {
      "id": "f79a4963-e6a7-46ac-9d47-dfcc531d9bcb",
      "name": "Parse AI JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        336,
        624
      ]
    },
    {
      "id": "816a2a8f-f489-4d9f-b1e4-06c68b6382fc",
      "name": "Gmail: Create Follow-Up Draft Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        672,
        624
      ]
    },
    {
      "id": "7f437895-4f06-463b-8133-d2ae7f98cbc0",
      "name": "Slack: Notify Owner to Re-Engage Lead",
      "type": "n8n-nodes-base.slack",
      "position": [
        1024,
        624
      ]
    },
    {
      "id": "0bb82f5e-ed99-4182-9269-20d0a967939d",
      "name": "Slack: Alert AI Draft Failure",
      "type": "n8n-nodes-base.slack",
      "position": [
        688,
        1296
      ]
    },
    {
      "id": "4cde9769-eab5-4df2-9d92-a1f1c6d4cd75",
      "name": "Build AI Error Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        464,
        1296
      ]
    },
    {
      "id": "2f9d974a-6eaa-4170-ae5e-f56755c7e656",
      "name": "Execute Re-Engagement Follow-Up Email Body with Azure OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        -144,
        896
      ]
    },
    {
      "id": "ca3ef8f2-66d6-45c4-91ea-4d85ceab7992",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2304,
        -128
      ],
      "parameters": {
        "width": 672,
        "height": 624,
        "content": "## 🔁 AI-Powered HubSpot Lead Re-Engagement Workflow\n\n### What this workflow does\nThis workflow automatically re-engages HubSpot leads that were previously marked as “Bad Timing” and have gone cold. Ev"
      }
    },
    {
      "id": "5fe26e48-0ab5-420b-97e3-88a706060456",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        400
      ],
      "parameters": {
        "width": 464,
        "height": 496,
        "content": "## ⏰ Daily Schedule & Lead Fetch (HubSpot)\n\nRuns every 24 hours to fetch leads\nfrom HubSpot with activity timestamps.\n\n• Scheduled trigger  \n• Pulls recent lead activity  \n• Feeds data into filtering "
      }
    },
    {
      "id": "58d57330-91ca-4cdc-b424-a115f9ba44e3",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        400
      ],
      "parameters": {
        "width": 288,
        "height": 448,
        "content": "## 🚦 Filter Leads Marked as “Bad Timing”\n\nOnly processes leads that were previously\nmarked as bad timing in HubSpot.\n\n• Prevents spamming active leads  \n• Targets cold or paused opportunities  \n• Keep"
      }
    },
    {
      "id": "1dd4c22f-f047-4a67-abaa-4c338be2b188",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -576,
        368
      ],
      "parameters": {
        "width": 336,
        "height": 496,
        "content": "## 🔄 Loop Over Eligible Leads\n\nProcesses leads one-by-one to avoid\nrate limits and ensure clean AI output.\n\n• Handles each lead independently  \n• Supports retries on failure  \n• Keeps processing stabl"
      }
    },
    {
      "id": "226753c4-adcf-4735-90cb-0009f8fc5803",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        416
      ],
      "parameters": {
        "width": 656,
        "height": 640,
        "content": "## ✍️ AI Follow-Up Email Generator\n\nGenerates short, polite re-engagement\nemails for cold leads.\n\n• Personalized using lead data  \n• Non-pushy, friendly tone  \n• Soft CTA to re-open conversation  \n"
      }
    },
    {
      "id": "9003037c-7cb8-4781-8cf0-36e40d5d37c3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        416
      ],
      "parameters": {
        "width": 368,
        "height": 432,
        "content": "## 📨 Gmail Draft Creation\n\nCreates a draft follow-up email\nfor sales to review and send.\n\n• Human-in-the-loop safety  \n• No auto-send to customers  \n• Keeps outreach controlled  \n"
      }
    },
    {
      "id": "c9ef72c9-c4ed-437c-99d2-f5c751407359",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        384
      ],
      "parameters": {
        "width": 272,
        "height": 464,
        "content": "## 🔔 Sales Rep Notification (Slack)\n\nNotifies the assigned owner that\na follow-up draft was created.\n\n• Includes lead email + status  \n• Prompts timely outreach  \n• Keeps sales informed  \n"
      }
    },
    {
      "id": "11986706-3aa5-4420-83e8-5d5824b71b6c",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        1104
      ],
      "parameters": {
        "width": 480,
        "height": 400,
        "content": "## ⚠️ AI Failure Handling & Fallback\n\nHandles cases where AI fails to\ngenerate a follow-up email.\n\n• Notifies sales on Slack  \n• Prevents silent lead drops  \n• Enables manual follow-up  \n"
      }
    },
    {
      "id": "73bde7cf-c29b-43a4-a9e8-d1dbe2ec5f9f",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        576
      ],
      "parameters": {
        "width": 336,
        "height": 272,
        "content": "## 🔐 Required Credentials & Access\n\n• HubSpot App Token  \n• Azure OpenAI (LLM generation)  \n• Gmail OAuth2 (draft emails)  \n• Slack API (sales alerts)  \n\nNever auto-send emails without review.\nKeep hu"
      }
    }
  ],
  "connections": {
    "Parse AI JSON": {
      "main": [
        [
          {
            "node": "Gmail: Create Follow-Up Draft Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build AI Error Payload": {
      "main": [
        [
          {
            "node": "Slack: Alert AI Draft Failure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger (Every 24h)": {
      "main": [
        [
          {
            "node": "HubSpot: Fetch Recent Leads + Activity Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack: Alert AI Draft Failure": {
      "main": [
        [
          {
            "node": "Batch Leads (Split In Batches)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Leads (Split In Batches)": {
      "main": [
        [],
        [
          {
            "node": "AI: Generate Re-Engagement Follow-Up Email Body",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter: Lead Status = BAD_TIMING": {
      "main": [
        [
          {
            "node": "Batch Leads (Split In Batches)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail: Create Follow-Up Draft Email": {
      "main": [
        [
          {
            "node": "Slack: Notify Owner to Re-Engage Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack: Notify Owner to Re-Engage Lead": {
      "main": [
        [
          {
            "node": "Batch Leads (Split In Batches)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot: Fetch Recent Leads + Activity Fields": {
      "main": [
        [
          {
            "node": "Filter: Lead Status = BAD_TIMING",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Generate Re-Engagement Follow-Up Email Body": {
      "main": [
        [
          {
            "node": "Parse AI JSON",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build AI Error Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Re-Engagement Follow-Up Email Body with Azure OpenAI": {
      "ai_languageModel": [
        [
          {
            "node": "AI: Generate Re-Engagement Follow-Up Email Body",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}