{
  "nodes": [
    {
      "id": "12cc91e8-fd72-41ff-b6f6-843b39b202d2",
      "name": "Overview & Purpose",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        96
      ],
      "parameters": {
        "width": 320,
        "height": 200,
        "content": "## \ud83d\udd2e AI Customer Success Risk Prediction Workflow\n\n**Purpose:** Predict customer churn risk 30-90 days early using AI analysis of multiple data signals, then automatically create personalized interventions\n\n**Why This is Revolutionary:**\n- Most CS teams are reactive - this is predictive\n- Combines product usage + support sentiment + billing patterns\n- AI generates personalized interventions based on specific risk factors\n- Reduces churn by 15-30% through early intervention\n\n**\ud83d\udd10 Security:** All API keys stored in environment variables and credentials"
      },
      "typeVersion": 1
    },
    {
      "id": "365de93c-898a-476e-a3ee-d80875707f01",
      "name": "Setup Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        368
      ],
      "parameters": {
        "width": 320,
        "height": 220,
        "content": "## \ud83c\udfaf Setup & Configuration\n\n**Required Environment Variables:**\n- `MIXPANEL_PROJECT_ID` (or analytics tool)\n- `HIGH_RISK_SLACK_CHANNEL`\n- `CS_TEAM_EMAIL`\n- `OPENAI_MODEL_VERSION`\n\n**Credentials Needed:**\n- OpenAI/Anthropic API (AI analysis)\n- Analytics Platform (Mixpanel/Amplitude)\n- Support System (Zendesk/Intercom)\n- Stripe/Billing System\n- HubSpot CRM\n- Slack API\n- SendGrid/Email Platform\n\n**Setup Time:** ~45 minutes"
      },
      "typeVersion": 1
    },
    {
      "id": "fd8d7b52-6862-410f-bb02-f1bd234060ce",
      "name": "AI Analysis Logic",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        96
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "## \ud83e\udde0 AI Risk Analysis Logic\n\n**Data Sources Combined:**\n- Product usage trends (logins, feature usage, session duration)\n- Support ticket sentiment & frequency\n- Payment patterns & billing issues\n- Email engagement rates\n- Contract renewal dates\n\n**AI Scoring Factors:**\n- Usage decline >30% = High risk\n- Negative support sentiment = Medium risk\n- Payment delays = High risk\n- Low email engagement = Low risk modifier\n- Multiple signals = Exponential risk increase\n\n**Risk Levels:** Critical (90+), High (70-89), Medium (40-69), Low (<40)"
      },
      "typeVersion": 1
    },
    {
      "id": "b3b1cfa4-cb6f-423c-9cee-a8d2b860c8bb",
      "name": "Daily Risk Analysis",
      "type": "n8n-nodes-base.cron",
      "position": [
        736,
        560
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ba458527-4372-4674-a99a-f792fd52e343",
      "name": "Fetch Product Usage Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        368
      ],
      "parameters": {
        "url": "={{ $env.ANALYTICS_API_URL }}/api/export",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "from_date",
              "value": "={{ $now.minus({days: 30}).toISODate() }}"
            },
            {
              "name": "to_date",
              "value": "={{ $now.toISODate() }}"
            },
            {
              "name": "event",
              "value": "[\"login\", \"feature_used\", \"session_end\"]"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{ $env.ANALYTICS_API_KEY }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9d0fc88a-5df1-4436-8adc-7631918a5c53",
      "name": "Fetch Support Tickets",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        960,
        560
      ],
      "parameters": {
        "options": {},
        "operation": "getAll"
      },
      "typeVersion": 1
    },
    {
      "id": "84229a28-d043-4271-93cd-9c35caaa8a41",
      "name": "Fetch Billing Data",
      "type": "n8n-nodes-base.stripe",
      "position": [
        960,
        752
      ],
      "parameters": {
        "resource": "customer",
        "operation": "list"
      },
      "typeVersion": 1
    },
    {
      "id": "674fb095-502e-45a4-8283-0f2d7f4b5646",
      "name": "Merge All Data Sources",
      "type": "n8n-nodes-base.merge",
      "position": [
        1184,
        464
      ],
      "parameters": {},
      "typeVersion": 3
    },
    {
      "id": "3a258f57-473d-4dba-b6c2-9323bad7fab4",
      "name": "AI Risk Prediction",
      "type": "n8n-nodes-base.aiTransform",
      "position": [
        1408,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "8fb5b97d-94b3-4249-82b8-a75d87666578",
      "name": "Route by Risk Level",
      "type": "n8n-nodes-base.if",
      "position": [
        1632,
        464
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "critical-risk",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.risk_score }}",
              "rightValue": 90
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "0b044e5d-7071-4621-b25a-6c2a2d0b4ba7",
      "name": "Check High Risk",
      "type": "n8n-nodes-base.if",
      "position": [
        1856,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "high-risk",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.risk_score }}",
              "rightValue": 70
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "45dcc6f5-ad2b-4e11-829b-bd6393e20062",
      "name": "Generate Critical Intervention",
      "type": "n8n-nodes-base.aiTransform",
      "position": [
        2080,
        208
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ba69f187-e251-43b9-a575-40c452b565ac",
      "name": "Critical Risk Slack Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        1856,
        352
      ],
      "parameters": {
        "text": "\ud83d\udea8 CRITICAL CUSTOMER RISK ALERT \ud83d\udea8",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $env.HIGH_RISK_SLACK_CHANNEL }}"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.2
    },
    {
      "id": "56ff908b-337f-4287-ac06-bebcbd467c44",
      "name": "Generate High Risk Intervention",
      "type": "n8n-nodes-base.aiTransform",
      "position": [
        2080,
        512
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4d065f87-c832-467b-9892-c78a612e1824",
      "name": "Send Personalized Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2304,
        592
      ],
      "parameters": {
        "options": {},
        "subject": "={{ $json.subject_line }}",
        "toEmail": "={{ $json.customer_data.email }}",
        "fromEmail": "={{ $env.CS_TEAM_EMAIL }}"
      },
      "typeVersion": 2
    },
    {
      "id": "fb61c43d-f77c-4a02-9219-33d2784ad975",
      "name": "Update CRM with Risk Data",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        2304,
        368
      ],
      "parameters": {
        "operation": "update"
      },
      "typeVersion": 2
    },
    {
      "id": "835e4d22-7d99-47d6-8275-461513310a94",
      "name": "Generate Medium Risk Check-in",
      "type": "n8n-nodes-base.aiTransform",
      "position": [
        2080,
        752
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "connections": {
    "Check High Risk": {
      "main": [
        [
          {
            "node": "Generate High Risk Intervention",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate Medium Risk Check-in",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Risk Prediction": {
      "main": [
        [
          {
            "node": "Route by Risk Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Risk Analysis": {
      "main": [
        [
          {
            "node": "Fetch Product Usage Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Support Tickets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Billing Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Risk Level": {
      "main": [
        [
          {
            "node": "Generate Critical Intervention",
            "type": "main",
            "index": 0
          },
          {
            "node": "Critical Risk Slack Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check High Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Support Tickets": {
      "main": [
        [
          {
            "node": "Merge All Data Sources",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge All Data Sources": {
      "main": [
        [
          {
            "node": "AI Risk Prediction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Product Usage Data": {
      "main": [
        [
          {
            "node": "Merge All Data Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Medium Risk Check-in": {
      "main": [
        [
          {
            "node": "Send Personalized Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update CRM with Risk Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Critical Intervention": {
      "main": [
        [
          {
            "node": "Send Personalized Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update CRM with Risk Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate High Risk Intervention": {
      "main": [
        [
          {
            "node": "Send Personalized Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update CRM with Risk Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}