{
  "name": "Predict customer churn with AI analysis of HubSpot and Google Sheets data",
  "nodes": [
    {
      "id": "c00e5d2a-415e-40c1-9e9b-60f34aa3d5b4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        0
      ],
      "parameters": {
        "width": 992,
        "height": 368,
        "content": "# Customer Health Scoring & Churn Alert\nThis workflow automatically calculates a customer health score by analyzing data from HubSpot and Google Sheets. If it detects a potential churn risk based on f"
      }
    },
    {
      "id": "9e0e813a-b908-4025-b57d-a724289673ae",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        1232
      ],
      "parameters": {
        "width": 432,
        "height": 176,
        "content": "## Contact me\n- If you need any modification to this workflow\n- if you need some help with this workflow\n- Or if you need any workflow in n8n, Make, or Langchain / Langgraph\n\nWrite to me: [thomas@poll"
      }
    },
    {
      "id": "50f33598-bcb5-4afd-8792-9368cfd0ce70",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        1200
      ],
      "parameters": {
        "width": null,
        "height": 272,
        "content": "This tool calls this workflow's own Webhook trigger. It sends all tickets at once to be processed and returns a single sentiment score."
      }
    },
    {
      "id": "fec2e35b-2cb4-43ae-82c8-af9f6ffec53b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        816
      ],
      "parameters": {
        "width": 352,
        "height": 272,
        "content": "This AI prompt checks for three churn signals:\n- Deal age > 1 year\n- A negative sentiment score\n- Declining feature usage over time"
      }
    },
    {
      "id": "34112bf3-f326-454d-a34f-cc59583e4ded",
      "name": "Manual Trigger: Run Churn Analysis",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -192,
        960
      ]
    },
    {
      "id": "124ca622-1418-4c72-abdf-1026dd1fdb53",
      "name": "HubSpot: Get All Deals",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        32,
        960
      ]
    },
    {
      "id": "10109472-0242-4d47-bb89-b39683107f91",
      "name": "Start Loop: For Each Deal",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        320,
        960
      ]
    },
    {
      "id": "b76656fb-f5e9-4aff-bb49-39ed6b6edc1f",
      "name": "Set: Isolate Current Deal ID  Export to Sheets",
      "type": "n8n-nodes-base.set",
      "position": [
        608,
        960
      ]
    },
    {
      "id": "2a4d7904-4375-47a8-9797-1715b3596484",
      "name": "Trigger: Receive Tickets for Scoring",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -192,
        608
      ]
    },
    {
      "id": "e9507eaa-294f-4ba8-a1d9-759f6ae58a5d",
      "name": "Code: Format Tickets for Analysis",
      "type": "n8n-nodes-base.code",
      "position": [
        32,
        608
      ]
    },
    {
      "id": "c34f65fd-2c46-47c0-9b06-87b090feca10",
      "name": "Loop: For Each Ticket",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        256,
        608
      ]
    },
    {
      "id": "173c07bc-884e-48d3-b927-31cdc800c5b2",
      "name": "AI: Analyze Ticket Sentiment",
      "type": "@n8n/n8n-nodes-langchain.sentimentAnalysis",
      "position": [
        480,
        480
      ]
    },
    {
      "id": "db3e0604-ba4f-4f09-b281-42848441a5c6",
      "name": "Merge: Consolidate Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        832,
        592
      ]
    },
    {
      "id": "2be479b2-d019-43d9-a06a-052991743f4d",
      "name": "Code: Convert Sentiment to Score",
      "type": "n8n-nodes-base.code",
      "position": [
        1248,
        608
      ]
    },
    {
      "id": "a52e3b3c-a73d-459e-9d68-9dc201383860",
      "name": "Code: Sum All Ticket Scores",
      "type": "n8n-nodes-base.code",
      "position": [
        1648,
        608
      ]
    },
    {
      "id": "87806b1f-1246-4c82-9fec-71bd668368e9",
      "name": "Respond: Return Total Score  Export to Sheets",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1952,
        608
      ]
    },
    {
      "id": "5099176a-7e74-4cfe-9e2e-82e7144db3b1",
      "name": "AI Agent: Gather Customer Data",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        960,
        960
      ]
    },
    {
      "id": "37a5efac-6dbf-4af0-830e-466e31561113",
      "name": "Config: Set LLM for Agent & Chains",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        544,
        736
      ]
    },
    {
      "id": "536718ef-3912-49fd-95c2-d172902e1b3a",
      "name": "Tool: Get HubSpot Data",
      "type": "@n8n/n8n-nodes-langchain.mcpClientTool",
      "position": [
        944,
        1312
      ]
    },
    {
      "id": "6c13beac-207b-48fd-8514-242c2ed30c87",
      "name": "Tool: Calculate Sentiment Score",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        784,
        1312
      ]
    },
    {
      "id": "4584effb-8688-4f06-a495-e2b4b7ebfd2e",
      "name": "Tool: Get Feature Usage from Sheets",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1104,
        1312
      ]
    },
    {
      "id": "7f03cc9a-09a2-4d19-b386-09302bcbd699",
      "name": "AI: Structure Agent's Findings  Export to Sheets",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1264,
        1312
      ]
    },
    {
      "id": "1147efd1-d880-4c75-a2da-7f6b74df3c43",
      "name": "Code: Group Feature Data by Name",
      "type": "n8n-nodes-base.code",
      "position": [
        1424,
        960
      ]
    },
    {
      "id": "e1f8b15e-3be2-4727-aaba-040d18016057",
      "name": "AI Chain: Analyze for Churn Risk",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1648,
        960
      ]
    },
    {
      "id": "c20a8716-68ce-4d76-911e-576a86ce5f7f",
      "name": "AI: Structure Alert Email",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1792,
        1168
      ]
    },
    {
      "id": "78bb2588-c4e0-4737-b21d-36889df26a28",
      "name": "Format: Convert Alert to HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        2016,
        960
      ]
    },
    {
      "id": "62eb0b37-a18b-4d49-b321-948ae60b8e79",
      "name": "Email: Send Churn Alert  Export to Sheets",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2224,
        960
      ]
    }
  ],
  "connections": {
    "Loop: For Each Ticket": {
      "main": [
        [
          {
            "node": "AI: Analyze Ticket Sentiment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot: Get All Deals": {
      "main": [
        [
          {
            "node": "Start Loop: For Each Deal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tool: Get HubSpot Data": {
      "ai_tool": [
        [
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI: Structure Alert Email": {
      "ai_outputParser": [
        [
          {
            "node": "AI Chain: Analyze for Churn Risk",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Start Loop: For Each Deal": {
      "main": [
        [],
        [
          {
            "node": "Set: Isolate Current Deal ID  Export to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge: Consolidate Results": {
      "main": [
        [
          {
            "node": "Code: Convert Sentiment to Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Sum All Ticket Scores": {
      "main": [
        [
          {
            "node": "Respond: Return Total Score  Export to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Analyze Ticket Sentiment": {
      "main": [
        [
          {
            "node": "Merge: Consolidate Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge: Consolidate Results",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Merge: Consolidate Results",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Format: Convert Alert to HTML": {
      "main": [
        [
          {
            "node": "Email: Send Churn Alert  Export to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent: Gather Customer Data": {
      "main": [
        [
          {
            "node": "Code: Group Feature Data by Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tool: Calculate Sentiment Score": {
      "ai_tool": [
        [
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "AI Chain: Analyze for Churn Risk": {
      "main": [
        [
          {
            "node": "Format: Convert Alert to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Convert Sentiment to Score": {
      "main": [
        [
          {
            "node": "Code: Sum All Ticket Scores",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Group Feature Data by Name": {
      "main": [
        [
          {
            "node": "AI Chain: Analyze for Churn Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code: Format Tickets for Analysis": {
      "main": [
        [
          {
            "node": "Loop: For Each Ticket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Config: Set LLM for Agent & Chains": {
      "ai_languageModel": [
        [
          {
            "node": "AI: Analyze Ticket Sentiment",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "AI Chain: Analyze for Churn Risk",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger: Run Churn Analysis": {
      "main": [
        [
          {
            "node": "HubSpot: Get All Deals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tool: Get Feature Usage from Sheets": {
      "ai_tool": [
        [
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Receive Tickets for Scoring": {
      "main": [
        [
          {
            "node": "Code: Format Tickets for Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email: Send Churn Alert  Export to Sheets": {
      "main": [
        [
          {
            "node": "Start Loop: For Each Deal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set: Isolate Current Deal ID  Export to Sheets": {
      "main": [
        [
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI: Structure Agent's Findings  Export to Sheets": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent: Gather Customer Data",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}