Support Ticket Analytics: Root Causes, Refund Impact, Chatbot Test
Statistics & ExperimentsModel answerLast updated
Join ticket, resolution and survey tables to find the worst complaint category, estimate a refund policy's causal effect from observational data, and design a chatbot A/B test.
Scenario
You are a data scientist on the customer-care analytics team of an online retailer. Three tables describe support tickets:
complaints(complaint_id, user_id, category, timestamp): one row per ticket.resolutions(complaint_id, resolution_type, resolution_time_hours): how and how fast a ticket was closed.satisfaction_scores(user_id, complaint_id, csat_score): post-ticket survey result on a 1-5 scale.
Questions
- Finding the problem category. Determine which complaint
categoryhas the lowest averagecsat_scoreand which has the longestresolution_time_hours. Give the SQL or analytical approach, and explain how you would decide what to prioritize if the two metrics point at different categories. - Estimating a policy's effect. The business is considering a "proactive refund" policy for certain categories (a refund issued before the customer asks). With only historical observational data, how would you estimate its causal effect on
csat_score? - Testing a new channel. Design an A/B test to learn whether a new AI-chatbot resolution path yields higher
csat_scorethan human-only resolution. Address sample size and power.
Constraints
- About 20% of tickets have no
csat_score. Explain how you would handle the bias this introduces. resolution_time_hourscan contain extreme outliers because some long-standing claims are still open.
Example
If "Shipping" shows an average CSAT of 2.1 and an average resolution time of 48 hours, while "Product Quality" shows 3.5 and 12 hours, Shipping is the category to prioritize.
Edge cases to address
- Tickets that are unresolved (null
resolution_type). - Users who file several tickets in a short window (serial complainers).
Give a structured answer covering all three parts, with SQL where relevant.
Hints
Hint 1
Start from `complaints` and LEFT JOIN the other tables so open and unrated tickets are not silently dropped. Use medians and percentiles instead of means for resolution time, and treat the unresolved rate as its own metric.
Hint 2
For missing CSAT, first check whether missingness depends on observed variables (category, resolution time, unresolved status). If so, reweight responders by the inverse of their response probability, and run a best-case/worst-case bound as a sensitivity check.
Hint 3
For the refund question, the core problem is selection: agents refund the high-value or most severe cases. Think propensity scores with overlap and balance checks, then stronger designs such as agent-leniency instruments, difference-in-differences, or a threshold-based regression discontinuity.
Hint 4
For the A/B test, randomize by user rather than ticket, analyze by intent-to-treat, include guardrails such as response rate, escalations and cost, and compute sample size from the standard deviation and the minimum detectable effect.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Overview
The three parts cover descriptive analysis, causal inference, and experiment design. The common thread is to ask what bias each number carries before trusting it: missing surveys, censored resolution times, selection into treatment, and repeat complainers.
1. Finding the problem category
Build a ticket-level view. complaints is the full population, so start there and LEFT JOIN the others. An INNER JOIN would drop unresolved and unrated tickets, which are often the worst ones.
WITH base AS (
SELECT
c.complaint_id, c.user_id, c.category,
r.resolution_type, s.csat_score,
CASE WHEN r.resolution_type IS NULL THEN 1 ELSE 0 END AS is_unresolved,
COALESCE(r.resolution_time_hours,
EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - c.timestamp)) / 3600) AS time_hours
FROM complaints c
LEFT JOIN resolutions r ON r.complaint_id = c.complaint_id
LEFT JOIN satisfaction_scores s ON s.complaint_id = c.complaint_id
)
SELECT
category,
COUNT(*) AS n_tickets,
COUNT(DISTINCT user_id) AS n_users,
AVG(csat_score) AS avg_csat,
AVG(CASE WHEN csat_score IS NULL THEN 1.0 ELSE 0 END) AS csat_missing_rate,
AVG(CASE WHEN csat_score <= 2 THEN 1.0 ELSE 0 END) AS share_low_csat,
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY time_hours) AS median_hours,
PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY time_hours) AS p90_hours,
AVG(is_unresolved) AS unresolved_rate
FROM base
GROUP BY category
ORDER BY avg_csat ASC, median_hours DESC;
Outliers. Open claims that are months old dominate the mean. Report median and p90, keep the unresolved rate as a separate metric, and if a mean is needed, winsorize at p99. A more rigorous option is Kaplan-Meier curves per category with open tickets treated as right-censored.
Missing CSAT (about 20%). Do not assume it is random; very angry and very happy customers respond more often.
- Diagnose: compare missingness by category, resolution type, time and unresolved status.
- Correct: fit a response-propensity model and weight responders by 1/p (inverse probability weighting), or use multiple imputation.
- Bound: recompute category averages assuming every missing score is 1, then 5. If the category ranking survives both extremes, the finding is robust.
- Avoid mean imputation, which shrinks variance and hides category differences.
Serial complainers. One user with 15 tickets can distort a category. Report both per-ticket and per-user averages (average within user first), flag users with, say, 3+ tickets in 7 days and check whether rankings change without them, and use user-clustered standard errors.
Prioritization. The lowest-CSAT and slowest categories may differ. Rank by expected impact:
impact = ticket volume × (target CSAT − category CSAT)
Add confidence intervals so small categories are not over-read. In the example, Shipping is worse on both metrics, so it wins provided its volume is material and the gap holds after reweighting.
2. Causal effect of proactive refunds (observational)
Define the estimand: the effect on the treated (ATT) in the target categories, with CSAT as the outcome.
Main threat: selection. Agents historically refund high-value orders, loyal customers and severe failures, all of which correlate with CSAT. A raw refunded vs. not-refunded comparison is confounded.
Primary approach: propensity methods.
- Model P(refund | category, order value, tenure, prior complaints, severity proxies, channel, week).
- Match, or use IPW or doubly robust AIPW.
- Check overlap and trim propensities near 0 or 1.
- Check covariate balance (standardized mean difference under 0.1).
- Estimate ATT with a confidence interval, using response weights for missing CSAT.
- Run sensitivity analysis (Rosenbaum bounds or E-value) to see how strong an unobserved confounder must be to erase the effect.
Stronger designs if the data permits:
- Instrumental variable: agent leniency, if tickets are assigned quasi-randomly. Check the exclusion restriction, since lenient agents may also be friendlier.
- Difference-in-differences: if refund rules changed for some categories only; verify parallel pre-trends.
- Regression discontinuity: if refunds trigger above a threshold such as order value.
Recommend following up with a randomized pilot, since observational estimates always carry residual doubt.
3. A/B test: chatbot vs. human-only
Design
- Randomize by user, so serial complainers do not experience both arms and arms do not contaminate each other.
- Restrict to categories where the chatbot can operate.
- Analyze by intent-to-treat: chatbot users who escalate to a human stay in the treatment arm.
- Ramp at about 5% to catch failures, then 50/50. Run whole weeks, at least two.
Metrics
- Primary: mean CSAT, plus top-2-box rate (share of 4-5).
- Guardrails: cost per resolution, refund dollars, escalation rate, reopen/repeat contact within 7 days, survey response rate (the chatbot may change who responds), and downstream repurchase or churn.
- Secondary: median resolution time.
Sample size. With σ ≈ 1.2, a minimum detectable effect δ = 0.1, α = 0.05 (two-sided) and 80% power:
n per arm ≈ 2 × (1.96 + 0.84)² × σ² / δ² ≈ 2 × 7.84 × 1.44 / 0.01 ≈ 2,260 responses.
Divide by the response rate (about 80%) to get roughly 2,800 users per arm, and inflate further for user clustering (design effect) if users file multiple tickets. If traffic is limited, accept a larger MDE or use variance reduction such as CUPED with pre-period CSAT.
Analysis. Compare means with a t-test or regression on user-level outcomes, use clustered or user-level aggregation, check sample-ratio mismatch, test response-rate differences between arms, and check heterogeneity by category without over-slicing (correct for multiple comparisons).
Common mistakes
- INNER JOINs that hide unresolved or unrated tickets.
- Reporting mean resolution time without handling censoring and outliers.
- Imputing the global mean for missing CSAT.
- Reading a naive refunded-vs-not comparison as causal.
- Randomizing by ticket, then analyzing as if tickets were independent.
- Ignoring that the chatbot can shift survey response rates.