{
  "name": "Automated daily customer win-back campaign with AI offers",
  "nodes": [
    {
      "id": "13f8de57-7247-4be1-8fc4-dddc1a7d677e",
      "name": "Scheduled Start: Daily Churn Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        160,
        0
      ]
    },
    {
      "id": "8f52666a-7247-4058-a775-2be80e3b4c0e",
      "name": "Fetch Customer Data from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        440,
        0
      ]
    },
    {
      "id": "37951981-3c3d-4434-8782-51e9129f0bbc",
      "name": "Filter High Churn Risk & No Campaign Customers",
      "type": "n8n-nodes-base.filter",
      "position": [
        760,
        0
      ]
    },
    {
      "id": "4152752b-3ba3-4af0-aec8-aba9fc0424d9",
      "name": "Check if Eligible Customers Found",
      "type": "n8n-nodes-base.if",
      "position": [
        1140,
        0
      ]
    },
    {
      "id": "c1164b8f-4497-4763-bb42-7187e9f2f4d2",
      "name": "Process Each Eligible Customer",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1640,
        -320
      ]
    },
    {
      "id": "8896a776-ed5b-431a-908b-663fa8475c77",
      "name": "Generate Win-Back Offer",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2100,
        -300
      ]
    },
    {
      "id": "b89954e9-7689-47e6-bf15-3089f3863ca9",
      "name": "(LLM Model for Offer Generation)",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2060,
        -120
      ]
    },
    {
      "id": "ee485123-32be-447b-80f3-303e3a046207",
      "name": "(Parse Offer JSON)",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2260,
        -100
      ]
    },
    {
      "id": "005890c2-f77d-4d0d-add2-496642464a9f",
      "name": "Log Sent Offer in System Log",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2640,
        -220
      ]
    },
    {
      "id": "98295978-21f1-420f-8e9c-4014d53ffb16",
      "name": "Send Win-Back Offer via Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2880,
        -120
      ]
    },
    {
      "id": "13095156-a54f-432f-8d10-209ddc30680a",
      "name": "Set 'Not Found' Status",
      "type": "n8n-nodes-base.set",
      "position": [
        1620,
        300
      ]
    },
    {
      "id": "1f823726-6483-40c1-b184-eac87886ded5",
      "name": "Log 'Not Found' in System Log",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1940,
        300
      ]
    },
    {
      "id": "c6828c9c-c39f-40b5-9197-1435915d3682",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -340
      ],
      "parameters": {
        "width": 380,
        "height": 300,
        "content": "# 00. Daily Start & Fetch Customer Data\n\n**Purpose:** Automatically triggers the workflow **once daily** based on the schedule set in the first node. It then fetches all customer data from the specifi"
      }
    },
    {
      "id": "71d3f596-1413-4e97-81eb-ec701f15938d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1560,
        540
      ],
      "parameters": {
        "width": 540,
        "height": 300,
        "content": "# 03. Handle No Eligible Customers\n\n**Purpose:** This path executes if the initial filter finds *no* customers meeting the win-back criteria during the daily check.\n1.  **Set Status:** Sets a variable"
      }
    },
    {
      "id": "0f076e97-7cf0-48b6-8808-db0f1863409e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        760,
        -360
      ],
      "parameters": {
        "width": 460,
        "height": 280,
        "content": "# 01. Filter & Branch\n\n**Purpose:** Filters the fetched customer data to identify those meeting specific win-back criteria:\n1.  `predicted_churn_score` is greater than 0.7.\n2.  No previous campaign da"
      }
    },
    {
      "id": "d3493f09-7eba-4625-98db-83cf649dbbcf",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1700,
        -760
      ],
      "parameters": {
        "width": 600,
        "height": 360,
        "content": "# 02. Generate & Send Win-Back Offer (Loop)\n\n**Purpose:** Processes each eligible customer found in the previous step individually within a loop.\n1.  **Generate Offer (Gemini):** Uses Google Gemini to"
      }
    },
    {
      "id": "2fc53a15-2bdd-48f5-9a74-44a2e028e7e0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -120
      ],
      "parameters": {
        "width": 400,
        "height": 380,
        "content": "# Example Customer Data\n\n\n{\n    \"customer_id\": \"CUST_001\",\n    \"last_purchase_date\": \"2024-01-10T10:00:00Z\",\n    \"purchase_frequency_days\": 90,\n    \"user_mail\":\"example@mail.com\",\n    \"days_since_last"
      }
    }
  ],
  "connections": {
    "(Parse Offer JSON)": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Win-Back Offer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Set 'Not Found' Status": {
      "main": [
        [
          {
            "node": "Log 'Not Found' in System Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Win-Back Offer": {
      "main": [
        [
          {
            "node": "Log Sent Offer in System Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Sent Offer in System Log": {
      "main": [
        [
          {
            "node": "Send Win-Back Offer via Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Win-Back Offer via Email": {
      "main": [
        [
          {
            "node": "Process Each Eligible Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Customer Data from Sheet": {
      "main": [
        [
          {
            "node": "Filter High Churn Risk & No Campaign Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Each Eligible Customer": {
      "main": [
        [],
        [
          {
            "node": "Generate Win-Back Offer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "(LLM Model for Offer Generation)": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Win-Back Offer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check if Eligible Customers Found": {
      "main": [
        [
          {
            "node": "Process Each Eligible Customer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set 'Not Found' Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scheduled Start: Daily Churn Check": {
      "main": [
        [
          {
            "node": "Fetch Customer Data from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter High Churn Risk & No Campaign Customers": {
      "main": [
        [
          {
            "node": "Check if Eligible Customers Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}