AutomationFlowsAI & RAG › Triage and Draft Gmail Support Replies with Stripe, Gpt-4.1, and Slack

Triage and Draft Gmail Support Replies with Stripe, Gpt-4.1, and Slack

ByMay Zhan @amayzing on n8n.io

This workflow polls Gmail for new inbox emails, looks up the sender in Stripe to classify them as a customer or non-customer, uses OpenAI plus Google Docs playbooks to draft a reply, and posts the draft to Slack for human review while sending an immediate confirmation email.…

Event trigger★★★★★ complexityAI-powered40 nodesHTTP RequestOpenAI ChatOutput Parser StructuredAgentStripeGmailSlackGmail Trigger
AI & RAG Trigger: Event Nodes: 40 Complexity: ★★★★★ AI nodes: yes Added:
Triage and Draft Gmail Support Replies with Stripe, Gpt-4.1, and Slack — n8n workflow card showing HTTP Request, OpenAI Chat, Output Parser Structured integration

This workflow corresponds to n8n.io template #17891 — 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": "UqpUvwebBDmCFFLH",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Customer Support Triage - Gmail, Stripe, Slack Draft Review",
  "tags": [],
  "nodes": [
    {
      "id": "a293e140-2fc1-4884-a6fb-b283931db090",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -8096,
        736
      ],
      "parameters": {
        "width": 480,
        "height": 896,
        "content": "## AI Customer Support Triage - Gmail, Stripe, Slack Draft Review\n\n### How it works\n\n1. Triggers on new emails in Gmail. 2. Filters and extracts necessary fields from emails. 3. Checks if incoming emails are from existing Stripe customers. 4. Drafts responses using AI based on customer status. 5. Formats and sends drafts to Slack for review.\n\n### Setup steps\n\n- [ ] Connect Gmail credentials through the Gmail trigger and related nodes.\n- [ ] Connect Slack credentials for draft notifications.\n- [ ] Ensure Stripe API key is set in the respective node.\n- [ ] Configure settings for company name, support emails, and SLA response time in the Settings node.\n\n### Customization\n\nYou can customize AI response models and SLA settings as per varying business needs."
      },
      "typeVersion": 1
    },
    {
      "id": "f757eb08-b903-4991-9e9f-45ca951f9ebb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -7536,
        1392
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 272,
        "content": "## Initialize and filter emails\n\nTriggers on new Gmail messages and filters to inbox-only items."
      },
      "typeVersion": 1
    },
    {
      "id": "4f2506e3-e4a1-4da6-abf4-d10c61b975e8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6640,
        992
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 672,
        "content": "## Extraction and metadata retrieval\n\nExtracts key fields from emails and fetches further metadata."
      },
      "typeVersion": 1
    },
    {
      "id": "905cfcd4-1c3c-4cec-b720-41686ab00bc8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5744,
        992
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 272,
        "content": "## Email parsing and thread history\n\nParses email data and retrieves thread history."
      },
      "typeVersion": 1
    },
    {
      "id": "640abe56-a32c-4574-ba25-60c063e912c3",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5072,
        848
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 416,
        "content": "## Stripe customer check\n\nVerifies if the email sender is an existing Stripe customer."
      },
      "typeVersion": 1
    },
    {
      "id": "94925679-8735-4f18-ab66-6cdb1b7c1632",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4400,
        832
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 592,
        "content": "## Support playbook retrieval\n\nFetches appropriate support playbook documents for customers and non-customers."
      },
      "typeVersion": 1
    },
    {
      "id": "2bef0333-0388-462f-81b7-5de7de781eeb",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3952,
        736
      ],
      "parameters": {
        "color": 7,
        "width": 1568,
        "height": 656,
        "content": "## Customer email drafting\n\nBuilds and sends confirmation emails to customers."
      },
      "typeVersion": 1
    },
    {
      "id": "c155485c-1847-47c3-ab74-e73b4196ecea",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4400,
        1456
      ],
      "parameters": {
        "color": 7,
        "width": 1568,
        "height": 480,
        "content": "## Non-customer email drafting\n\nBuilds and sends confirmation emails to non-customers."
      },
      "typeVersion": 1
    },
    {
      "id": "91f5bdd4-6460-4abc-ab6e-6517daff5775",
      "name": "Batch Process Messages",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -6592,
        1504
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "9487e9df-8fab-47f2-bee6-f046eb2a81d2",
      "name": "Post Gmail Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -3616,
        960
      ],
      "parameters": {
        "url": "https://gmail.googleapis.com/gmail/v1/users/me/messages/send",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"raw\": \"{{ $json.raw }}\" }",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "f77f14f6-c4bd-4886-bce1-918ce3b6f5e9",
      "name": "GPT-4 Chat for Customers",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -3312,
        1072
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {
          "maxTokens": 1000,
          "responseFormat": "text"
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f75be399-2701-4791-83d1-5c9e662b0327",
      "name": "Parse Customer Response",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -3184,
        1072
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"email_body\": \"The HTML email response to send to the customer\",\n  \"intent\": \"Brief classification of the customer's request (e.g., billing_inquiry, technical_support, cancellation_request)\",\n  \"sentiment\": \"Customer sentiment: positive, neutral, negative, or frustrated\",\n  \"is_followup\": \"yes or no - whether this appears to be a follow-up to a previous conversation\",\n  \"requires_escalation\": \"yes or no - whether this needs human escalation\",\n  \"escalation_reason\": \"If escalation required, explain why. Otherwise empty string.\",\n  \"internal_notes\": \"Any notes for the support team about this ticket\"\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "adfaf42f-a736-44b5-95bc-6e19348aa397",
      "name": "AI Draft Customer Reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -3328,
        848
      ],
      "parameters": {
        "text": "=Review the email received with the subject: {{ $('Parse Email Content').first().json.Subject }} and email message of: {{ $('Retrieve Full Email Message').first().json.textPlain || $('Retrieve Full Email Message').first().json.snippet }}\n\n## Thread Context\n**Number of previous exchanges:** {{ $('Build Thread Transcript').first().json.messageCount }}\n\n{{ $('Build Thread Transcript').first().json.threadHistory }}\n\nWrite an appropriate email response to this client answering their query while staying aligned with the FAQ guidelines provided below.\n\n## Customer Information\n- **Name:** {{ $('Parse Email Content').first().json.name || 'Valued Customer' }}\n\n## Stripe Customer Data\n- **Stripe Customer ID:** {{ $('Retrieve Stripe Customer Info').first().json.id }}\n- **Customer Name:** {{ $('Retrieve Stripe Customer Info').first().json.name }}\n- **Account Balance:** {{ $('Retrieve Stripe Customer Info').first().json.balance }}\n- **Currency:** {{ $('Retrieve Stripe Customer Info').first().json.currency }}\n- **Created:** {{ $('Retrieve Stripe Customer Info').first().json.created }}\n- **Delinquent:** {{ $('Retrieve Stripe Customer Info').first().json.delinquent }}\n- **Default Payment Method:** {{ $('Retrieve Stripe Customer Info').first().json.invoice_settings?.default_payment_method || 'Not set' }}\n\n## FAQ Guidelines\n{{ $('Access Customer Support Playbook').first().json.content }}\n\n## ESCALATION RULES - MUST FOLLOW\nSet requires_escalation to \"yes\" if ANY of these conditions are met:\n\n1. **Thread length:** The number of previous exchanges has reached the escalation threshold of {{ $('Set Support Parameters').first().json.escalationThreshold }} AND the issue is not resolved\n2. **Exhausted troubleshooting:** Customer has completed all standard troubleshooting steps but issue persists\n3. **Service-side issue:** Problem is isolated to {{ $('Set Support Parameters').first().json.companyName }} only (other streaming services work fine)\n4. **Payment discrepancy:** Customer was charged but has no access, or billing dispute\n5. **Explicit request:** Customer explicitly asks for escalation, supervisor, or technical team\n6. **Legal/formal:** Message is from a lawyer, mentions legal action, BBB, chargeback, or fraud\n7. **VIP/Partnership:** Business inquiry outside normal support scope\n8. **Account security:** Unauthorized access, compromised account, or identity concerns\n9. **Frustrated sentiment:** Customer expresses significant frustration AND has already tried troubleshooting\n\n## Response Instructions\n1. Address the customer by name\n2. Provide a helpful, professional response\n3. Use the Stripe customer data to personalize your response where relevant\n4. If escalation is required, mention the ticket has been escalated to the technical team (do not name the internal ticketing tool)\n5. Sign off as {{ $('Set Support Parameters').first().json.companyName }} Team\n\nReturn your response as structured JSON with: email_body, intent, sentiment, is_followup, requires_escalation, escalation_reason, internal_notes",
        "options": {
          "maxIterations": 2,
          "systemMessage": "=You are a friendly and professional customer support agent for {{ $('Set Support Parameters').first().json.companyName }}. Always output in the required JSON format with all fields: email_body, intent, sentiment, is_followup, requires_escalation, escalation_reason, internal_notes. The email_body should be valid HTML.\n\nIMPORTANT: You MUST carefully evaluate the escalation rules. If the thread has 2+ previous exchanges and the issue isn't resolved, or if the customer has exhausted troubleshooting, you MUST set requires_escalation to \"yes\"."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "executeOnce": false,
      "typeVersion": 1.7
    },
    {
      "id": "a18c4489-dd84-4773-b45e-9776b04ddaae",
      "name": "Retrieve Stripe Customer Info",
      "type": "n8n-nodes-base.stripe",
      "position": [
        -4576,
        960
      ],
      "parameters": {
        "resource": "customer",
        "customerId": "={{ $('Fetch Stripe Customers').first().json.data[0].id }}"
      },
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0630f9f0-ac89-458a-bde5-783fb7ace4a0",
      "name": "Fetch Stripe Customers",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -5024,
        1104
      ],
      "parameters": {
        "url": "https://api.stripe.com/v1/customers",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $('Parse Email Content').first().json.email }}"
            },
            {
              "name": "limit",
              "value": "1"
            }
          ]
        },
        "nodeCredentialType": "stripeApi"
      },
      "credentials": {
        "stripeApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c3caa07d-b9d0-4f30-8802-35e2773f583a",
      "name": "Send Gmail Draft for Customer",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -2976,
        944
      ],
      "parameters": {
        "message": "={{ $json.output.email_body }}",
        "options": {
          "sendTo": "={{ $('Parse Email Content').item.json.email }}",
          "threadId": "={{ $('Parse Email Content').first().json.threadId }}"
        },
        "subject": "=Re: {{ $('Parse Email Content').first().json.Subject.replace(/^Re:\\s*/i, '') }}",
        "resource": "draft",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a73e220b-4b12-4a27-a0be-2f68e2810268",
      "name": "Convert HTML to Slack Format",
      "type": "n8n-nodes-base.code",
      "position": [
        -2752,
        960
      ],
      "parameters": {
        "jsCode": "// Convert HTML to Slack mrkdwn\nconst html = $('AI Draft Customer Reply').first().json.output.email_body;\n\nconst slackBody = html\n  // Convert links\n  .replace(/<a\\s+href=[\"']([^\"']+)[\"'][^>]*>([^<]+)<\\/a>/gi, '<$1|$2>')\n  // Convert bold\n  .replace(/<(strong|b)>([^<]+)<\\/(strong|b)>/gi, '*$2*')\n  // Convert italic\n  .replace(/<(em|i)>([^<]+)<\\/(em|i)>/gi, '_$2_')\n  // Convert ordered lists - number each item\n  .replace(/<ol[^>]*>([\\s\\S]*?)<\\/ol>/gi, (match, content) => {\n    let counter = 0;\n    return content.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, (m, text) => {\n      counter++;\n      return `${counter}. ${text.trim()}\\n`;\n    });\n  })\n  // Convert unordered lists - bullet each item\n  .replace(/<ul[^>]*>([\\s\\S]*?)<\\/ul>/gi, (match, content) => {\n    return content.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, '\u2022 $1\\n');\n  })\n  // Catch any remaining standalone <li> tags\n  .replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, '\u2022 $1\\n')\n  // Horizontal rules\n  .replace(/<hr\\s*\\/?>/gi, '\\n---\\n')\n  // Paragraphs\n  .replace(/<p>/gi, '')\n  .replace(/<\\/p>/gi, '\\n\\n')\n  // Line breaks\n  .replace(/<br\\s*\\/?>/gi, '\\n')\n  // Clean up extra newlines\n  .replace(/\\n{3,}/g, '\\n\\n')\n  .trim();\n\nreturn [{ json: { email_body: slackBody } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "6a95996f-1df7-4249-90e1-215af77a5480",
      "name": "Check Stripe Customer",
      "type": "n8n-nodes-base.if",
      "position": [
        -4800,
        1104
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "375f3d29-0b74-4d4c-84df-d276672a3359",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.data.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "b889b0af-d62b-475a-9029-d43dd6f56638",
      "name": "Compose Customer Confirmation Email",
      "type": "n8n-nodes-base.code",
      "position": [
        -3904,
        960
      ],
      "parameters": {
        "jsCode": "// Build the auto-acknowledgement email as a base64url encoded RFC822 message.\nconst settings = $('Set Support Parameters').first().json;\nconst companyName = settings.companyName;\nconst fromAddress = settings.supportFromEmail;\nconst sla = settings.responseTimeSla || '24 hours';\n\nconst parseEmail = $('Parse Email Content').first().json;\nconst recipient = parseEmail.email;\nconst firstName = parseEmail.firstName || parseEmail.name?.split(' ')[0] || 'Valued Customer';\n\nconst subject = \"Confirmation: Request Received\";\n\nconst body = `\n<p>Hello ${firstName},</p>\n\n<p>Thank you for contacting ${companyName}! Our team has received your request, and we'll get back to you within <strong>${sla}</strong>.</p>\n\n<p>Best regards,<br>\n${companyName} Team</p>\n`;\n\nconst email = [\n  `From: ${companyName} <${fromAddress}>`,\n  `To: ${recipient}`,\n  \"Subject: \" + subject,\n  \"Content-Type: text/html; charset=UTF-8\",\n  \"\",\n  body\n].join(\"\\n\");\n\nconst encodedEmail = Buffer.from(email)\n  .toString(\"base64\")\n  .replace(/\\+/g, \"-\")\n  .replace(/\\//g, \"_\")\n  .replace(/=+$/, \"\");\n\nreturn [{ json: { raw: encodedEmail } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ed509a70-06cb-4dc0-b60d-0c7607f342b2",
      "name": "Post Non-Customer Confirmation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -4128,
        1568
      ],
      "parameters": {
        "url": "https://gmail.googleapis.com/gmail/v1/users/me/messages/send",
        "method": "POST",
        "options": {},
        "jsonBody": "={ \"raw\": \"{{ $json.raw }}\" }",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "21c8f1cf-2e4d-49ee-aa85-bc2fd4fefe6e",
      "name": "GPT-4 Chat for Non-Customers",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -3904,
        1792
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {
          "maxTokens": 1000,
          "responseFormat": "text"
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "80ad8a42-b7b4-4ac8-aedc-15a6347ab979",
      "name": "Parse Non-Customer Response",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -3776,
        1792
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"email_body\": \"The HTML email response to send to the non-customer\",\n  \"intent\": \"Brief classification of the inquiry (e.g., pricing_inquiry, general_question, partnership_request)\",\n  \"sentiment\": \"Sender sentiment: positive, neutral, negative, or frustrated\",\n  \"is_followup\": \"yes or no - whether this appears to be a follow-up to a previous conversation\",\n  \"requires_escalation\": \"yes or no - whether this needs human escalation\",\n  \"escalation_reason\": \"If escalation required, explain why. Otherwise empty string.\",\n  \"internal_notes\": \"Any notes for the support team about this inquiry\"\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "03125761-847d-4065-9619-4e757b4219f8",
      "name": "AI Draft Non-Customer Reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -3904,
        1568
      ],
      "parameters": {
        "text": "=Review the email received with the subject: {{ $('Parse Email Content').first().json.Subject }} and email message of: {{ $('Retrieve Full Email Message').first().json.textPlain || $('Retrieve Full Email Message').first().json.snippet }}\n\n## Thread Context\n**Number of previous exchanges:** {{ $('Build Thread Transcript').first().json.messageCount }}\n\n{{ $('Build Thread Transcript').first().json.threadHistory }}\n\nWrite an appropriate email response to this person answering their query while staying aligned with the FAQ guidelines provided below.\n\n## Sender Information\n- **Name:** {{ $('Parse Email Content').first().json.name || 'there' }}\n- **Email:** {{ $('Parse Email Content').first().json.email }}\n\n**Note:** This person is NOT a current subscriber in our system.\n\n## FAQ Guidelines\n{{ $('Access Non-Cust Support Playbook').first().json.content }}\n\n## ESCALATION RULES - MUST FOLLOW\nSet requires_escalation to \"yes\" if ANY of these conditions are met:\n\n1. **Thread length:** The number of previous exchanges has reached the escalation threshold of {{ $('Set Support Parameters').first().json.escalationThreshold }} AND the issue is not resolved\n2. **Exhausted troubleshooting:** Person has completed all standard troubleshooting steps but issue persists\n3. **Service-side issue:** Problem is isolated to {{ $('Set Support Parameters').first().json.companyName }} only (other streaming services work fine)\n4. **Explicit request:** Person explicitly asks for escalation, supervisor, or technical team\n5. **Legal/formal:** Message is from a lawyer, mentions legal action, BBB, chargeback, or fraud\n6. **VIP/Partnership:** Business inquiry, partnership request, or licensing question\n7. **Frustrated sentiment:** Person expresses significant frustration AND has already tried troubleshooting\n8. **Complex billing:** Refund requests, disputed charges, or payment issues\n\n## Response Instructions\n1. Address the sender by name if available\n2. Provide a helpful, professional response\n3. Since they are not a customer, guide them toward subscription options if relevant\n4. If escalation is required, mention the ticket has been escalated to the appropriate team (do not name the internal ticketing tool)\n5. Sign off as {{ $('Set Support Parameters').first().json.companyName }} Team\n\nReturn your response as structured JSON with: email_body, intent, sentiment, is_followup, requires_escalation, escalation_reason, internal_notes",
        "options": {
          "maxIterations": 2,
          "systemMessage": "=You are a friendly and professional customer support agent for {{ $('Set Support Parameters').first().json.companyName }}. This inquiry is from someone who is NOT a current subscriber. Always output in the required JSON format with all fields: email_body, intent, sentiment, is_followup, requires_escalation, escalation_reason, internal_notes. The email_body should be valid HTML.\n\nIMPORTANT: You MUST carefully evaluate the escalation rules. If the thread has 2+ previous exchanges and the issue isn't resolved, or if the person has exhausted troubleshooting, you MUST set requires_escalation to \"yes\"."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "executeOnce": false,
      "typeVersion": 1.7
    },
    {
      "id": "2acc5296-28b6-4355-9918-7f1f40505eaa",
      "name": "Send Gmail Draft for Non-Customer",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -3488,
        1568
      ],
      "parameters": {
        "message": "={{ $json.output.email_body }}",
        "options": {
          "sendTo": "={{ $('Parse Email Content').item.json.email }}",
          "threadId": "={{ $('Parse Email Content').first().json.threadId }}"
        },
        "subject": "=Re: {{ $('Parse Email Content').first().json.Subject.replace(/^Re:\\s*/i, '') }}",
        "resource": "draft",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a3714d1-f184-46c3-aed5-7aba06caddbf",
      "name": "Convert HTML to Slack for Non-Cust",
      "type": "n8n-nodes-base.code",
      "position": [
        -3200,
        1568
      ],
      "parameters": {
        "jsCode": "// Convert HTML to Slack mrkdwn\nconst html = $('AI Draft Non-Customer Reply').first().json.output.email_body;\n\nconst slackBody = html\n  // Convert links\n  .replace(/<a\\s+href=[\"']([^\"']+)[\"'][^>]*>([^<]+)<\\/a>/gi, '<$1|$2>')\n  // Convert bold\n  .replace(/<(strong|b)>([^<]+)<\\/(strong|b)>/gi, '*$2*')\n  // Convert italic\n  .replace(/<(em|i)>([^<]+)<\\/(em|i)>/gi, '_$2_')\n  // Convert ordered lists - number each item\n  .replace(/<ol[^>]*>([\\s\\S]*?)<\\/ol>/gi, (match, content) => {\n    let counter = 0;\n    return content.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, (m, text) => {\n      counter++;\n      return `${counter}. ${text.trim()}\\n`;\n    });\n  })\n  // Convert unordered lists - bullet each item\n  .replace(/<ul[^>]*>([\\s\\S]*?)<\\/ul>/gi, (match, content) => {\n    return content.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, '\u2022 $1\\n');\n  })\n  // Catch any remaining standalone <li> tags\n  .replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, '\u2022 $1\\n')\n  // Horizontal rules\n  .replace(/<hr\\s*\\/?>/gi, '\\n---\\n')\n  // Paragraphs\n  .replace(/<p>/gi, '')\n  .replace(/<\\/p>/gi, '\\n\\n')\n  // Line breaks\n  .replace(/<br\\s*\\/?>/gi, '\\n')\n  // Clean up extra newlines\n  .replace(/\\n{3,}/g, '\\n\\n')\n  .trim();\n\nreturn [{ json: { email_body: slackBody } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "3fb8a8f3-1708-4770-a29a-b71698e90bca",
      "name": "Compose Non-Customer Confirmation",
      "type": "n8n-nodes-base.code",
      "position": [
        -4352,
        1568
      ],
      "parameters": {
        "jsCode": "// Build the auto-acknowledgement email as a base64url encoded RFC822 message.\nconst settings = $('Set Support Parameters').first().json;\nconst companyName = settings.companyName;\nconst fromAddress = settings.supportFromEmail;\nconst sla = settings.responseTimeSla || '24 hours';\n\nconst parseEmail = $('Parse Email Content').first().json;\nconst recipient = parseEmail.email;\nconst firstName = parseEmail.firstName || parseEmail.name?.split(' ')[0] || 'there';\n\nconst subject = \"Confirmation: Request Received\";\n\nconst body = `\n<p>Hello ${firstName},</p>\n\n<p>Thank you for contacting ${companyName}! Our team has received your request, and we'll get back to you within <strong>${sla}</strong>.</p>\n\n<p>Best regards,<br>\n${companyName} Team</p>\n`;\n\nconst email = [\n  `From: ${companyName} <${fromAddress}>`,\n  `To: ${recipient}`,\n  \"Subject: \" + subject,\n  \"Content-Type: text/html; charset=UTF-8\",\n  \"\",\n  body\n].join(\"\\n\");\n\nconst encodedEmail = Buffer.from(email)\n  .toString(\"base64\")\n  .replace(/\\+/g, \"-\")\n  .replace(/\\//g, \"_\")\n  .replace(/=+$/, \"\");\n\nreturn [{ json: { raw: encodedEmail } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fcca634c-a32b-465d-8669-5bdfc40979a6",
      "name": "Post Non-Customer Draft to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        -2976,
        1568
      ],
      "parameters": {
        "text": "=\ud83d\udce7 *Non-Customer Support Draft Ready*\n\n*Name:* {{ $('Parse Email Content').first().json.name || 'Unknown' }}\n*Email:* {{ $('Parse Email Content').first().json.email }}\n*Subject:* {{ $('Parse Email Content').first().json.Subject }}\n*Thread Exchanges:* {{ $('Build Thread Transcript').first().json.messageCount }}\n\n\u26a0\ufe0f *Not a Stripe customer*\n\n*Intent:* {{ $('AI Draft Non-Customer Reply').first().json.output.intent }}\n*Sentiment:* {{ $('AI Draft Non-Customer Reply').first().json.output.sentiment }}\n*Is Follow-up:* {{ $('AI Draft Non-Customer Reply').first().json.output.is_followup }}\n*Requires Escalation:* {{ $('AI Draft Non-Customer Reply').first().json.output.requires_escalation }}\n{{ $('AI Draft Non-Customer Reply').first().json.output.requires_escalation === 'yes' ? '\ud83d\udea8 *ESCALATION REASON:* ' + $('AI Draft Non-Customer Reply').first().json.output.escalation_reason : '' }}\n\n---\n*Internal Notes:*\n{{ $('AI Draft Non-Customer Reply').first().json.output.internal_notes || 'None' }}\n\n---\n*Draft Response:*\n{{ $json.email_body }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SLACK_CHANNEL_ID"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a08b0e7d-8db4-4633-955b-b848ce6f0915",
      "name": "Post Customer Draft to Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        -2528,
        1232
      ],
      "parameters": {
        "text": "=\ud83d\udce7 *Customer Support Draft Ready*\n\n*Name:* {{ $('Retrieve Stripe Customer Info').first().json.name || $('Parse Email Content').first().json.name }}\n*Email:* {{ $('Retrieve Stripe Customer Info').first().json.email }}\n*Stripe Customer ID:* {{ $('Retrieve Stripe Customer Info').first().json.id }}\n*Account Balance:* {{ $('Retrieve Stripe Customer Info').first().json.balance }} {{ $('Retrieve Stripe Customer Info').first().json.currency }}\n*Delinquent:* {{ $('Retrieve Stripe Customer Info').first().json.delinquent ? '\u26a0\ufe0f Yes' : 'No' }}\n*Subject:* {{ $('Parse Email Content').first().json.Subject }}\n*Thread Exchanges:* {{ $('Build Thread Transcript').first().json.messageCount }}\n\n*Intent:* {{ $('AI Draft Customer Reply').first().json.output.intent }}\n*Sentiment:* {{ $('AI Draft Customer Reply').first().json.output.sentiment }}\n*Is Follow-up:* {{ $('AI Draft Customer Reply').first().json.output.is_followup }}\n*Requires Escalation:* {{ $('AI Draft Customer Reply').first().json.output.requires_escalation }}\n{{ $('AI Draft Customer Reply').first().json.output.requires_escalation === 'yes' ? '\ud83d\udea8 *ESCALATION REASON:* ' + $('AI Draft Customer Reply').first().json.output.escalation_reason : '' }}\n\n---\n*Internal Notes:*\n{{ $('AI Draft Customer Reply').first().json.output.internal_notes || 'None' }}\n\n---\n*Draft Response:*\n{{ $json.email_body }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SLACK_CHANNEL_ID"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0a389624-6be0-4677-a8ce-af86f0b2eb06",
      "name": "Filter Only Inbox Emails",
      "type": "n8n-nodes-base.filter",
      "position": [
        -7040,
        1504
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9744e598-6f56-412b-a0ad-588f4442d8d5",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.labels[0].name }}",
              "rightValue": "INBOX"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4b9ebf3d-aac7-45ab-b835-dc0398d58603",
      "name": "Retrieve Full Email Message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -6816,
        1504
      ],
      "parameters": {
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "378bf322-e45d-48a3-96dc-88b9a0220997",
      "name": "Extract Key Email Details",
      "type": "n8n-nodes-base.set",
      "position": [
        -6368,
        1104
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c9fc731d-b2d0-4171-8fc7-d8868e2c5c44",
              "name": "From",
              "type": "string",
              "value": "={{ $json.From }}"
            },
            {
              "id": "05f7d3e0-ae00-4bb9-8948-f7ab86ba84b3",
              "name": "Subject",
              "type": "string",
              "value": "={{ $json.Subject }}"
            },
            {
              "id": "46a19568-68d4-4241-ab93-bd841136f558",
              "name": "threadId",
              "type": "string",
              "value": "={{ $json.threadId }}"
            },
            {
              "id": "498d7917-5376-4ea9-9995-0372110d762a",
              "name": "id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "c2c4d41a-6d9f-4f10-9cda-f7805b753e59",
              "name": "snippet",
              "type": "string",
              "value": "={{ $json.snippet }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fc70d0b9-9b7f-4f91-a71a-817e39326315",
      "name": "Fetch Email Metadata",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -6144,
        1104
      ],
      "parameters": {
        "url": "=https://gmail.googleapis.com/gmail/v1/users/me/messages/{{ $json.id }}?format=metadata",
        "options": {},
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8a8c3083-6f5c-4005-903a-24e71d0edff0",
      "name": "Retrieve Email Thread History",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -5472,
        1104
      ],
      "parameters": {
        "options": {},
        "resource": "thread",
        "threadId": "={{ $('Extract Gmail Thread ID').first().json.threadId }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a5409c5-4eb2-421b-bbfb-7a9b313f0e55",
      "name": "Extract Gmail Thread ID",
      "type": "n8n-nodes-base.code",
      "position": [
        -5920,
        1104
      ],
      "parameters": {
        "jsCode": "// Get thread ID directly from Gmail response (not from headers)\nconst threadId = $json.threadId;\nconst messageId = $json.id;\n\n// Also get Message-ID header if you still need it\nconst headers = $json.payload?.headers || [];\nconst messageIdHeader = headers.find(h => h.name === 'Message-ID');\nconst emailMessageId = messageIdHeader ? messageIdHeader.value : null;\n\nreturn [{ \n  json: { \n    threadId,      // Gmail thread ID (use this for Thread \u2192 Get)\n    messageId,     // Gmail message ID\n    emailMessageId // Email header Message-ID (for References header)\n  } \n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e816cd37-f685-4e99-8a89-48c74b539105",
      "name": "When Email Sent via Gmail",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -7488,
        1504
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0cf983d7-b3e2-4646-a498-09d5bd42b18c",
      "name": "Parse Email Content",
      "type": "n8n-nodes-base.code",
      "position": [
        -5696,
        1104
      ],
      "parameters": {
        "jsCode": "// Code node (JavaScript) \u2014 Run Once for All Items\n// Reads fields from \"Edit Fields\" safely and adds \"Re: \" if not present.\n\nconst editItem = ($items(\"Extract Key Email Details\")[0]?.json) ?? {};\nconst fromRaw = String(editItem.From ?? \"\").trim();\n\n// --- Parse name + email ---\nlet name = null;\nlet email = null;\n\nconst angleMatch = fromRaw.match(/^\\s*(?:\"?([^\"<]+?)\"?\\s*)?<\\s*([^>]+)\\s*>\\s*$/); // Name <email>\nif (angleMatch) {\n  name  = angleMatch[1]?.trim() || null;\n  email = angleMatch[2].trim();\n} else {\n  const emailMatch = fromRaw.match(/([A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,})/i);\n  if (emailMatch) {\n    email = emailMatch[1].trim();\n    const before = fromRaw.slice(0, fromRaw.indexOf(email))\n                          .replace(/[<>\"()]/g, \"\")\n                          .trim();\n    name = before || null;\n  }\n}\n\nlet firstName = name ? name.split(/\\s+/)[0] : null;\nconst formatted = email ? (name ? `${name} <${email}>` : `<${email}>`) : \"\";\n\n// --- Subject logic with \"Re:\" ---\nlet subject = editItem.Subject ?? \"\";\nif (subject && !/^Re:/i.test(subject)) {\n  subject = `Re: ${subject.trim()}`;\n}\n\n// --- Pass through other fields ---\nconst threadId = editItem.threadId ?? null;\nconst id       = editItem.id ?? null;\n\n// --- Output single item ---\nreturn [{\n  json: {\n    fromRaw,\n    name,\n    firstName,\n    email,\n    formatted,\n    Subject: subject,   // now automatically prefixed with \"Re:\" if needed\n    threadId,\n    id\n  }\n}];\n\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a64d7747-6f52-4c69-b0bc-8ebeb4cbf2f2",
      "name": "Build Thread Transcript",
      "type": "n8n-nodes-base.code",
      "position": [
        -5248,
        1104
      ],
      "parameters": {
        "jsCode": "// Build a readable thread transcript and count prior exchanges.\n// Support-side messages are identified from the address list in the Settings node.\nconst settings = $('Set Support Parameters').first().json;\nconst supportAddresses = String(settings.supportEmailAddresses || '')\n  .split(',')\n  .map(s => s.trim().toLowerCase())\n  .filter(Boolean);\n\nconst messages = $input.all();\nconst currentMessageId = $('Extract Key Email Details').item.json.id;\n\nconst history = messages\n  .filter(msg => msg.json.id !== currentMessageId)\n  .sort((a, b) => parseInt(a.json.internalDate || 0) - parseInt(b.json.internalDate || 0))\n  .map(msg => {\n    const from = String(msg.json.From || '').toLowerCase();\n    const date = new Date(parseInt(msg.json.internalDate || 0)).toLocaleString();\n    const snippet = msg.json.snippet || '';\n    const isSupport = supportAddresses.some(addr => from.includes(addr));\n    return '[' + (isSupport ? 'SUPPORT' : 'CUSTOMER') + ' - ' + date + ']:\\n' + snippet;\n  });\n\nconst threadHistory = history.length > 0\n  ? '## Previous Messages\\n\\n' + history.join('\\n\\n---\\n\\n')\n  : 'No previous messages in thread.';\n\nreturn [{ json: { threadHistory: threadHistory, messageCount: history.length } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "7533561a-1f65-4452-b60b-dd311e6e3ef1",
      "name": "Access Customer Support Playbook",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        -4128,
        960
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/YOUR_GOOGLE_DOC_ID/edit"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "36f04867-c9f9-40b9-90de-51ccbac4d4c2",
      "name": "Access Non-Cust Support Playbook",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        -4352,
        1248
      ],
      "parameters": {
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/YOUR_GOOGLE_DOC_ID/edit"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ea1a556e-2f45-438b-ad60-25f63e57e1c9",
      "name": "Set Support Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        -7264,
        1504
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1+1234567890-+1234567890",
              "name": "companyName",
              "type": "string",
              "value": "Your Company"
            },
            {
              "id": "a1+1234567890-+1234567890",
              "name": "supportFromEmail",
              "type": "string",
              "value": "user@example.com"
            },
            {
              "id": "a1+1234567890-+1234567890",
              "name": "supportEmailAddresses",
              "type": "string",
              "value": "user@example.com,user@example.com,user@example.com"
            },
            {
              "id": "a1+1234567890-+1234567890",
              "name": "responseTimeSla",
              "type": "string",
              "value": "24 hours"
            },
            {
              "id": "a1+1234567890-+1234567890",
              "name": "escalationThreshold",
              "type": "string",
              "value": "2"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "f36ede4e-7f8e-4ec5-972f-6d4d0e48e582",
  "nodeGroups": [],
  "connections": {
    "Parse Email Content": {
      "main": [
        [
          {
            "node": "Retrieve Email Thread History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Email Metadata": {
      "main": [
        [
          {
            "node": "Extract Gmail Thread ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Stripe Customer": {
      "main": [
        [
          {
            "node": "Retrieve Stripe Customer Info",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Access Non-Cust Support Playbook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Process Messages": {
      "main": [
        [],
        [
          {
            "node": "Extract Key Email Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Stripe Customers": {
      "main": [
        [
          {
            "node": "Check Stripe Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Support Parameters": {
      "main": [
        [
          {
            "node": "Filter Only Inbox Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Draft Customer Reply": {
      "main": [
        [
          {
            "node": "Send Gmail Draft for Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Thread Transcript": {
      "main": [
        [
          {
            "node": "Fetch Stripe Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Gmail Thread ID": {
      "main": [
        [
          {
            "node": "Parse Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Customer Response": {
      "ai_outputParser": [
        [
          {
            "node": "AI Draft Customer Reply",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Post Gmail Confirmation": {
      "main": [
        [
          {
            "node": "AI Draft Customer Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Only Inbox Emails": {
      "main": [
        [
          {
            "node": "Retrieve Full Email Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Chat for Customers": {
      "ai_languageModel": [
        [
          {
            "node": "AI Draft Customer Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Key Email Details": {
      "main": [
        [
          {
            "node": "Fetch Email Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Email Sent via Gmail": {
      "main": [
        [
          {
            "node": "Set Support Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Draft Non-Customer Reply": {
      "main": [
        [
          {
            "node": "Send Gmail Draft for Non-Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Non-Customer Response": {
      "ai_outputParser": [
        [
          {
            "node": "AI Draft Non-Customer Reply",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Full Email Message": {
      "main": [
        [
          {
            "node": "Batch Process Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert HTML to Slack Format": {
      "main": [
        [
          {
            "node": "Post Customer Draft to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Chat for Non-Customers": {
      "ai_languageModel": [
        [
          {
            "node": "AI Draft Non-Customer Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Post Customer Draft to Slack": {
      "main": [
        [
          {
            "node": "Batch Process Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Email Thread History": {
      "main": [
        [
          {
            "node": "Build Thread Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Stripe Customer Info": {
      "main": [
        [
          {
            "node": "Access Customer Support Playbook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Gmail Draft for Customer": {
      "main": [
        [
          {
            "node": "Convert HTML to Slack Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Non-Customer Confirmation": {
      "main": [
        [
          {
            "node": "AI Draft Non-Customer Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Access Customer Support Playbook": {
      "main": [
        [
          {
            "node": "Compose Customer Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Access Non-Cust Support Playbook": {
      "main": [
        [
          {
            "node": "Compose Non-Customer Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Non-Customer Draft to Slack": {
      "main": [
        [
          {
            "node": "Batch Process Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Non-Customer Confirmation": {
      "main": [
        [
          {
            "node": "Post Non-Customer Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Gmail Draft for Non-Customer": {
      "main": [
        [
          {
            "node": "Convert HTML to Slack for Non-Cust",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert HTML to Slack for Non-Cust": {
      "main": [
        [
          {
            "node": "Post Non-Customer Draft to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Customer Confirmation Email": {
      "main": [
        [
          {
            "node": "Post Gmail Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

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

About this workflow

This workflow polls Gmail for new inbox emails, looks up the sender in Stripe to classify them as a customer or non-customer, uses OpenAI plus Google Docs playbooks to draft a reply, and posts the draft to Slack for human review while sending an immediate confirmation email.…

Source: https://n8n.io/workflows/17891/ — 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

Transcript Evalu8r V2 is a robust browser-based transcript analysis tool powered by Deepgram’s speech-to-text API and built into an n8n workflow template. This release introduces full in-browser audio

Google Drive Trigger, HTTP Request, Agent +5
AI & RAG

Transcript Evalu8r is an AI-powered transcript analysis workflow that automates the processing, visualization, and evaluation of transcribed conversations. This n8n workflow template is designed to he

Google Drive Trigger, HTTP Request, Agent +5
AI & RAG

Portfolio 1: Invoice manager. Uses gmailTrigger, googleDrive, agent, lmChatOpenAi. Event-driven trigger; 54 nodes.

Gmail Trigger, Google Drive, Agent +7
AI & RAG

This n8n workflow automates sales processes using AI agents integrated with Airtable as a CRM and Gmail for email handling. It consists of two main workflows: one for handling Airtable status changes

Airtable Trigger, Agent, OpenAI Chat +9
AI & RAG

mails2notion V2. Uses lmChatOpenAi, toolCalculator, outputParserStructured, gmail. Event-driven trigger; 38 nodes.

OpenAI Chat, Tool Calculator, Output Parser Structured +5