AutomationFlowsAI & RAG › Personalized Customer Retention Campaigns with Gpt-4o Analytics & Gmail

Personalized Customer Retention Campaigns with Gpt-4o Analytics & Gmail

ByCheng Siong Chin @cschin on n8n.io

This workflow automates end-to-end data intelligence processing by ingesting structured data (CSV, JSON), enriching it through multiple AI analysis pathways, and generating actionable insights. Designed for business analysts, data scientists, and operations teams, it solves the…

Cron / scheduled trigger★★★★★ complexityAI-powered37 nodesHTTP RequestOpenAI ChatOutput Parser StructuredMcp Client ToolGmail ToolAgentHTTP Request Tool
AI & RAG Trigger: Cron / scheduled Nodes: 37 Complexity: ★★★★★ AI nodes: yes Added:

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

This workflow follows the Agent → Gmail Tool 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": "op5nQmzjjS8pioex",
  "name": "Smart Customer Retention & Win-Back GPT-4o System",
  "tags": [],
  "nodes": [
    {
      "id": "ffff686b-860e-462e-bc29-801cdb11ef8c",
      "name": "Daily Churn Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2112,
        704
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 2
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "d179dd36-9f8e-42d8-93e6-ce8fc23ac8d2",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1888,
        704
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "customerApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Customer API endpoint URL__>"
            },
            {
              "id": "id-2",
              "name": "churnThreshold",
              "type": "number",
              "value": 0.7
            },
            {
              "id": "id-3",
              "name": "inactiveDays",
              "type": "number",
              "value": 30
            },
            {
              "id": "id-4",
              "name": "trackingApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Campaign tracking API endpoint__>"
            },
            {
              "id": "id-5",
              "name": "strategyApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Strategy update API endpoint__>"
            },
            {
              "id": "id-6",
              "name": "sentimentApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Sentiment analysis API endpoint__>"
            },
            {
              "id": "id-7",
              "name": "usageAnalyticsApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Product usage analytics API endpoint__>"
            },
            {
              "id": "id-8",
              "name": "emailEngagementApiUrl",
              "type": "string",
              "value": "<__PLACEHOLDER_VALUE__Email engagement tracking API endpoint__>"
            },
            {
              "id": "id-9",
              "name": "highRiskThreshold",
              "type": "number",
              "value": 85
            },
            {
              "id": "id-10",
              "name": "mediumRiskThreshold",
              "type": "number",
              "value": 70
            },
            {
              "id": "id-11",
              "name": "emailWaitHours",
              "type": "number",
              "value": 48
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "5979b14b-e42a-4815-b11e-f0d3a11cb7ed",
      "name": "Fetch Customer Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1664,
        704
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.customerApiUrl }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "include_activity",
              "value": "true"
            },
            {
              "name": "include_purchases",
              "value": "true"
            },
            {
              "name": "include_subscriptions",
              "value": "true"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "92c67f03-1249-48cf-a2b1-872b62d51d5f",
      "name": "Calculate Churn Signals",
      "type": "n8n-nodes-base.code",
      "position": [
        -1440,
        704
      ],
      "parameters": {
        "jsCode": "// Calculate churn signals for all customers\nconst enrichedCustomers = [];\n\nfor (const item of $input.all()) {\n  const customer = item.json;\n  \n  // Calculate days since last activity\n  const lastActivityDate = customer.last_activity_date ? new Date(customer.last_activity_date) : null;\n  const daysSinceLastActivity = lastActivityDate ? \n    Math.floor((new Date() - lastActivityDate) / (1000 * 60 * 60 * 24)) : 999;\n  \n  // Calculate purchase recency (days since last purchase)\n  const lastPurchaseDate = customer.last_purchase_date ? new Date(customer.last_purchase_date) : null;\n  const purchaseRecency = lastPurchaseDate ? \n    Math.floor((new Date() - lastPurchaseDate) / (1000 * 60 * 60 * 24)) : 999;\n  \n  // Determine subscription status\n  const subscriptionStatus = customer.subscription_status || 'unknown';\n  const isActiveSubscription = subscriptionStatus === 'active';\n  \n  // Calculate engagement score (0-100)\n  const loginCount = customer.login_count || 0;\n  const emailOpenRate = customer.email_open_rate || 0;\n  const featureUsage = customer.feature_usage_count || 0;\n  \n  const engagementScore = Math.min(100, \n    (loginCount * 2) + \n    (emailOpenRate * 50) + \n    (featureUsage * 3)\n  );\n  \n  // Calculate overall churn risk score (0-100, higher = more risk)\n  let churnRiskScore = 0;\n  \n  // Factor 1: Days since last activity (max 40 points)\n  if (daysSinceLastActivity > 90) churnRiskScore += 40;\n  else if (daysSinceLastActivity > 60) churnRiskScore += 30;\n  else if (daysSinceLastActivity > 30) churnRiskScore += 20;\n  else if (daysSinceLastActivity > 14) churnRiskScore += 10;\n  \n  // Factor 2: Purchase recency (max 25 points)\n  if (purchaseRecency > 180) churnRiskScore += 25;\n  else if (purchaseRecency > 120) churnRiskScore += 20;\n  else if (purchaseRecency > 90) churnRiskScore += 15;\n  else if (purchaseRecency > 60) churnRiskScore += 10;\n  \n  // Factor 3: Subscription status (max 15 points)\n  if (!isActiveSubscription) churnRiskScore += 15;\n  else if (subscriptionStatus === 'trial') churnRiskScore += 10;\n  \n  // Factor 4: Engagement score (max 20 points, inverse)\n  if (engagementScore < 20) churnRiskScore += 20;\n  else if (engagementScore < 40) churnRiskScore += 15;\n  else if (engagementScore < 60) churnRiskScore += 10;\n  else if (engagementScore < 80) churnRiskScore += 5;\n  \n  // Ensure score is between 0-100\n  churnRiskScore = Math.min(100, Math.max(0, churnRiskScore));\n  \n  // Enrich customer data with churn signals\n  enrichedCustomers.push({\n    json: {\n      ...customer,\n      churn_signals: {\n        days_since_last_activity: daysSinceLastActivity,\n        purchase_recency: purchaseRecency,\n        subscription_status: subscriptionStatus,\n        engagement_score: engagementScore,\n        churn_risk_score: churnRiskScore\n      },\n      churn_risk_score: churnRiskScore\n    }\n  });\n}\n\nreturn enrichedCustomers;"
      },
      "typeVersion": 2
    },
    {
      "id": "c36a7606-5737-472b-9519-7a138bb0a0c5",
      "name": "Check Churn Risk",
      "type": "n8n-nodes-base.if",
      "position": [
        -1216,
        704
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $('Calculate Churn Signals').item.json.churn_risk_score }}",
              "rightValue": "={{ $('Workflow Configuration').first().json.churnThreshold }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d2cea499-bd4c-4583-94d6-7b73cc47fd09",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        848,
        400
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "209aadf4-1496-4835-90d6-9c1a7713aa46",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1104,
        400
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"customerEmail\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Customer email address\"\n\t\t},\n\t\t\"offerType\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Type of win-back offer (discount, free_trial, upgrade, etc.)\"\n\t\t},\n\t\t\"offerValue\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Value or details of the offer\"\n\t\t},\n\t\t\"emailSubject\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email subject line\"\n\t\t},\n\t\t\"emailBody\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email body content in HTML format\"\n\t\t},\n\t\t\"reasoning\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Why this offer was chosen for this customer\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "80d1ad0f-71db-4751-a747-10f3400d00a2",
      "name": "MCP Client Tool",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        -192,
        592
      ],
      "parameters": {
        "options": {},
        "endpointUrl": "<__PLACEHOLDER_VALUE__MCP Server URL for customer data access__>"
      },
      "typeVersion": 1.2
    },
    {
      "id": "d47ae10c-ba93-4a4f-b9a6-1d3a9386ae07",
      "name": "Gmail Tool",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        976,
        448
      ],
      "parameters": {
        "sendTo": "={{ $fromAI('customerEmail') }}",
        "message": "={{ $fromAI('emailBody') }}",
        "options": {},
        "subject": "={{ $fromAI('emailSubject') }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0e8c50f9-aea9-4104-9530-2560f24687ef",
      "name": "Analyze Performance Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1728,
        464
      ],
      "parameters": {
        "jsCode": "// Analyze campaign performance metrics\nconst items = $input.all();\n\n// Initialize metrics\nlet totalCampaigns = items.length;\nlet conversions = 0;\nlet responses = 0;\nlet offerTypes = {};\nlet successfulPatterns = [];\n\n// Process each campaign result\nfor (const item of items) {\n  const data = item.json;\n  \n  // Track conversions and responses\n  if (data.converted) conversions++;\n  if (data.responded) responses++;\n  \n  // Track offer effectiveness by type\n  const offerType = data.offerType || 'unknown';\n  if (!offerTypes[offerType]) {\n    offerTypes[offerType] = { total: 0, conversions: 0, responses: 0 };\n  }\n  offerTypes[offerType].total++;\n  if (data.converted) offerTypes[offerType].conversions++;\n  if (data.responded) offerTypes[offerType].responses++;\n  \n  // Identify successful patterns\n  if (data.converted) {\n    successfulPatterns.push({\n      offerType: offerType,\n      churnRisk: data.churnRisk || 'unknown',\n      customerSegment: data.customerSegment || 'unknown',\n      daysSinceLastPurchase: data.daysSinceLastPurchase || 0,\n      messageType: data.messageType || 'unknown'\n    });\n  }\n}\n\n// Calculate rates\nconst conversionRate = totalCampaigns > 0 ? (conversions / totalCampaigns * 100).toFixed(2) : 0;\nconst responseRate = totalCampaigns > 0 ? (responses / totalCampaigns * 100).toFixed(2) : 0;\n\n// Calculate offer effectiveness\nconst offerEffectiveness = {};\nfor (const [type, stats] of Object.entries(offerTypes)) {\n  offerEffectiveness[type] = {\n    conversionRate: stats.total > 0 ? (stats.conversions / stats.total * 100).toFixed(2) : 0,\n    responseRate: stats.total > 0 ? (stats.responses / stats.total * 100).toFixed(2) : 0,\n    totalCampaigns: stats.total\n  };\n}\n\n// Identify patterns in successful campaigns\nconst patternAnalysis = {};\nfor (const pattern of successfulPatterns) {\n  const key = `${pattern.offerType}_${pattern.churnRisk}_${pattern.customerSegment}`;\n  if (!patternAnalysis[key]) {\n    patternAnalysis[key] = {\n      count: 0,\n      offerType: pattern.offerType,\n      churnRisk: pattern.churnRisk,\n      customerSegment: pattern.customerSegment,\n      avgDaysSinceLastPurchase: 0,\n      messageTypes: {}\n    };\n  }\n  patternAnalysis[key].count++;\n  patternAnalysis[key].avgDaysSinceLastPurchase += pattern.daysSinceLastPurchase;\n  \n  const msgType = pattern.messageType;\n  patternAnalysis[key].messageTypes[msgType] = (patternAnalysis[key].messageTypes[msgType] || 0) + 1;\n}\n\n// Calculate averages and sort patterns\nconst topPatterns = Object.values(patternAnalysis)\n  .map(p => ({\n    ...p,\n    avgDaysSinceLastPurchase: (p.avgDaysSinceLastPurchase / p.count).toFixed(0)\n  }))\n  .sort((a, b) => b.count - a.count)\n  .slice(0, 5);\n\n// Generate strategy recommendations\nconst recommendations = [];\n\n// Recommendation based on conversion rate\nif (parseFloat(conversionRate) < 5) {\n  recommendations.push({\n    type: 'conversion_improvement',\n    priority: 'high',\n    suggestion: 'Conversion rate is below 5%. Consider more aggressive offers or better targeting.'\n  });\n} else if (parseFloat(conversionRate) > 15) {\n  recommendations.push({\n    type: 'conversion_success',\n    priority: 'low',\n    suggestion: 'Excellent conversion rate. Maintain current strategy and scale successful patterns.'\n  });\n}\n\n// Recommendation based on offer effectiveness\nconst bestOffer = Object.entries(offerEffectiveness)\n  .sort((a, b) => parseFloat(b[1].conversionRate) - parseFloat(a[1].conversionRate))[0];\n\nif (bestOffer) {\n  recommendations.push({\n    type: 'offer_optimization',\n    priority: 'medium',\n    suggestion: `${bestOffer[0]} offers show highest conversion rate (${bestOffer[1].conversionRate}%). Increase allocation to this offer type.`\n  });\n}\n\n// Recommendation based on successful patterns\nif (topPatterns.length > 0) {\n  const topPattern = topPatterns[0];\n  recommendations.push({\n    type: 'pattern_replication',\n    priority: 'high',\n    suggestion: `Most successful pattern: ${topPattern.offerType} for ${topPattern.churnRisk} risk ${topPattern.customerSegment} customers. Replicate this approach.`\n  });\n}\n\n// Return comprehensive analysis\nreturn [{\n  json: {\n    summary: {\n      totalCampaigns,\n      conversions,\n      responses,\n      conversionRate: parseFloat(conversionRate),\n      responseRate: parseFloat(responseRate)\n    },\n    offerEffectiveness,\n    topSuccessfulPatterns: topPatterns,\n    recommendations,\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7de3e400-ac58-41c7-8c68-b87e44004844",
      "name": "Update Strategy Parameters",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1904,
        464
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.strategyApiUrl }}",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "optimalChurnThreshold",
              "value": "={{ $('Analyze Performance Data').first().json.optimalChurnThreshold }}"
            },
            {
              "name": "bestPerformingOfferTypes",
              "value": "={{ $('Analyze Performance Data').first().json.bestPerformingOfferTypes }}"
            },
            {
              "name": "timingRecommendations",
              "value": "={{ $('Analyze Performance Data').first().json.timingRecommendations }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "30cc6cd0-b248-46cf-bb5b-542e19a97279",
      "name": "Segment by Risk Level",
      "type": "n8n-nodes-base.switch",
      "position": [
        -544,
        704
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "High Risk",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "id-1",
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    },
                    "leftValue": "={{ $json.churn_risk_score }}",
                    "rightValue": "={{ $('Workflow Configuration').first().json.highRiskThreshold }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "id-2",
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    },
                    "leftValue": "={{ $json.churn_risk_score }}",
                    "rightValue": "={{ $('Workflow Configuration').first().json.mediumRiskThreshold }}"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "015e76e9-fdd5-4cce-99cc-cddffb4c2d60",
      "name": "Fetch Sentiment Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -992,
        544
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.sentimentApiUrl }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "customer_id",
              "value": "={{ $json.customer_id }}"
            },
            {
              "name": "include_social",
              "value": "true"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "b835c884-43ad-460f-913f-7ba869ffc039",
      "name": "Fetch Product Usage Analytics",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -992,
        832
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.usageAnalyticsApiUrl }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "customer_id",
              "value": "={{ $json.customer_id }}"
            },
            {
              "name": "period_days",
              "value": "90"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "f736c891-d9a3-4879-8135-352150fe76de",
      "name": "Merge Customer Intelligence",
      "type": "n8n-nodes-base.merge",
      "position": [
        -768,
        688
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "9a83dd9c-a915-4fd4-a23b-ac08eefe200a",
      "name": "High Risk Strategy Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -264,
        368
      ],
      "parameters": {
        "text": "=Customer Intelligence: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a HIGH RISK customer retention specialist focused on preventing imminent churn.\n\nYour task is to:\n1. Analyze the comprehensive customer intelligence including churn signals, sentiment data, and usage analytics\n2. Use the Sentiment Analysis Agent Tool to deeply understand customer frustrations and pain points\n3. Use the MCP Client Tool to access detailed customer history and preferences\n4. Create an AGGRESSIVE win-back strategy with premium offers (30-50% discounts, extended trials, VIP support)\n5. Craft urgent, empathetic messaging that acknowledges their concerns and demonstrates value\n6. Use the Gmail Tool to send the personalized high-priority win-back email\n7. Return structured offer details\n\nFor HIGH RISK customers:\n- Offer maximum value and incentives\n- Address specific pain points from sentiment analysis\n- Include personal touch (account manager contact, priority support)\n- Create urgency with time-limited offers\n- Show understanding of their situation"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "678277a3-7516-4d95-9f95-4966c0913436",
      "name": "Low Risk Strategy Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -264,
        1024
      ],
      "parameters": {
        "text": "=Customer Intelligence: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a LOW RISK customer retention specialist focused on proactive engagement.\n\nYour task is to:\n1. Analyze customer intelligence to identify early warning signs\n2. Use the Pricing API Tool to check current pricing and available promotions\n3. Use the MCP Client Tool for customer preferences\n4. Create a GENTLE win-back strategy with modest offers (5-15% discounts, bonus features)\n5. Focus on relationship building and value reminders\n6. Use the Gmail Tool to send the personalized check-in email\n7. Return structured offer details\n\nFor LOW RISK customers:\n- Maintain relationship with friendly check-ins\n- Highlight underutilized features that could help them\n- Offer small incentives as goodwill gestures\n- Request feedback to show you care\n- Keep tone light and helpful, not desperate"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "dea8084c-1b70-4f98-aaf4-dfc401510761",
      "name": "OpenAI Chat Model 3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -320,
        1248
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "3184c63f-9f24-4656-b3fc-a6abb9261454",
      "name": "Structured Output Parser 3",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        16,
        1248
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"customerEmail\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Customer email address\"\n\t\t},\n\t\t\"offerType\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Type of win-back offer (discount, free_trial, upgrade, etc.)\"\n\t\t},\n\t\t\"offerValue\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Value or details of the offer\"\n\t\t},\n\t\t\"emailSubject\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email subject line\"\n\t\t},\n\t\t\"emailBody\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email body content in HTML format\"\n\t\t},\n\t\t\"reasoning\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Why this offer was chosen for this customer\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "3cc74547-a0dc-4d32-b8a4-a8c8c3ebb0a3",
      "name": "Pricing API Tool",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        -144,
        1248
      ],
      "parameters": {
        "url": "<__PLACEHOLDER_VALUE__Pricing API endpoint__>",
        "options": {},
        "toolDescription": "Fetches current pricing, available promotions, and discount eligibility for customers"
      },
      "typeVersion": 4.3
    },
    {
      "id": "8509b544-d3b3-41d5-b0fa-469dacd2bbf2",
      "name": "Aggregate Campaign Results",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1344,
        464
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "offerType"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cf6bb4f9-08cb-4191-950f-3a8afeceaf36",
      "name": "Wait for Email Response",
      "type": "n8n-nodes-base.wait",
      "position": [
        256,
        512
      ],
      "parameters": {
        "resume": "webhook",
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "1ecdde72-ba11-458f-9885-8e2e5e92c7e7",
      "name": "Check Email Engagement",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        320
      ],
      "parameters": {
        "url": "={{ $('Workflow Configuration').first().json.emailEngagementApiUrl }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.customerEmail }}"
            },
            {
              "name": "campaign_id",
              "value": "={{ $json.campaign_id }}"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "57e2da33-2b88-49b2-b449-7ea7053abd8a",
      "name": "Check Response Status",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "id-1",
              "operator": {
                "type": "boolean",
                "operation": "false"
              },
              "leftValue": "={{ $('Check Email Engagement').item.json.email_opened }}"
            },
            {
              "id": "id-2",
              "operator": {
                "type": "boolean",
                "operation": "false"
              },
              "leftValue": "={{ $('Check Email Engagement').item.json.email_clicked }}"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "def685b1-763f-4bbb-a545-45d6b277504a",
      "name": "Follow-up Strategy Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        872,
        176
      ],
      "parameters": {
        "text": "=Follow-up needed for: {{ JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are a follow-up retention specialist handling customers who did not engage with the initial email.\n\nYour task is to:\n1. Analyze why the initial email may not have resonated\n2. Create a DIFFERENT approach with alternative messaging and offers\n3. Try a different value proposition or angle\n4. Use the Gmail Tool to send a follow-up email with fresh perspective\n5. Return structured offer details\n\nFor follow-ups:\n- Change the subject line approach completely\n- Try different pain points or benefits\n- Offer alternative incentives\n- Use different tone (more casual or more formal)\n- Keep it shorter and more direct"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "18aa1121-4c6d-4397-a400-b94a9cf07206",
      "name": "Calculate CLV Impact",
      "type": "n8n-nodes-base.code",
      "position": [
        1536,
        464
      ],
      "parameters": {
        "jsCode": "// Calculate Customer Lifetime Value (CLV) Impact of Retention Campaigns\nconst items = $input.all();\n\n// Initialize metrics\nlet totalCustomers = items.length;\nlet retainedCustomers = 0;\nlet totalSavedRevenue = 0;\nlet totalCampaignCost = 0;\nlet customerMetrics = [];\n\n// Average CLV assumptions (can be customized based on business)\nconst avgMonthlyRevenue = 100; // Average monthly revenue per customer\nconst avgCustomerLifetimeMonths = 24; // Average customer lifetime in months\nconst baselineCLV = avgMonthlyRevenue * avgCustomerLifetimeMonths;\n\n// Process each customer campaign result\nfor (const item of items) {\n  const data = item.json;\n  \n  // Determine if customer was retained\n  const wasRetained = data.converted || data.responded || false;\n  if (wasRetained) retainedCustomers++;\n  \n  // Calculate saved revenue for this customer\n  const customerCLV = data.historicalCLV || baselineCLV;\n  const churnRisk = data.churnRiskScore || 50;\n  const churnProbability = churnRisk / 100;\n  \n  // Saved revenue = CLV * probability of churn * retention success\n  const savedRevenue = wasRetained ? customerCLV * churnProbability : 0;\n  totalSavedRevenue += savedRevenue;\n  \n  // Estimate campaign cost per customer\n  const campaignCost = data.campaignCost || 10; // Default $10 per campaign\n  totalCampaignCost += campaignCost;\n  \n  // Store individual customer metrics\n  customerMetrics.push({\n    customerId: data.customerId || data.customerEmail,\n    wasRetained,\n    churnRisk,\n    savedRevenue: savedRevenue.toFixed(2),\n    campaignCost: campaignCost.toFixed(2),\n    roi: campaignCost > 0 ? ((savedRevenue - campaignCost) / campaignCost * 100).toFixed(2) : 0,\n    projectedCLV: wasRetained ? customerCLV : 0\n  });\n}\n\n// Calculate retention rate improvement\nconst retentionRate = totalCustomers > 0 ? (retainedCustomers / totalCustomers * 100).toFixed(2) : 0;\n\n// Baseline retention rate (without campaign) - assume 20% would have stayed anyway\nconst baselineRetentionRate = 20;\nconst retentionRateImprovement = (parseFloat(retentionRate) - baselineRetentionRate).toFixed(2);\n\n// Calculate campaign ROI\nconst campaignROI = totalCampaignCost > 0 ? \n  ((totalSavedRevenue - totalCampaignCost) / totalCampaignCost * 100).toFixed(2) : 0;\n\n// Calculate projected long-term value\nconst projectedLongTermValue = retainedCustomers * baselineCLV;\n\n// Calculate net revenue impact\nconst netRevenueImpact = totalSavedRevenue - totalCampaignCost;\n\n// Calculate average metrics\nconst avgSavedRevenuePerCustomer = totalCustomers > 0 ? \n  (totalSavedRevenue / totalCustomers).toFixed(2) : 0;\nconst avgCampaignCostPerCustomer = totalCustomers > 0 ? \n  (totalCampaignCost / totalCustomers).toFixed(2) : 0;\n\n// Segment analysis by risk level\nconst highRiskCustomers = customerMetrics.filter(c => c.churnRisk >= 70);\nconst mediumRiskCustomers = customerMetrics.filter(c => c.churnRisk >= 40 && c.churnRisk < 70);\nconst lowRiskCustomers = customerMetrics.filter(c => c.churnRisk < 40);\n\nconst segmentAnalysis = {\n  highRisk: {\n    total: highRiskCustomers.length,\n    retained: highRiskCustomers.filter(c => c.wasRetained).length,\n    retentionRate: highRiskCustomers.length > 0 ? \n      (highRiskCustomers.filter(c => c.wasRetained).length / highRiskCustomers.length * 100).toFixed(2) : 0,\n    totalSavedRevenue: highRiskCustomers.reduce((sum, c) => sum + parseFloat(c.savedRevenue), 0).toFixed(2)\n  },\n  mediumRisk: {\n    total: mediumRiskCustomers.length,\n    retained: mediumRiskCustomers.filter(c => c.wasRetained).length,\n    retentionRate: mediumRiskCustomers.length > 0 ? \n      (mediumRiskCustomers.filter(c => c.wasRetained).length / mediumRiskCustomers.length * 100).toFixed(2) : 0,\n    totalSavedRevenue: mediumRiskCustomers.reduce((sum, c) => sum + parseFloat(c.savedRevenue), 0).toFixed(2)\n  },\n  lowRisk: {\n    total: lowRiskCustomers.length,\n    retained: lowRiskCustomers.filter(c => c.wasRetained).length,\n    retentionRate: lowRiskCustomers.length > 0 ? \n      (lowRiskCustomers.filter(c => c.wasRetained).length / lowRiskCustomers.length * 100).toFixed(2) : 0,\n    totalSavedRevenue: lowRiskCustomers.reduce((sum, c) => sum + parseFloat(c.savedRevenue), 0).toFixed(2)\n  }\n};\n\n// Generate insights and recommendations\nconst insights = [];\n\nif (parseFloat(campaignROI) > 200) {\n  insights.push({\n    type: 'success',\n    message: `Excellent ROI of ${campaignROI}%. Campaign is highly profitable and should be scaled.`\n  });\n} else if (parseFloat(campaignROI) > 100) {\n  insights.push({\n    type: 'success',\n    message: `Good ROI of ${campaignROI}%. Campaign is profitable and performing well.`\n  });\n} else if (parseFloat(campaignROI) > 0) {\n  insights.push({\n    type: 'warning',\n    message: `Moderate ROI of ${campaignROI}%. Consider optimizing campaign costs or targeting.`\n  });\n} else {\n  insights.push({\n    type: 'alert',\n    message: `Negative ROI of ${campaignROI}%. Campaign needs significant optimization or restructuring.`\n  });\n}\n\nif (parseFloat(retentionRateImprovement) > 15) {\n  insights.push({\n    type: 'success',\n    message: `Strong retention improvement of ${retentionRateImprovement}% above baseline.`\n  });\n}\n\nif (parseFloat(segmentAnalysis.highRisk.retentionRate) < 30) {\n  insights.push({\n    type: 'warning',\n    message: `High-risk customer retention is low at ${segmentAnalysis.highRisk.retentionRate}%. Consider more aggressive offers for this segment.`\n  });\n}\n\n// Return comprehensive CLV impact analysis\nreturn [{\n  json: {\n    summary: {\n      totalCustomers,\n      retainedCustomers,\n      retentionRate: parseFloat(retentionRate),\n      retentionRateImprovement: parseFloat(retentionRateImprovement)\n    },\n    financial: {\n      totalSavedRevenue: totalSavedRevenue.toFixed(2),\n      totalCampaignCost: totalCampaignCost.toFixed(2),\n      netRevenueImpact: netRevenueImpact.toFixed(2),\n      campaignROI: parseFloat(campaignROI),\n      avgSavedRevenuePerCustomer: parseFloat(avgSavedRevenuePerCustomer),\n      avgCampaignCostPerCustomer: parseFloat(avgCampaignCostPerCustomer)\n    },\n    longTerm: {\n      projectedLongTermValue: projectedLongTermValue.toFixed(2),\n      retainedCustomerCount: retainedCustomers,\n      avgCLVPerRetainedCustomer: baselineCLV.toFixed(2)\n    },\n    segmentAnalysis,\n    insights,\n    timestamp: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "1753df60-d143-43de-9db9-5d179abe5683",
      "name": "Merge All Campaign Paths",
      "type": "n8n-nodes-base.merge",
      "position": [
        936,
        600
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "7533ca0c-0516-4dcb-80fb-30b3015ba632",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -320,
        592
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "gpt-4o"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ca17de37-e757-48d8-bf0a-51988d4f7286",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -64,
        592
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"customerEmail\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Customer email address\"\n\t\t},\n\t\t\"offerType\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Type of win-back offer (discount, free_trial, upgrade, etc.)\"\n\t\t},\n\t\t\"offerValue\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Value or details of the offer\"\n\t\t},\n\t\t\"emailSubject\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email subject line\"\n\t\t},\n\t\t\"emailBody\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Personalized email body content in HTML format\"\n\t\t},\n\t\t\"reasoning\": {\n\t\t\t\"type\": \"string\",\n\t\t\t\"description\": \"Why this offer was chosen for this customer\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "789166dd-9b09-4eaf-b9dc-040e20fdc5ac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        -144
      ],
      "parameters": {
        "color": 4,
        "width": 688,
        "height": 192,
        "content": "##  PREREQUISITES\nOpenAI API key, Google Sheets access, Slack workspace, Gmail account, basic n8n familiarity.  \n\n## USE CASES\nMarket research automation, competitive intelligence monitoring, customer feedback analysis at scale "
      },
      "typeVersion": 1
    },
    {
      "id": "e4450751-fc28-4696-a0c5-bf7293508bd0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -144
      ],
      "parameters": {
        "color": 6,
        "width": 646,
        "height": 224,
        "content": "## CUSTOMIZATION\nSwap AI models (Claude, Gemini, Llama), add/remove analysis branches, modify output destinations \n\n##  BENEFITS\nEliminates manual data processing (80% time savings), enables simultaneous multi-perspective analysis "
      },
      "typeVersion": 1
    },
    {
      "id": "22ce6df8-c0b2-4413-acfd-fb6fff053b8c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        -144
      ],
      "parameters": {
        "color": 3,
        "width": 496,
        "height": 208,
        "content": "## SETUP STEPS\n1. Configure OpenAI API key in credentials\n2. Set up Google Sheets connection with service account\n3. Add Slack webhook for notifications\n4. Connect Gmail for automated report distribution\n5. Configure NVIDIA API (if using specialized models)\n6. Map input data source "
      },
      "typeVersion": 1
    },
    {
      "id": "45370f56-e4d0-4d31-9a88-fbba690df126",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2096,
        -144
      ],
      "parameters": {
        "width": 704,
        "height": 240,
        "content": "##  HOW IT WORKS\nThis workflow automates end-to-end data intelligence processing by ingesting structured data (CSV, JSON), enriching it through multiple AI analysis pathways, and generating actionable insights. Designed for business analysts, data scientists, and operations teams, it solves the problem of manual data enrichment and fragmented analysis by consolidating diverse AI models (GPT-4, LLM analysis, sentiment detection) into a unified pipeline. Data flows from source ingestion \u2192 enrichment/validation \u2192 branching into three specialized analysis paths (Competitive Intelligence, Sentiment Analysis, Market Insights) \u2192 aggregation \u2192 result storage (Google Sheets) and notifications (Slack, Gmail). Each path applies distinct AI models for comprehensive intelligence gathering."
      },
      "typeVersion": 1
    },
    {
      "id": "69479ab9-7b82-4be8-8836-1d4504c531a5",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2144,
        496
      ],
      "parameters": {
        "color": 7,
        "width": 1744,
        "height": 848,
        "content": "## Data Ingestion & Validation\nSources structured data and validates format integrity\n\n### Why:\n Ensures clean, consistent input for downstream processing\n"
      },
      "typeVersion": 1
    },
    {
      "id": "94158760-2cd6-4ebe-bd8f-3d864209e500",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 1264,
        "content": "## AI-Powered Enrichment\nApplies GPT-4 and Claude APIs for contextual enhancement\n\n### Why: \nAdds business intelligence and semantic meaning to raw data"
      },
      "typeVersion": 1
    },
    {
      "id": "5fcb749c-e040-4009-9479-d4e0ab6e212a",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 1056,
        "height": 1296,
        "content": "## Competitive Intelligence Path\nAnalyzes market positioning and evaluates emotional tone and emerging patterns\n\n### Why:\n Identifies strategic opportunities and threats"
      },
      "typeVersion": 1
    },
    {
      "id": "3a365443-93ed-41bc-b7af-34ab3fabcd69",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 1312,
        "content": "## Results Aggregation, Export & Notification \nConsolidates outputs to Google Sheets with formatting\n\n### Why:\n Centralizes findings for stakeholder review and archiving\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9fee850c-77ea-4ca0-8878-beac75566bf9",
  "connections": {
    "Gmail Tool": {
      "ai_tool": [
        [
          {
            "node": "Follow-up Strategy Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "MCP Client Tool": {
      "ai_tool": [
        [
          {
            "node": "High Risk Strategy Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Check Churn Risk": {
      "main": [
        [
          {
            "node": "Fetch Sentiment Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Product Usage Analytics",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Customer Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pricing API Tool": {
      "ai_tool": [
        [
          {
            "node": "Low Risk Strategy Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Daily Churn Check": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Follow-up Strategy Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "High Risk Strategy Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Customer Data": {
      "main": [
        [
          {
            "node": "Calculate Churn Signals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model 3": {
      "ai_languageModel": [
        [
          {
            "node": "Low Risk Strategy Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Calculate CLV Impact": {
      "main": [
        [
          {
            "node": "Analyze Performance Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Sentiment Data": {
      "main": [
        [
          {
            "node": "Merge Customer Intelligence",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check Response Status": {
      "main": [
        [
          {
            "node": "Merge All Campaign Paths",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Follow-up Strategy Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Segment by Risk Level": {
      "main": [
        [
          {
            "node": "High Risk Strategy Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Email Response",
            "type": "main",
            "index": 0
          },
          {
            "node": "Low Risk Strategy Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Email Engagement": {
      "main": [
        [
          {
            "node": "Check Response Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Fetch Customer Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Churn Signals": {
      "main": [
        [
          {
            "node": "Check Churn Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Low Risk Strategy Agent": {
      "main": [
        [
          {
            "node": "Wait for Email Response",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge All Campaign Paths",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Wait for Email Response": {
      "main": [
        [
          {
            "node": "Check Email Engagement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Performance Data": {
      "main": [
        [
          {
            "node": "Update Strategy Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Follow-up Strategy Agent": {
      "main": [
        [
          {
            "node": "Aggregate Campaign Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "High Risk Strategy Agent": {
      "main": [
        [
          {
            "node": "Wait for Email Response",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge All Campaign Paths",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge All Campaign Paths": {
      "main": [
        [
          {
            "node": "Aggregate Campaign Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Follow-up Strategy Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "High Risk Strategy Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Campaign Results": {
      "main": [
        [
          {
            "node": "Calculate CLV Impact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser 3": {
      "ai_outputParser": [
        [
          {
            "node": "Low Risk Strategy Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Merge Customer Intelligence": {
      "main": [
        [
          {
            "node": "Segment by Risk Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Product Usage Analytics": {
      "main": [
        [
          {
            "node": "Merge Customer Intelligence",
            "type": "main",
            "index": 2
          }
        ]
      ]
    }
  }
}

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 automates end-to-end data intelligence processing by ingesting structured data (CSV, JSON), enriching it through multiple AI analysis pathways, and generating actionable insights. Designed for business analysts, data scientists, and operations teams, it solves the…

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

Schedules automated vendor pricing analysis across multiple sources. Fetches delivery reliability and contract data, analyzes vendor performance using Claude AI, then distributes consolidated reports

HTTP Request, Airtable, OpenAI Chat +9
AI & RAG

This n8n workflow revolutionizes Instagram content creation by automating everything from idea input to publishing high-quality, AI-generated posts with realistic images or infographics. Whether you'r

OpenAI Chat, Facebook Graph Api, Agent +5
AI & RAG

This workflow automates end-to-end ESG (Environmental, Social, and Governance) sustainability reporting for enterprise sustainability teams, compliance officers, and green governance leads. It solves

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

This n8n template transforms your daily meeting preparation by automatically researching attendees and generating comprehensive briefing documents. Every weekday morning, it analyzes your calendar eve

Google Calendar, Slack, Agent +7
AI & RAG

This workflow automates end-to-end financial transaction processing for finance teams managing high-volume bank data. It eliminates manual reconciliation by intelligently classifying transactions, det

HTTP Request, Agent, OpenAI Chat +4