{
  "id": "896WetNRzIGunBT8",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI-Powered Inbound Email Assistant with Smart Classification & Auto-Response",
  "tags": [],
  "nodes": [
    {
      "id": "3fae9082-b21d-4251-92e1-2361d9803ec8",
      "name": "Function Node: Parse Email Content",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        32
      ],
      "parameters": {
        "jsCode": "function decodeBase64(input) {\n  try {\n    return Buffer.from(input, \"base64\").toString(\"utf8\");\n  } catch (e) {\n    return \"\";\n  }\n}\n\n// === Gmail Trigger Payload ===\nconst payload = $json.payload || {};\nconst headers = payload.headers || [];\n\n// === BODY (multi-part fallback) ===\nlet bodyRaw =\n  payload.body?.data ||\n  payload.parts?.find(p => p.mimeType?.includes(\"text/plain\"))?.body?.data ||\n  payload.parts?.[0]?.parts?.find(p => p.mimeType?.includes(\"text/plain\"))?.body?.data ||\n  \"\";\n\nlet body = decodeBase64(bodyRaw).trim();\n\n// === Snippet fallback ===\n// E\u011fer body bo\u015fsa Gmail trigger snippet\u2019\u0131n\u0131 kullan\nif (!body || body.length < 10) {\n  body = $json.snippet || \"(no message content)\";\n}\n\n// === FROM & SUBJECT ===\nlet fromHeader =\n  headers.find(h => h.name?.toLowerCase() === \"from\")?.value ||\n  $json.From ||  // root-level fallback\n  \"\";\nlet subjectHeader =\n  headers.find(h => h.name?.toLowerCase() === \"subject\")?.value ||\n  $json.Subject ||  // root-level fallback\n  \"(no subject)\";\n\n// === Clean Email ===\nlet from_email = fromHeader;\nconst emailMatch = fromHeader.match(/<(.+?)>/);\nif (emailMatch) from_email = emailMatch[1].trim();\n\n// === Lead Name ===\nconst leadNameMatch = fromHeader.match(/^(.+?)\\s*</);\nconst lead_name = leadNameMatch ? leadNameMatch[1].trim() : \"Unknown Lead\";\n\n// === Output ===\nreturn [\n  {\n    json: {\n      lead_name,\n      from_email,\n      subject: subjectHeader,\n      last_message: body,\n      context_language: \"en\",\n      calendar_link: \"https://calendar.google.com/calendar/u/0/r\",\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "116f79fd-ce8d-4b66-bd3d-7083bfe5570a",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1104,
        -144
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {
          "maxTokens": 300,
          "temperature": 0.7
        },
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "=You are an AI Email Assistant for a Gmail-based outreach workflow built on n8n.\n\nYour task:\n- Read the incoming email carefully, especially the message body below:\n---\nEMAIL CONTENT:\n\"{{ $json.last_message }}\"\n---\n- Respond politely, professionally, and concisely (under 150 words).\n- Classify the intent into one of three strict categories.\n- If the email body or subject is missing, unclear, or too short to determine intent, set \"action\": \"needs_review\" instead of guessing.\n\n---\n\n### ACTION CATEGORIES\n\n1. **schedule_meeting**\n   - The lead clearly wants to book, schedule, or discuss a meeting, call, or demo.\n   - Phrases may include: \"schedule a call\", \"book a time\", \"discuss this\", \"set up a meeting\", \"can we talk\".\n   - Your reply must include the Google Calendar link provided in {{ $json.calendar_link }}.\n\n2. **auto_reply**\n   - The lead politely declines, says they\u2019re not interested, already reviewed, or will contact later.\n   - Example phrases: \"no meeting needed\", \"already reviewed\", \"thank you, not now\", \"I\u2019ll get back to you\", \"maybe later\".\n   - Respond briefly, thank them, and DO NOT include the calendar link.\n\n3. **needs_review**\n   - The message is unclear, off-topic, empty, or requires human judgment.\n   - Example: \u201cCan you send more details?\u201d, \u201cWhat exactly do you offer?\u201d.\n   - Return this category if you are uncertain about intent.\n\n---\n\n### RESPONSE GUIDELINES\n\n- Always reply in the same language as the lead ({{ $json.context_language }}).\n- Do not invent any details or new links.\n- Keep tone friendly and natural.\n- Include a one-sentence CRM summary of what the lead expressed.\n- You MUST always output a valid JSON object in this exact schema:\n\n{\n  \"reply\": \"the full email reply text\",\n  \"summary\": \"short CRM summary (1 sentence)\",\n  \"action\": \"schedule_meeting\" | \"auto_reply\" | \"needs_review\"\n}\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "e2927aab-b7a2-4897-896a-915933150257",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -96,
        -96
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "494647f1-82f4-485d-990b-d70a3a4e5393",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        1584,
        0
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "124b3761-030e-4532-89c7-6e870cee3bc9",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json[\"message\"][\"content\"][\"action\"]}}",
                    "rightValue": "=schedule_meeting"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3abc94b2-e672-44ec-aabb-a6e68166bf7e",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json[\"message\"][\"content\"][\"action\"]}}",
                    "rightValue": "auto_reply"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "0de1ef2c-906b-43df-89cc-a99ce27e78ba",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$json[\"message\"][\"content\"][\"action\"]}}",
                    "rightValue": "needs_review"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3,
      "alwaysOutputData": false
    },
    {
      "id": "aa514acf-6fa0-4460-843f-f1fa67a16541",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1424,
        16
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2,
      "alwaysOutputData": false
    },
    {
      "id": "33d04a4a-fdd8-41fd-a9f8-bf5a1f1a45e0",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        240,
        -224
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d639f63f-a53d-47be-b11c-a372cf2a4b8e",
      "name": "Merge (Allowed)",
      "type": "n8n-nodes-base.merge",
      "position": [
        496,
        -160
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "=email",
              "field2": "=from_email"
            }
          ]
        }
      },
      "typeVersion": 3.2,
      "alwaysOutputData": false
    },
    {
      "id": "501cead7-0f59-49f0-b15e-ba81be8c0862",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1872,
        -176
      ],
      "parameters": {
        "end": "={{ $now.plus(2, 'hour') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "additionalFields": {
          "summary": "={{ $json.subject }}\nLead : {{ $json.lead_name }}",
          "attendees": [
            "={{ $json.from_email }}"
          ],
          "description": "=Lead Mail: {{ $json.from_email }}\nSummary: {{ $json.message.content.summary }}\n"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "899ee580-3458-4196-8f18-3bf4896a3ade",
      "name": "Personalize AI Reply",
      "type": "n8n-nodes-base.code",
      "position": [
        2128,
        -112
      ],
      "parameters": {
        "jsCode": "// --- MailPilot: Personalize AI Reply (Schedule Meeting Case, Human Style) ---\nreturn $input.all().map(item => {\n  // === Input verileri ===\n  const name = item.json.first_name || item.json.lead_name || \"there\";\n  const company = item.json.company || \"\";\n  const replyText =\n    item.json.message?.content?.body ||\n    item.json.reply ||\n    \"Thanks for getting back to me!\";\n\n  const link =\n    item.json.calendar_link ||\n    item.json.htmlLink ||\n    item.json.link ||\n    \"\";\n\n  // === Header ===\n  const header = \"\ud83d\udcc5 Let's Schedule a Quick Call\";\n\n  // === HTML Body ===\n  const html = `\n  <div style=\"font-family: Arial, sans-serif; font-size:15px; color:#202124; line-height:1.6; max-width:600px; margin:0 auto;\">\n    <h2 style=\"color:#1a73e8; font-size:18px; margin-bottom:16px;\">${header}</h2>\n    \n    <p>Hi ${name},</p>\n    \n    <p>${replyText}</p>\n    \n    <p>You can book a quick call using my calendar link below:</p>\n    <p><a href=\"${link}\" target=\"_blank\" style=\"color:#1a73e8;\">${link}</a></p>\n    \n    <p>Looking forward to connecting soon!</p>\n    \n    <p>Best regards,<br>\n    <strong>Your Name</strong><br>\n    <small>Your Company</small><br>\n    <a href=\"mailto:yourmail\" style=\"color:#1a73e8;\">yourmail</a></p>\n  </div>\n  `;\n\n  item.json.subject =\n    item.json.subject || \"Schedule a Quick Call \u2014 MailPilot AI Reply\";\n  item.json.finalMessage = html;\n  return item;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fbe4b687-adda-4403-bdb4-0b542d7a901f",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1872,
        560
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "bc8533fd-78f5-4f10-885a-f129125fbfe3",
      "name": "Send AI Reminder Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2576,
        560
      ],
      "parameters": {
        "sendTo": "={{ $('Switch').item.json.from_email }}",
        "message": "={{ $json.finalMessage }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "bb8ef98d-1e84-4745-8cd6-d4f07a911e9b",
      "name": "AI Reminder Generator",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2080,
        560
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an AI assistant for a Gmail-based outreach workflow built on n8n.\nThis branch is for FOLLOW-UP when the lead did NOT clearly ask to schedule.\n\nGoals:\n- Re-engage the lead kindly after a few days.\n- Keep tone friendly, concise, and human-like (under 90 words).\n- Use the same language as the lead ({{ $json.context_language }}).\n- Briefly reference the latest message if relevant ({{ $json.last_message }}).\n\nSTRICT RULES:\n- Do NOT include any calendar/scheduling links.\n- Do NOT suggest booking or \u201cpick a time\u201d.\n- Ask ONE short clarifying question that moves the conversation forward.\n\nOutput strictly as JSON:\n{\n  \"subject\": \"short email subject line\",\n  \"body\": \"personalized follow-up email text WITHOUT any links\"\n}\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "f30a301c-3f3c-4e90-83c8-2b337753f32f",
      "name": "Personalize Greeting",
      "type": "n8n-nodes-base.code",
      "position": [
        2416,
        560
      ],
      "parameters": {
        "jsCode": "// --- MailPilot: Personalize Greeting (Clean white, no background) ---\nreturn $input.all().map(item => {\n  // === 1) Input De\u011ferleri ===\n  const name = item.json.first_name || item.json.lead_name || \"there\";\n  const subject = item.json.subject || \"Following up\";\n  const content = item.json.message?.content?.body || item.json.body || \"\";\n  const senderName = \"Your Name\";\n  const senderEmail = \"Your Mail\";\n\n  // === 2) Ba\u015fl\u0131k (Friendly follow-up tone) ===\n  const header = \"\ud83d\udcac Just Checking In \u2014 Hope You're Doing Well\";\n\n  // === 3) HTML Body (Outbound tarz\u0131 sade) ===\n  const htmlBody = `\n  <div style=\"font-family: Arial, sans-serif; font-size:15px; color:#202124; line-height:1.6; max-width:600px; margin:0 auto;\">\n    <h2 style=\"color:#1a73e8; font-size:18px; margin-bottom:16px;\">${header}</h2>\n\n    <p>Hi ${name},</p>\n\n    <p>I just wanted to quickly follow up on our previous conversation.</p>\n    <p>${content || \"I\u2019d love to reconnect and see how things are going on your end.\"}</p>\n\n    <p>Best regards,<br>\n    <strong>${senderName}</strong><br>\n    <small>Your Company</small><br>\n    <a href=\"mailto:${senderEmail}\" style=\"color:#1a73e8;\">${senderEmail}</a></p>\n  </div>\n  `;\n\n  // === 4) Output ===\n  item.json.subject = subject;\n  item.json.finalMessage = htmlBody;\n  return item;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "06db529f-f27c-44db-9c88-2c95433f7b2a",
      "name": "Send a text message (New Meeting)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2160,
        -352
      ],
      "parameters": {
        "text": "=\ud83d\uddd3 New Meeting Booked!\n\n\ud83d\udc64 Lead: {{ $('Switch').item.json.lead_name }}\n\ud83d\udd52 When: {{ new Date($json.start?.dateTime || Date.now()).toLocaleString('en-EN', { timeZone: $json.start?.timeZone || 'Europe/Istanbul', dateStyle: 'medium', timeStyle: 'short' }) }}\n\ud83e\uddfe Subject: {{ $json.summary || 'No subject' }}\n\ud83d\udd17 Calendar: {{ $json.htmlLink || $json.hangoutLink || $json.meetingLink || '\u2014' }}\n\n\ud83e\udde0 Description:\n{{ $json.description || 'No description available.' }}\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "73e5ebe7-8a37-439e-a00b-576cf3a90699",
      "name": "Send AI Reply (schedule_meeting)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2320,
        -112
      ],
      "parameters": {
        "sendTo": "={{ $('Switch').item.json.from_email }}",
        "message": "={{ $json.finalMessage }}\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $('Switch').item.json.subject }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "4eff830f-78cf-4f82-86c2-6c291cce77b1",
      "name": "Send AI Reply (auto_reply)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2224,
        224
      ],
      "parameters": {
        "sendTo": "={{ $json.from_email }}",
        "message": "={{ $json.finalMessage }}\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re: {{ $json.subject }}\n"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "b6e28f76-f30e-46d7-9e75-58e79c5b7178",
      "name": "Personalize Auto Reply",
      "type": "n8n-nodes-base.code",
      "position": [
        2048,
        224
      ],
      "parameters": {
        "jsCode": "// --- MailPilot: Personalize Auto Reply (Thank You / Not Interested Case, Human Style) ---\nreturn $input.all().map(item => {\n  // === Input verileri ===\n  const name = item.json.first_name || item.json.lead_name || \"there\";\n  const company = item.json.company || \"\";\n  const replyText =\n    item.json.message?.content?.body ||\n    item.json.reply ||\n    \"Thanks for your response!\";\n\n  // === Header ===\n  const header = \"\ud83d\udcac Thanks for Your Interest \u2014 Stay Connected!\";\n\n  // === HTML Body ===\n  const html = `\n  <div style=\"font-family: Arial, sans-serif; font-size:15px; color:#202124; line-height:1.6; max-width:600px; margin:0 auto;\">\n    <h2 style=\"color:#34a853; font-size:18px; margin-bottom:16px;\">${header}</h2>\n    \n    <p>Hi ${name},</p>\n    \n    <p>${replyText}</p>\n    \n    <p>If you ever want to revisit automation ideas or explore new workflows in the future, I\u2019d be happy to help anytime.</p>\n    \n    <p>Best regards,<br>\n    <strong>Your Name</strong><br>\n    <small>Your Company Name</small><br>\n    <a href=\"mailto:yourmail\" style=\"color:#1a73e8;\">yourmail</a></p>\n  </div>\n  `;\n\n  item.json.subject =\n    item.json.subject || \"mail\";\n  item.json.finalMessage = html;\n  return item;\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d6d97fa3-49d6-445f-9791-300d23e587c2",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        688,
        -160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "9c58d318-d7ce-4e67-85c5-3114b3d11a07",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Kabul Edildi"
            },
            {
              "id": "6f4a183d-f826-4b01-8010-2e9c7aadf1cd",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Accepted"
            },
            {
              "id": "8f080a00-4300-41e0-826c-31429684387b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Reddedildi"
            },
            {
              "id": "80ba6773-f2df-46fc-bdd6-1cc4b8b91c6b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Declined"
            },
            {
              "id": "8b0db750-18a9-4012-bbe0-51e7ca9bafc2",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Belki"
            },
            {
              "id": "78955e1e-f299-4b2b-8597-1855c4ee72f5",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Tentative"
            },
            {
              "id": "ceb85329-5529-4544-acc3-3dd10588400f",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Ge\u00e7ici Olarak Kabul Edildi"
            },
            {
              "id": "6005c931-dade-4856-9c0f-6f45668bd175",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Temporarily Accepted"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "adc3deb0-8604-4c26-8a4e-fb6f24ec0dd3",
      "name": "Send a text message (meet accepted)",
      "type": "n8n-nodes-base.telegram",
      "position": [
        912,
        -272
      ],
      "parameters": {
        "text": "=\ud83d\udce9 Calendar Response Received\n\n\ud83d\udc64 Lead: {{ $json.first_name }}\n\ud83d\udce7 Email: {{ $json.email }}\n\ud83d\uddd3\ufe0f Meeting: {{ $json.subject_hint }}\n\ud83d\udccd Status: {{ $json.subject }}\n\n\u2014 The lead responded to your calendar invitation.\n",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "07a341c6-3166-4a6d-baba-2bfa619d9070",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -416
      ],
      "parameters": {
        "width": 320,
        "height": 736,
        "content": "## AI-Powered Inbound Email Assistant with Smart Classification & Auto-Response\n\nThis workflow acts as your personal email assistant. It reads incoming emails, checks if the sender is on your \"whitelist\" (Google Sheets), and uses AI to determine what they want.\n\n### How it works\n1. **Monitors Gmail:** Triggers when a new email arrives.\n2. **Filters & Verifies:** Checks your Google Sheet to ensure the sender is allowed and ignores automated calendar replies.\n3. **AI Classification:** GPT-4 analyzes the intent:\n   - **Schedule:** Books a meeting on Google Calendar and sends a confirmation.\n   - **Decline:** Sends a polite, context-aware \"thank you\" email.\n   - **Unclear:** Waits (e.g., 3 days) and sends a gentle follow-up.\n\n### Setup Steps\n1. **Credentials:** Connect Gmail, Google Sheets, OpenAI, and Google Calendar accounts.\n2. **Whitelist:** Create a Google Sheet with columns: `email`, `first_name`, `company`.\n3. **Config:** Update the \"Wait\" node for your preferred delay (default is set to minutes for testing)."
      },
      "typeVersion": 1
    },
    {
      "id": "8594bbc6-21a2-492f-9069-5c4ed7efd33d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -416
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 608,
        "content": "## 1.  Ingestion & Filtering \ud83d\udce5\nMonitors your inbox, verifies the sender against your allowed list in Google Sheets, and filters out automated calendar responses (Accept/Decline notifications) to prevent loops."
      },
      "typeVersion": 1
    },
    {
      "id": "327fcb92-8f11-4111-a453-a0148256c87c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        -416
      ],
      "parameters": {
        "color": 7,
        "width": 1072,
        "height": 608,
        "content": "##  2. AI Analysis & Routing \ud83e\udde0\nParses the email body and uses GPT-4 to classify the lead's intent into three categories: Schedule Meeting, Auto-Reply (Not Interested), or Needs Review."
      },
      "typeVersion": 1
    },
    {
      "id": "b1de9ca0-f9bf-47a3-84b6-785f9bfeddd2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        -496
      ],
      "parameters": {
        "color": 7,
        "width": 784,
        "height": 576,
        "content": "##  3. Booking & Confirmation \ud83d\udcc5\nAutomatically creates a Google Calendar event for the lead, sends a personalized HTML confirmation email with the link, and notifies you via Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "627689e6-dddf-43c6-af69-e64a9f5ed49b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1888,
        96
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 304,
        "content": "## 4. Polite Decline \ud83d\udcac\nGenerates and sends a courteous, AI-driven response for leads who aren't interested at the moment, without including calendar links."
      },
      "typeVersion": 1
    },
    {
      "id": "62aff496-ea90-4f52-976d-b457b6b1cdac",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        416
      ],
      "parameters": {
        "color": 7,
        "width": 976,
        "height": 336,
        "content": "##  5. Re-engagement \u23f3\nWaits for a set period (configurable), then generates a gentle, context-aware follow-up email to re-engage leads who were unclear or didn't respond."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Europe/Istanbul",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "9ac8867f-5901-45b5-b23e-623706f75436",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send a text message (meet accepted)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "AI Reminder Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Personalize Auto Reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Function Node: Parse Email Content",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        [
          {
            "node": "Personalize AI Reply",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send a text message (New Meeting)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge (Allowed)": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Merge (Allowed)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Personalize AI Reply": {
      "main": [
        [
          {
            "node": "Send AI Reply (schedule_meeting)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Personalize Greeting": {
      "main": [
        [
          {
            "node": "Send AI Reminder Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Reminder Generator": {
      "main": [
        [
          {
            "node": "Personalize Greeting",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Personalize Auto Reply": {
      "main": [
        [
          {
            "node": "Send AI Reply (auto_reply)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send AI Reminder Email": {
      "main": [
        []
      ]
    },
    "Send AI Reply (auto_reply)": {
      "main": [
        []
      ]
    },
    "Send AI Reply (schedule_meeting)": {
      "main": [
        []
      ]
    },
    "Send a text message (New Meeting)": {
      "main": [
        []
      ]
    },
    "Function Node: Parse Email Content": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          },
          {
            "node": "Merge (Allowed)",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}