Customer Health & Churn Alert
Customer Health Scoring & Churn Alert

A customer success team was manually cross-referencing three data sources — HubSpot deal records, support ticket history, and product feature usage spreadsheets — to identify accounts showing early signs of churn. Every at-risk review required opening multiple tools, applying subjective judgment with no consistent scoring criteria, and repeating the process across every account in the book. By the time warning signs were spotted, the window to act before renewal had often already closed.
We built a dual-pipeline n8n workflow: a reusable webhook endpoint that scores incoming support tickets by sentiment, and an on-demand churn analysis loop that evaluates every HubSpot deal against three independent risk dimensions and dispatches a structured alert email for any account crossing the risk threshold.
The Workflow
Trigger: Two Entry Points
Pipeline A — Webhook: Ticket Scoring An HTTP POST webhook receives individual support ticket payloads. This pipeline is self-contained and reusable — it operates both as a standalone scoring endpoint and as an internal tool called by the AI agent during the full churn analysis run.
Pipeline B — On-Demand: Full Churn Analysis Triggered manually or on a schedule to evaluate all active HubSpot deals in sequence. Each deal passes through enrichment, multi-signal scoring, and alert dispatch within the same execution.
Stage 1: Support Ticket Sentiment Scoring (Pipeline A)
Node 1 - Webhook: Receive Ticket Accepts an incoming support ticket body via HTTP POST. Passes the ticket content to the LangChain sentiment analysis chain.
Node 2 - LangChain Sentiment Analysis (OpenAI GPT-4o-mini) Evaluates the ticket content and returns a numeric sentiment score using the following scale:
- Positive sentiment → +10
- Neutral sentiment → +5
- Negative sentiment → −10
The numeric output is stored against the ticket record and is available as input to the churn scoring stage.
Node 3 - OpenAI GPT-4o-mini (Shared Language Model)
A single model node shared across all three AI components in the workflow — the sentiment analysis chain, the data-gathering AI agent, and the churn risk LLM chain — via the ai_languageModel connection. Centralizes credential management and model configuration.
Stage 2: HubSpot Deal Retrieval (Pipeline B)
Node 4 - AI Agent: Data Gatherer (OpenAI GPT-4o-mini) Uses an MCP Client Tool connected to HubSpot via HTTP Streamable transport to retrieve deal records for all active accounts. For each deal, the agent pulls: deal record, associated contact email, support ticket history, and product feature usage data. No manual CRM navigation required — the agent queries HubSpot directly.
Node 5 - MCP Client Tool (HubSpot)
Connected to the data-gathering agent as an ai_tool. Handles the HubSpot API calls for deal records, contact associations, and ticket retrieval via the MCP HTTP Streamable transport layer.
Stage 3: Feature Usage Normalization
Node 6 - Code Node: Group Feature Usage by Product Takes the raw feature usage data returned for each account and groups activity records by product name. This normalization step surfaces usage trends per product, which the churn scoring chain uses to detect declining engagement patterns.
Stage 4: Churn Risk Scoring
Node 7 - LangChain Churn Risk Chain (OpenAI GPT-4o-mini) Evaluates each account against three independent churn signals:
- Deal age — account active for more than one year (elevated risk threshold)
- Sentiment score — net-negative aggregate across support tickets (sum of scored tickets below zero)
- Feature usage trend — declining engagement with core product features based on grouped usage data
The chain outputs a risk level classification — Low, Medium, or High — and generates 2–3 recommended actions specific to the account's signal profile.
Stage 5: Alert Generation and Dispatch
Node 8 - Code Node: Build Alert Email (HTML) Constructs a structured HTML email body containing: account name, risk level classification, the three signal evaluations (deal age, sentiment, usage trend), and the recommended actions from the churn risk chain. Converts the structured output to HTML for SMTP dispatch.
Node 9 - SMTP: Send Churn Alert Email Dispatches the formatted alert to the Customer Success Manager assigned to the account. The email gives the CSM immediate triage priority — risk level is visible in the subject line — and concrete next steps without requiring them to open HubSpot, a ticket queue, or a usage dashboard.
Results
- Manual cross-referencing fully eliminated — CRM data, ticket sentiment, and feature usage are all gathered and evaluated in a single automated run, with no human steps between trigger and alert
- Consistent scoring across every account — the same three-signal rubric is applied to all deals, replacing subjective judgment with a repeatable evaluation
- Ticket scoring pipeline is reusable — operates as a standalone POST endpoint for real-time ticket triage and as an internal tool during the full churn analysis loop
- Risk classification enables immediate prioritization — CSMs receive High / Medium / Low classification in the alert, so they know which accounts to act on first without reading raw data
- Recommended actions included in every alert — reducing the gap between churn signal detection and team response
Stack
| Layer | Tool |
|---|---|
| Automation | n8n (self-hosted) |
| Triggers | Webhook (ticket scoring) · Manual / Schedule (churn analysis) |
| Language Model | OpenAI GPT-4o-mini (shared — sentiment, agent, churn chain) |
| CRM Integration | HubSpot via MCP Client Tool (HTTP Streamable transport) |
| AI Framework | n8n LangChain nodes (sentiment chain, agent, churn risk chain) |
| Email Dispatch | SMTP |
My Role
- Designed the dual-pipeline architecture: a reusable webhook scoring endpoint for individual tickets and a sequential deal-loop pipeline for full churn analysis
- Wired the single GPT-4o-mini node as the shared language model across all three AI components — sentiment analysis, data-gathering agent, and churn risk chain — to centralize configuration
- Connected HubSpot via MCP Client Tool using HTTP Streamable transport for deal record retrieval, contact association, and ticket history without direct API integration work per endpoint
- Built the ticket sentiment scoring model: Positive +10, Neutral +5, Negative −10, with net-score aggregation for per-account churn signal evaluation
- Implemented the feature usage normalization code node to group raw activity records by product name for trend detection
- Authored the churn risk chain evaluation logic across three independent signals: deal age threshold, net sentiment score, and feature usage decline
- Built the HTML alert email construction node and configured SMTP dispatch with risk level classification and recommended actions in every alert