---
name: the-mood-ring
display_name: The Mood Ring
description: "Activate when a CSM needs to understand the emotional trajectory of a customer relationship — analyzes sentiment across Slack, email, meeting notes, and calendar patterns over time to detect enthusiasm fading, frustration building, or engagement declining before the customer says anything. Also activates for 'how is [customer] feeling', 'sentiment check for [account]', 'customer mood for [account]', 'are we losing [customer]'."
icon: "💍"
trigger: mood ring
inputs:
  - name: customer_name
    description: "Customer or account name to analyze emotional trajectory for"
    type: string
    required: true
  - name: time_range
    description: "Time range to analyze (e.g., 'last 6 months', 'YTD', 'since January')"
    type: string
    required: false
    default: "last 6 months"
tools: [kg_search, search_all]
depends-on: [html_design, highcharts]
---

## Overview

The Mood Ring reads the emotional trajectory of a customer relationship over time — not just point-in-time sentiment, but the arc. It detects when enthusiasm is fading, when formality is increasing, when response times are stretching, and when engagement is declining — often before the customer says anything explicitly. It visualizes the relationship as a heartbeat monitor, giving CSMs an early warning system for churn and a clear picture of relationship health.

## Workflow

### Step 1: Collect Communication History
- **Mode:** agentic
- **Input:** `{{customer_name}}`, `{{time_range}}`
- **Output:** Chronological list of all communications with metadata
- **Validate:** Communications found from at least 2 channels
- **On failure:** Note which channels have no data; need at least 2 months of history for meaningful analysis

Search across ALL channels for communications with the customer over the time range:

1. **Slack** — Load `slack_builtin` skill. Search customer channels and mentions. Capture: message text, timestamp, tone, length, emoji usage, thread participation, response latency.
2. **Email** — Load `outlook_builtin` skill. Search sent/received with customer contacts. Capture: subject, body length, formality markers, response time, sign-off style, CC list changes.
3. **Calendar** — Load `outlook_builtin` (calendar). Pull meetings with customer. Track: frequency, duration, cancellations, no-shows, attendee seniority changes.
4. **Knowledge Graph** — `kg_search` with customer name, `include_edges=True`. Pull relationship history, escalation events, decision points.
5. **Indexed Docs** — `search_all` for meeting notes, QBR summaries, account health reports mentioning the customer.

### Step 2: Analyze Sentiment Signals
- **Mode:** agentic
- **Input:** Communication history from Step 1
- **Output:** Scored sentiment signals by time period (weekly or biweekly buckets)

For each communication, score sentiment on multiple dimensions:

**Email Signals:**
- Length trend: are emails getting shorter? (declining engagement)
- Formality shift: moving from "Hey!" to "Dear team" (distancing)
- Response time: taking longer to reply? (deprioritizing)
- Enthusiasm markers: exclamation marks, positive adjectives declining
- Sign-off changes: "Cheers!" → "Best regards" → "Regards" (cooling)
- CC additions: adding procurement, legal, management (escalation risk)
- Question density: fewer questions = less investment in relationship

**Slack Signals:**
- Message frequency trend
- Emoji/reaction usage declining
- Thread participation decreasing
- Shifting from casual to formal tone
- Response latency increasing

**Calendar Signals:**
- Meeting cancellations or reschedules increasing
- Meeting duration shrinking
- Attendee seniority dropping (sending junior people)
- No-shows
- Declining meeting invitations

**Composite Sentiment Score:** For each time bucket, calculate a score from -100 (hostile/churning) to +100 (enthusiastic/expanding). Weight recent data more heavily.

### Step 3: Map the Emotional Arc
- **Mode:** agentic
- **Input:** Sentiment scores over time from Step 2
- **Output:** Emotional arc analysis with inflection points and pattern matching

Identify:
- **Inflection points:** When did sentiment shift? What event caused it?
- **Trend direction:** Improving, stable, or declining?
- **Velocity:** How fast is the change? Gradual drift vs. sudden drop?
- **Pattern matching:** Compare to known arcs:
  - "Enthusiastic → Neutral → Formal → Silent" = classic pre-churn
  - "Neutral → Curious → Engaged → Enthusiastic" = expansion trajectory
  - "Positive → Frustrated spike → Recovery" = handled escalation well
  - "Stable → Sudden drop → No recovery" = undetected incident

Generate the narrative: "This customer was enthusiastic in January, neutral by March, and their last 3 emails have gotten progressively shorter and more formal. They're about to churn and haven't told you yet."

### Step 4: Generate the Heartbeat Visualization
- **Mode:** deterministic
- **Tool:** Load `html_design` and `highcharts` skills
- **Input:** Sentiment scores, inflection points, arc analysis
- **Output:** Interactive HTML dashboard
- **Validate:** Dashboard renders with heartbeat chart
- **On failure:** Simplify to text-based sentiment report

Create `artifacts/mood-ring-{{customer_name}}.html` with:

1. **Heartbeat Monitor** — Hero visualization. Highcharts spline/area chart styled like an EKG:
   - X-axis: time (weekly buckets)
   - Y-axis: composite sentiment (-100 to +100)
   - Green zone (+50 to +100): healthy/enthusiastic
   - Yellow zone (0 to +50): neutral/watchful
   - Orange zone (-50 to 0): concerning/cooling
   - Red zone (-100 to -50): critical/churning
   - Annotated inflection points with what caused the shift

2. **Channel Breakdown** — Separate sentiment lines for Email, Slack, Calendar overlaid on one chart

3. **Signal Detail Cards** — Specific detected patterns:
   - "Emails shortened by 40% over 3 months"
   - "Response time increased from 2 hours to 3 days"
   - "Last 3 meetings had junior attendees only"
   - "Formality index increased 60% since March"

4. **The Diagnosis** — Prominent card:
   - Current temperature: "🥶 Cold" / "😐 Cool" / "😊 Warm" / "🔥 Hot"
   - Trajectory: "↘️ Declining" / "→ Stable" / "↗️ Improving"
   - Churn risk probability
   - The narrative summary

5. **Recommended Actions** — Based on diagnosis:
   - If declining: "Schedule executive alignment within 1 week"
   - If sudden drop: "Investigate the inflection point event"
   - If improving: "Capitalize — propose expansion conversation"

Design: Dark theme, medical/clinical aesthetic with green-on-dark heartbeat visualization.

### Step 5: Offer Follow-up Actions
- **Mode:** deterministic
- **Output:** Decision card

Options: "Schedule a save-the-relationship call" / "Run The Translator on their latest message" / "Compare mood across all my accounts" / "Set up sentiment monitoring alerts"

## Output

An interactive heartbeat-monitor-style dashboard showing the customer's emotional trajectory over time, with channel breakdown, signal details, a diagnosis with churn probability, and recommended actions.

## Lessons Learned

### Do
- Weight recent communications more heavily than older ones
- Look at PATTERNS not individual messages — one bad email doesn't mean churn
- Compare across channels — formal email but warm Slack = different signal than formal everywhere
- Always generate the narrative summary — numbers alone don't tell the story
- Include the "what caused the shift" for each inflection point

### Don't
- Don't confuse busy/short replies with negative sentiment — check if it's a pattern over 2+ weeks
- Don't alarm the CSM over normal seasonal fluctuations (holidays = less engagement)
- Don't ignore positive signals when looking for negative ones — confirmation bias is real
- Don't treat formality as always negative — some cultures and companies are naturally formal

### Common Failures
- Not enough history: need at least 2 months for meaningful trajectory. Note if insufficient.
- Customer uses channels outside monitoring: note gaps in coverage
- Sentiment misreads sarcasm or cultural communication styles: flag low-confidence readings

### When to Ask the User
- When trajectory shows a sudden unexplained drop — ask if they know what happened
- When signals conflict across channels (warm on Slack, cold on email)
- When there's insufficient data for reliable assessment