skills/chatbot-analytics/SKILL.md
Implement AI chatbot analytics and conversation monitoring. Use when adding conversation metrics, tracking AI usage, measuring user engagement with chat, or building conversation dashboards. Activates for AI analytics, token tracking, conversation categorization, and chat performance.
npx skillsauth add curiositech/windags-skills chatbot-analyticsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill helps you implement analytics for the AI coaching chat feature while maintaining HIPAA compliance.
IF abandonment_rate > 40% within 24h
→ THEN escalate to admin team
→ ELSE log for trending analysis
IF crisis_escalations > 5 within 24h
→ THEN send email alert immediately
→ ELSE track for weekly review
IF error_rate > 10% within 1h
→ THEN send Slack alert
→ ELSE continue monitoring
IF token_cost > budget_threshold
→ THEN enable cost controls
→ ELSE continue tracking
IF metadata.usedCrisisProtocol == true
→ category = "crisis_support"
ELSE IF metadata.usedCopingStrategies == true
→ category = "coping_strategies"
ELSE IF metadata.usedCheckInSupport == true
→ category = "checkin_support"
ELSE IF metadata.requestedClarification == true
→ category = "clarification"
ELSE
→ category = "general_chat"
IF data_contains(PHI_indicators)
→ REJECT storage, log metadata only
ELSE IF data_is_aggregate()
→ STORE for analytics
ELSE IF data_is_metadata()
→ STORE with encryption
ELSE
→ REVIEW manually before storage
messageContent, userQuery, or specificTopicstrackConversationEnd() is called in all exit paths, add session timeout logicstarted_at, user_id, and outcome columns, implement query optimizationSetup: User reports feeling overwhelmed, AI detects crisis indicators
// 1. Start tracking conversation
await trackConversationStart('conv-789', 'user-123');
// 2. AI processes message and sets metadata flags
const aiResponse = await processMessage(userMessage);
const metadata = {
usedCrisisProtocol: true,
usedCopingStrategies: false,
requestedClarification: false
};
// 3. Expert decision: Check crisis threshold first
if (metadata.usedCrisisProtocol) {
// Set category immediately
const category = 'crisis_support';
// Track the exchange with crisis flag
await trackMessageExchange('conv-789',
{ input: 150, output: 300 },
1200, // 1.2s response time
{ hadFallback: false, hasCrisisIndicator: true }
);
}
// 4. End conversation with escalation
await trackConversationEnd('conv-789', 'crisis_escalated');
// 5. Check if alert threshold reached
const recentCrises = await countCrisisEscalations(24); // last 24h
if (recentCrises > 5) {
await sendAlert('crisis_spike', { count: recentCrises });
}
Expert catches: The crisis flag triggers immediate categorization and outcome tracking, bypassing normal conversation flow analysis.
Novice misses: Would wait until conversation end to classify, missing real-time escalation opportunity.
Do NOT use this skill for:
Delegate when:
data-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.