AutomationFlowsAI & RAG › Send Gpt-4o Follow-up Emails to Leads and Detect Replies with Gmail

Send Gpt-4o Follow-up Emails to Leads and Detect Replies with Gmail

ByAndrew @striker on n8n.io

Sales teams, agencies, and service businesses that follow up with inbound leads via email and want to automate the entire sequence without losing the personal touch. Webhook receives the new lead form submission Configure Variables node sets your sender name, email, company…

Webhook trigger★★★★☆ complexityAI-powered19 nodesAgentOpenAI ChatGmailSlackGoogle Sheets
AI & RAG Trigger: Webhook Nodes: 19 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #15725 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "cHJpAwjf0EZnSlHn",
  "name": "Lead Follow-Up with AI and Reply Detection",
  "tags": [],
  "nodes": [
    {
      "id": "f75cfa63-5819-4d29-97c1-595e92422c96",
      "name": "New Lead Form Submission",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -368,
        448
      ],
      "parameters": {
        "path": "lead-form",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "275a6593-5ca4-4ca4-b9e2-2ab01a641430",
      "name": "Configure Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -96,
        448
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "senderName",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Your name (e.g. Sarah from Sales)__>"
            },
            {
              "id": "2",
              "name": "senderEmail",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Your email address (e.g. user@example.com)__>"
            },
            {
              "id": "3",
              "name": "companyName",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Your company name__>"
            },
            {
              "id": "4",
              "name": "replyDetectionEmail",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Email to monitor for replies (e.g. user@example.com)__>"
            },
            {
              "id": "5",
              "name": "waitTimeBetweenEmails",
              "type": "number",
              "value": 48
            },
            {
              "id": "6",
              "name": "leadName",
              "type": "string",
              "value": "={{ $json.body.name }}"
            },
            {
              "id": "7",
              "name": "leadEmail",
              "type": "string",
              "value": "={{ $json.body.email }}"
            },
            {
              "id": "8",
              "name": "leadCompany",
              "type": "string",
              "value": "={{ $json.body.company }}"
            },
            {
              "id": "9",
              "name": "leadInquiry",
              "type": "string",
              "value": "={{ $json.body.inquiry }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3ba03f03-6b64-480c-9979-81c0d6e95012",
      "name": "Generate First Follow-Up Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        352,
        432
      ],
      "parameters": {
        "text": "=Write a personalized follow-up email for a new lead.\n\nLead Details:\n- Name: {{ $json.leadName }}\n- Email: {{ $json.leadEmail }}\n- Company: {{ $json.leadCompany }}\n- Inquiry: {{ $json.leadInquiry }}\n\nSender Details:\n- Name: {{ $json.senderName }}\n- Company: {{ $json.companyName }}\n\nWrite a warm, professional email that:\n1. Thanks them for their interest\n2. Addresses their specific inquiry\n3. Offers to schedule a call or provide more information\n4. Keeps it concise (3-4 paragraphs)\n\nReturn ONLY the email body text, no subject line.",
        "options": {
          "systemMessage": "You are a professional sales assistant who writes personalized, warm follow-up emails to leads. Write in a friendly but professional tone."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "49c1a9fd-e393-4a3e-9629-a587dd60a5ca",
      "name": "OpenAI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        320,
        592
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "d1295ec8-47ab-4e73-9dc3-4a23aa838ed7",
      "name": "Send First Follow-Up Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        688,
        432
      ],
      "parameters": {
        "sendTo": "={{ $(\"Configure Variables\").item.json.leadEmail }}",
        "message": "={{ $json.output }}",
        "options": {
          "senderName": "={{ $(\"Configure Variables\").item.json.senderName }}"
        },
        "subject": "=Re: Your inquiry about {{ $(\"Configure Variables\").item.json.companyName }}",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "6927e43e-483c-43bf-9df4-ab9365763ab9",
      "name": "Wait 48 Hours",
      "type": "n8n-nodes-base.wait",
      "position": [
        1024,
        480
      ],
      "parameters": {
        "unit": "hours",
        "amount": "={{ $(\"Configure Variables\").item.json.waitTimeBetweenEmails }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "16e907ed-6bf5-4062-8cea-f808c375056d",
      "name": "Notify Team of Reply",
      "type": "n8n-nodes-base.slack",
      "position": [
        2112,
        256
      ],
      "parameters": {
        "text": "=\ud83c\udf89 Lead responded!\n\n*Lead:* {{ $(\"Configure Variables\").item.json.leadName }} ({{ $(\"Configure Variables\").item.json.leadCompany }})\n*Email:* {{ $(\"Configure Variables\").item.json.leadEmail }}\n*Reply:* {{ $json.text }}\n\nCheck your inbox to continue the conversation!",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "otherOptions": {}
      },
      "typeVersion": 2.4
    },
    {
      "id": "8e0240f3-d4d9-4b67-b2e7-26bbd3d4341e",
      "name": "Log Reply Status to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2368,
        256
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9ca4ff75-79df-40d2-a696-ddfb130c8fe7",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -112
      ],
      "parameters": {
        "color": "#FFF995",
        "width": 768,
        "height": 256,
        "content": "## AI Lead Follow-Up Sequence with Reply Detection\n\n**Who it's for:** Sales teams, agencies, and service businesses that follow up with inbound leads via email and want to automate the entire sequence without losing the personal touch.\n\n**What it does:** Triggers when a new lead submits a form, sends a personalized AI-written first email via Gmail, waits 48 hours, checks if the lead replied, then routes accordingly. Replied leads get logged to Google Sheets and your team gets notified in Slack. Non-replies get a second AI-written follow-up with a different angle.\n\n**Requirements:** Gmail credential, OpenAI API key, Slack credential, Google Sheets credential"
      },
      "typeVersion": 1
    },
    {
      "id": "59f899cf-cb9a-420d-b788-58dae0b06571",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        304
      ],
      "parameters": {
        "color": "#606060",
        "width": 582,
        "height": 320,
        "content": "## 1. Trigger and Configuration\n\nWebhook receives the lead form submission. Update the Configure Variables node with your sender name, sender email, company name, reply detection email, and wait time before activating."
      },
      "typeVersion": 1
    },
    {
      "id": "51dec2a6-254b-4ba1-8ea7-8a321694a2fb",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        304
      ],
      "parameters": {
        "color": "#606060",
        "width": 598,
        "height": 416,
        "content": "## 2. AI Email Generation and Send\n\nLead data is passed to OpenAI which writes a personalized first follow-up email based on the inquiry details. Gmail sends it from your connected account."
      },
      "typeVersion": 1
    },
    {
      "id": "cd2d981d-1755-46b4-9865-a810ce3c73df",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        933,
        320
      ],
      "parameters": {
        "color": "#606060",
        "width": 598,
        "height": 320,
        "content": "## 3. Wait and Reply Detection\n\nThe workflow pauses for 48 hours. After the wait, a Gmail trigger checks the inbox for any reply from the lead using the reply detection email set in the Configure Variables node."
      },
      "typeVersion": 1
    },
    {
      "id": "af4f39e1-7ee0-43e9-b054-76eeb7b963c5",
      "name": "Send Second Follow-Up Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2400,
        608
      ],
      "parameters": {
        "sendTo": "={{ $(\"Configure Variables\").item.json.leadEmail }}",
        "message": "={{ $json.output }}",
        "options": {
          "senderName": "={{ $(\"Configure Variables\").item.json.senderName }}"
        },
        "subject": "=Quick follow-up: {{ $(\"Configure Variables\").item.json.companyName }}",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7e0f0778-34fd-4ffa-9c51-fb42994e56a7",
      "name": "Generate Second Follow-Up Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2048,
        608
      ],
      "parameters": {
        "text": "=Write a second follow-up email for a lead who has not responded to the first email.\n\nLead Details:\n- Name: {{ $(\"Configure Variables\").item.json.leadName }}\n- Company: {{ $(\"Configure Variables\").item.json.leadCompany }}\n- Original Inquiry: {{ $(\"Configure Variables\").item.json.leadInquiry }}\n\nSender Details:\n- Name: {{ $(\"Configure Variables\").item.json.senderName }}\n- Company: {{ $(\"Configure Variables\").item.json.companyName }}\n\nWrite a brief, friendly follow-up that:\n1. Takes a different angle (e.g., share a relevant case study, offer a resource, or mention a limited-time offer)\n2. Acknowledges they might be busy\n3. Provides clear value or next steps\n4. Keeps it short (2-3 paragraphs)\n\nReturn ONLY the email body text, no subject line.",
        "options": {
          "systemMessage": "You are a professional sales assistant who writes brief, value-focused follow-up emails. Take a different angle from the first email and keep it concise."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "db9bbb98-66ca-4881-b1aa-45450ce97567",
      "name": "Did Lead Reply?",
      "type": "n8n-nodes-base.if",
      "position": [
        1696,
        448
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d6c71fc6-8fbf-44c0-b385-d74d9c6f8dfd",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        320
      ],
      "parameters": {
        "color": "#606060",
        "width": 342,
        "height": 272,
        "content": "## 4. Route by Reply Status\n\nIf node checks whether the lead replied. True routes to the replied branch. False routes to the no reply branch."
      },
      "typeVersion": 1
    },
    {
      "id": "d98befd3-1033-4cd6-b88d-3c03339bf362",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        112
      ],
      "parameters": {
        "color": "#606060",
        "width": 582,
        "height": 320,
        "content": "## 5. Lead Replied\n\nSlack sends a notification to your team that the lead responded. Google Sheets logs the reply status, lead name, email, and timestamp for tracking."
      },
      "typeVersion": 1
    },
    {
      "id": "014c08ab-6dd1-4ab9-964c-2b3890586ecf",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        480
      ],
      "parameters": {
        "color": "#606060",
        "width": 582,
        "height": 320,
        "content": "## 6. No Reply\n\nOpenAI writes a second follow-up email using a different angle than the first. Gmail sends it from your connected account."
      },
      "typeVersion": 1
    },
    {
      "id": "1a842e3f-5389-43b5-ba36-1b68bbef6948",
      "name": "Check for Lead Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1280,
        480
      ],
      "parameters": {
        "limit": 10,
        "filters": {
          "sender": "={{ $(\"Configure Variables\").item.json.leadEmail }}",
          "receivedAfter": "={{ $now.minus(2, \"days\").toISO() }}"
        },
        "operation": "getAll"
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "4a9bfb39-e450-43b9-b17a-5e8b33999024",
  "connections": {
    "OpenAI Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate First Follow-Up Email",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Generate Second Follow-Up Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Wait 48 Hours": {
      "main": [
        [
          {
            "node": "Check for Lead Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Did Lead Reply?": {
      "main": [
        [
          {
            "node": "Notify Team of Reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Second Follow-Up Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Variables": {
      "main": [
        [
          {
            "node": "Generate First Follow-Up Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Lead Reply": {
      "main": [
        [
          {
            "node": "Did Lead Reply?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Team of Reply": {
      "main": [
        [
          {
            "node": "Log Reply Status to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Lead Form Submission": {
      "main": [
        [
          {
            "node": "Configure Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send First Follow-Up Email": {
      "main": [
        [
          {
            "node": "Wait 48 Hours",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate First Follow-Up Email": {
      "main": [
        [
          {
            "node": "Send First Follow-Up Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Second Follow-Up Email": {
      "main": [
        [
          {
            "node": "Send Second Follow-Up Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Sales teams, agencies, and service businesses that follow up with inbound leads via email and want to automate the entire sequence without losing the personal touch. Webhook receives the new lead form submission Configure Variables node sets your sender name, email, company…

Source: https://n8n.io/workflows/15725/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Enhance your support, onboarding, and internal knowledge workflows with an intelligent RAG-powered chatbot that responds using live data stored in Google Sheets. 🤖📚 Built for teams that rely on struct

Chat Trigger, Output Parser Structured, Memory Buffer Window +6
AI & RAG

🧾 Short Description

Agent, OpenAI Chat, Output Parser Structured +4
AI & RAG

This workflow automates the resume screening process using AI, enabling faster and more consistent candidate evaluation. It analyzes uploaded resumes, scores candidates based on job fit, and automatic

Agent, OpenAI Chat, Output Parser Structured +3
AI & RAG

This workflow automates end-to-end concert ticket booking validation and fan experience management using two coordinated AI agents. It is designed for ticketing platforms, event operators, and venue o

OpenAI Chat, Output Parser Structured, Agent +4
AI & RAG

This workflow automates the end-to-end employee onboarding process by provisioning new hires across multiple internal systems and delivering a personalized welcome experience.

HTTP Request, Slack, Notion +4