---
name: ticket-trend-analyzer
description: Fetches Salesforce support cases and Helpjuice articles via
  API to identify volume trends, top issue themes, repeat customers,
  escalation patterns, product friction signals, and documentation gaps.
  Use when user mentions "ticket trends", "support analysis", "support
  health", "what are customers struggling with", "repeat issues",
  "biweekly report", "weekly report", "ticket patterns", "documentation
  gaps", or asks to "analyze my tickets". Runs on a biweekly cadence.
license: MIT
compatibility: Requires curl, jq, SALESFORCE_USERNAME, SALESFORCE_PASSWORD,
  SALESFORCE_SECURITY_TOKEN, HELPJUICE_API_KEY, HELPJUICE_SUBDOMAIN
metadata:
  author: sofia
  version: "2.0"
allowed-tools: Bash Read Write
---

# Ticket Trend Analyzer

Fetches Salesforce cases and Helpjuice articles via API and produces a
narrative support health report. Covers volume trends, top issue themes,
escalation signals, product friction patterns, and documentation gaps.

The report tells a story — what's happening, what's accelerating, and
what to do about it. It is designed to be skimmable by leadership and
actionable by support ops, product, and docs.

**Cadence: biweekly.** One report covers the two most recent full
Mon–Sun weeks (14 days), never including today. "Period" throughout
this skill means that 14-day window, and "prior period" means the 14
days before it. Reports before 2026-10 were weekly; see Step 2 for how
to compare against them.

---

## Prerequisites

- SALESFORCE_USERNAME environment variable
- SALESFORCE_PASSWORD environment variable
- SALESFORCE_SECURITY_TOKEN environment variable
- HELPJUICE_API_KEY environment variable
- HELPJUICE_SUBDOMAIN environment variable
- curl and jq installed

---

## Quick Reference

### Salesforce Cases

# Fetch cases for a biweekly report: exact Mon–Sun range, both dates
# inclusive (UTC)
scripts/salesforce-api.sh cases --start 2026-08-31 --end 2026-09-13

# Relative to today (includes today's partial day; trim before use)
scripts/salesforce-api.sh cases --days 15

# Fetch cases with a specific status
scripts/salesforce-api.sh cases --days 15 --status Open

`cases` follows `nextRecordsUrl` and returns every matching record, so
there is no row cap. A 14-day window is roughly 750–800 raw cases, about
70% of them spam or internal before Step 1b.

# Fetch a single case by case number
scripts/salesforce-api.sh case --number 00160094

# Fetch a case's full email thread, incl. agent resolution replies
# (Incoming=false = agent). Use to confirm bugs (Step 5c) and doc-gap
# theses (Step 6) — the inbound Description alone only shows the customer.
scripts/salesforce-api.sh case-thread --number 00160094

**READ THE ENTIRE THREAD OUTPUT — never pipe it through `tail` or read only
the last N characters/lines.** A thread can have several `Incoming=false`
messages: an auto-ack template first, then a real diagnostic reply, then
more back-and-forth. The actual resolution is often in the middle, not at
the end — quoted-reply chains mean the LAST message in the array can be a
short "thanks, following up" that reads as boilerplate while the substantive
diagnosis sits earlier in the same thread. Reading only the tail has
produced real, published errors before (calling a confirmed diagnosis
"unconfirmed" because the actual reply was cut off). Print every record and
read all of them before concluding a case has no resolution.

**Check for merged cases before treating same-account cases as separate
incidents.** Salesforce case merges leave a signature you can detect without
a special field: pull `case-thread` for a case, and if its EmailMessage
thread contains an auto-ack ("Case Received!" / "Appcues Support Case
Received!") for a DIFFERENT case number than the one you queried, the two
cases have been merged — that thread is now the single source of truth for
both. Concretely:
- If `case-thread --number X` returns 0 records (or only a thin/unrelated
  reply) for a case that's `Status = Closed`, don't conclude "no diagnosis
  available" — try nearby case numbers from the *same contact/account*
  filed within the same day. One of them is likely the surviving case that
  absorbed X's thread.
- If a thread you pulled contains receipts for two different case numbers,
  treat them as **one incident**, not two — dedupe them before counting
  cases per theme, per account (Step 5b), or in total volume (Step 3). Cite
  both case numbers when referencing it, but count it once.
- This check matters most for repeat-customer / churn-risk scoring (Step
  5b): two merged cases from the same account are not a "2+ cases, repeat
  friction" signal — they're one report that happened to be filed twice.

### Helpjuice Articles

**Do NOT use `helpjuice-api.sh`** — it shells out to `python3`, which triggers
a broken `xcrun` error. Use direct `curl` + `jq` calls instead.

```bash
export APPCUES_HOME="$HOME/appcues-support" && source "$APPCUES_HOME/.env"

# List all published articles (paginate with ?page=N — capped at 25/page)
curl -s "https://appcues.helpjuice.com/api/v3/articles?page=1" \
  -H "Authorization: $HELPJUICE_API_KEY" | jq '.articles[] | {id, name}'

# Get a single article by ID
curl -s "https://appcues.helpjuice.com/api/v3/articles/12345" \
  -H "Authorization: $HELPJUICE_API_KEY" | jq '.article | {id, name, body}'

# Search articles
curl -s "https://appcues.helpjuice.com/api/v3/articles?search=TERM" \
  -H "Authorization: $HELPJUICE_API_KEY" | jq '.articles[] | {id, name}'
```

---

## Workflow

### Step 1: Fetch and validate data

Load credentials then fetch data from both APIs:

```bash
export APPCUES_HOME="$HOME/appcues-support" && source "$APPCUES_HOME/.env"
```

scripts/salesforce-api.sh cases --start <monday> --end <sunday>

Use `--start`/`--end` with the Monday and Sunday of the window. This
also works for any past range. Confirm `totalSize` equals the number of records returned. If they
differ, pagination broke partway through; stop and report it rather
than analyzing a partial window.

```bash
curl -s "https://appcues.helpjuice.com/api/v3/articles?page=1" \
  -H "Authorization: $HELPJUICE_API_KEY" | jq '.articles[] | {id, name}'
```

#### Verify SOQL fields
Before proceeding, check that the SOQL query in
`scripts/salesforce-api.sh` includes ALL fields listed in
`references/salesforce-columns.md`. If any are missing, update
the script before fetching. In particular, confirm `Account.Name`
is in the SELECT — without it, repeat customer analysis is impossible.

#### Filter to the requested date range
`--start`/`--end` return exactly the requested range. If you used
`--days` instead, it counts back from now and includes today's cases,
so filter the response to ONLY cases whose `CreatedDate` falls within
the requested range before proceeding.

Default window: the two most recent full Mon–Sun weeks. For example,
run on Wed Oct 15 → Mon Sep 29 to Sun Oct 12; discard anything from
Oct 13 onward and anything before Sep 29.

#### Validate
Before analysis, confirm:
- Cases were returned with at least Id, Subject, CreatedDate, and Type populated
- Account.Name is populated on at least some records (null is
  expected for cases without an associated account)
- Helpjuice articles were returned with at least title populated
- Note total case count and date range covered

Stop and ask if either API call fails or returns empty results.
Do not proceed with incomplete data.

Report back before continuing:
"I fetched X cases from [start date] to [end date] and Y Helpjuice
articles. Here's what I'm working with: [any issues flagged]."

---

### Step 1b: Filter out spam and sales ops

Before any analysis, remove cases that are not true customer support.
All subsequent steps operate only on the filtered dataset.

#### Spam and non-support removal
Remove cases matching ANY of these criteria:

| # | Category | Rule |
|---|---|---|
| 1 | Spam / Bulk Mail | Type = "Spam/Bulk Mail" |
| 2 | Internal / System | Type = "Internal/System" |
| 3 | Sales ops — deal processing | Type = "Billing" AND Subject starts with "New Case from Sales" |
| 4 | Sales ops — provisioning | Type = "Provisioning" AND Subject starts with "Renewed:" or "Closed Won:" or "Closed Lost:" |
| 5 | Sales ops — outreach | Subject contains "Outreach Campaign" |
| 6 | Sales ops — MAU tracking | Subject contains "New MAU Upgrade Opp Created" |
| 7 | Auto-generated summaries | Subject starts with "Tasks summary for" |
| 8 | CSAT auto-replies | Subject = "How was our support?" |

Normalize Type values (trim whitespace, case-insensitive match)
before applying these rules.

#### What to keep
Keep all other cases, including:
- **Billing cases** — customer-initiated billing questions (e.g.
  "change billing contact", "cancellation of subscription") are
  real support issues and belong in the main analysis
- Renewal replies from customers (e.g. "Re: Appcues Renewal Alert"
  with a real question in the body)
- Cases with Type = None/blank — these are often real support cases
  submitted via forms

#### Internal senders (`SuppliedEmail` ends in `@appcues.com`)
Read the Description before dropping these. Keep a case when a CSM or
AM is relaying a real customer's problem: "New Case from Slack"
tickets, "logging this support ticket for <Account>", or "looping in
Support" on a customer thread. Drop it when the Appcues employee is the
one asking: data pulls, invoice or AR follow-ups, internal security
questionnaires, meeting logistics, or training scheduling. When in
doubt, ask whether a customer is waiting on the answer.

Also drop non-support mail that slips past the Type rules: vendor
marketing, payment remittance and PO notices, vendor incident notices
sent to Appcues, inbound sales leads, and repeated automated reminders
for the same questionnaire (keep one).

#### Report the filter results
After filtering, briefly confirm the filtered count:
"Analyzing N true support cases from [start date] to [end date]."

Do NOT include a spam/sales ops filtering breakdown in the final report.
The filtering is a data preparation step — keep it out of the output.

---

### Step 2: Load trend history

Read the trend history file at `data/trend-history.json` if it exists.
This file contains structured data from prior reports and powers the
trend arrows and cross-period trend analysis.

Fields used for period-over-period comparison in Step 7 Section 2:
`total_cases`, `escalation_rate`, `median_time_to_escalation_hours`,
`median_resolution_hours`, `closed_cases_in_period`.

#### Mixed weekly and biweekly history
Entries before 2026-10 cover 7 days; biweekly entries carry
`"period_days": 14`. Treat an entry with no `period_days` as 7. Only
compare metrics across entries of the same length:

- **Key Metrics (Section 2):** if the most recent entry is not a
  14-day entry for the immediately preceding 14 days, do not stitch
  weekly entries together. Medians and rates can't be summed, and the
  weekly history has gaps. Recompute the prior period directly from
  Salesforce with the same method as Step 3 and use that.
- **Theme trends and recurrence (Steps 5, 6):** weekly entries still
  count. A theme or gap present in any entry within the lookback
  window counts as having appeared before.

If the file does not exist, proceed without it. Trend columns will show
🆕 for all themes.

---

### Step 3: Volume and trend analysis
- Total case volume for the period (use filtered dataset only)
- Direction vs. prior period — growing, shrinking, or stable?
- Keep this to 1-2 sentences. No tables, no day-of-week breakdowns.

#### Escalations — compute BOTH measures
`Sent_to_SE_Queue__c` supports two different counts, and reporting only
the first understates engineering load:

1. **Escalated cases (opened in-period)** — cases created in the period
   with a non-null `Sent_to_SE_Queue__c`. This is the denominator for
   `escalation_rate`. Keep it: it answers "what share of new cases
   needed an engineer."
2. **Escalations actioned in-period** — every case whose
   `Sent_to_SE_Queue__c` falls in the period, *regardless of
   CreatedDate*. Fetch with
   `cases --start <monday> --end <sunday> --by escalated`. This answers "how much
   escalation work happened this period," and it is usually higher
   because older cases get escalated too.

Apply the Step 1b filters to both, and report both filtered so they're
comparable period-over-period. Record both in Step 8.

**Two caveats to state in the report:**
- Any case escalated but excluded by Step 1b (internal requester, spam,
  outreach) must be called out rather than silently dropped — say "N
  customer escalations out of M escalated cases."
- The field undercounts. Agents who write "I've let our product team
  know" in-thread often set no SE-queue timestamp, so every escalation
  count is a floor. Check agent replies in the top themes before
  implying the numbers are complete.

**Never write "all N escalations this period" when N came from measure 1.**
Say "all N escalations among cases opened this period." The unqualified
phrasing is false whenever measure 2 is larger, and it will leak into
the Executive Summary, Product Friction, and the Slack summary.

> Example (2026-07-27): 3 escalations among cases opened in-period
> (3.9%) but 6 actioned in-period — four older cases were escalated
> that week and appeared nowhere in the first draft. A 4th in-period
> escalation was an internally-filed report, excluded from volume.

#### Resolution time
Compute median resolution time for cases **closed during the period**:
- Filter to cases where `ClosedDate != null` AND `ClosedDate` falls
  within `[period_start, period_end]`. Use `ClosedDate`, not
  `CreatedDate`, so cases opened earlier but closed this period count
  toward this period's median (and cases opened this period but still
  open don't artificially pull it down).
  Fetch them with `cases --start <monday> --end <sunday> --by closed`.
- For each qualifying case, compute `(ClosedDate − CreatedDate)` in
  hours. Take the median.
- Record two values for Step 7 and Step 8:
  - `median_resolution_hours` — one decimal
  - `closed_cases_in_period` — integer N
- Format for display:
  - `< 48h` → `"14.6h"`
  - `≥ 48h` → `"3.2d"` (hours / 24, one decimal)
  - If `N < 5` → append `" (low N=3)"` and skip the direction arrow

---

### Step 4: Issue clustering
Group cases into themes using ALL of these fields:
- **Subject** — the case title
- **Description** — the body of the case
- **Product__c** — the Salesforce Product field
- **Feature__c** — the Salesforce Feature field

Use all four fields together to classify each case. Do not rely
on Subject alone — many cases have generic subjects but contain
the real issue in Description, Product, or Feature.

Clustering rules:
- Identify recurring keywords and phrases across all four fields
- Cluster into distinct issue themes
- Count frequency per theme
- Note which Type values map to which themes
- Only leave a case in "Other / General" if Subject, Description,
  Product, and Feature are all uninformative or blank

For the report, only the **top 5 themes by case count** appear in
the main body. All remaining themes go to the appendix.

---

### Step 4b: Tag each case by app surface

Classify every case in the filtered dataset as `appcues_app`, `studio`,
or `unclear`. The Appcues App is the new product; Studio is the legacy
app still in wide use. Both run side-by-side, so a rollout question or a
regression on the new surface should not get lost inside a generic
"campaigns" theme.

Apply these rules in order, first match wins:

1. **Salesforce Product__c.** Check first, before any text matching:
   - `Product__c = "Studio"` → `studio`. Reliable — support only uses
     it for Studio-specific issues.
   - `Product__c = "Appcues App"` → **candidate `appcues_app`, verify
     before committing.** Support-team tagging on new-product cases is
     inconsistent — the field has been observed on cases about generic
     entitlement, onboarding, and email that are NOT actually about the
     new app surface. Confirm by reading the case: the customer must
     be describing an Appcues App surface (dashboards + cards, Key
     Moments, Recommendations, Appcues AI, campaigns/tactics/briefs,
     or the new builder). If the case is a generic flow/email/entitlement
     question that could equally be Studio, tag `unclear`.
   - `Product__c = "Builder"` → **do NOT map straight to Studio.**
     Both apps have a builder. Fall through to the text rules.
   - `Uncategorized/Other` and blank → fall through. ~44% of real
     support cases have no useful Product value, so the text rules
     do meaningful work.
2. **High-confidence Appcues App text** (Subject + Description + any
   pulled `case-thread`). Any of these → `appcues_app` — but the term
   must appear in the **customer's own message** describing their
   issue, not in an agent template/signature (e.g. an OOO auto-reply
   that says "you now have access to the new Appcues") or as a passing
   comparison ("does the new Appcues do this differently?"). If the
   only mention is in a template or an aside while the customer's
   actual question is about a Studio surface (email builder, Studio
   flows, integrations), tag `studio` or `unclear`, not `appcues_app`:
   - `Appcues App`, `the new Appcues`, `the new app`
   - `new editor`, `new builder` (customer-side terms for the Appcues
     App builder — seen in real cases, e.g. 00165778, 00165776)
   - `Appcues AI` (require the two words adjacent — "Appcues" and "AI"
     appearing separately does NOT count)
   - `Key Moment` / `Key Moments`
   - `tactic` / `tactics` (Appcues App grouping construct; Studio has none)
   - `uplift` (Appcues App metric)
   - `brief` when adjacent to `campaign`, `tactic`, or `experience`
   - `Recommendations` capitalized as a feature name (not the verb
     "recommend" or a lowercased "recommendations")
3. **High-confidence Studio text.** Any of these → `studio`:
   - Literal `Studio`
   - `Flow Builder`, `Chrome Extension` (builder access), `Events
     Explorer`, or `Goals` referenced as a surface
4. **Ambiguous terms paired with a companion.** Only counts as
   `appcues_app` when paired in the same case:
   - `campaign` + (`objective` | `brief` | `Key Moment` | `Appcues AI` |
     `dashboard` | `tactic`)
   - `dashboard` + (`card` | `uplift` | `Key Moment`)
   - `objective` + (`campaign` | `tactic` | `experience`)
5. **Default** → `unclear`.

Record the tag on each case for use in Step 7. Do not create a theme
out of this — it's a cross-cutting label, not a cluster.

---

### Step 5: Enrich themes with context

For each of the top 5 themes, annotate with:
- **Trend direction** (from trend history): ⬆️ growing, ➡️ stable,
  ⬇️ declining, 🆕 first appearance
- **Repeat flag**: If the theme appeared in the 2 previous reports
  as well, note "Nth report running" (e.g., "3rd report running").
  Legacy weekly reports count as reports here.
- **Escalation flag**: If any case in this theme was escalated
  (Sent_to_SE_Queue__c non-null), note count (e.g., "2 escalated")

---

### Step 5b: Churn risk watchlist

Identify accounts with repeat contact this period that suggests churn
risk, and surface them to Customer Success with a risk score.

#### Scoring method
Compute a `risk_score` for every account with 2+ cases in the period:

1. **Base points per case (type weight)**:
   - `Troubleshooting` or `Bug` → 2 pts
   - All other Types → 1 pt
2. **Escalation bonus**: +3 pts per escalated case in the account
3. **Theme concentration bonus**: +2 pts if more than 50% of the
   account's cases hit the same `Feature__c` (or clearly the same
   product area when Feature is blank)

Accounts with a single case are not scored or listed, even when that
case was escalated.

#### Signal classification
Classify each flagged account by the pattern in their cases:

| Signal | When to assign |
|---|---|
| `friction` | Same issue repeated, or escalations on core features. Customer is hitting walls, not learning. |
| `adoption` | Multiple cases but spread across distinct How To / feedback topics. Customer is ramping up. |
| `mixed` | Multiple cases across unrelated product areas with no dominant friction pattern. |
| `low` | High volume but clearly benign — billing/account housekeeping, etc. |

Use Description, Product__c, and Feature__c to compare cases —
not Subject alone.

#### CSM resolution
For every flagged account, pull the CSM name from
`Account.Customer_Success_Manager_Name__c` and show it as plain text.
The report does not @-mention CSMs; Customer Success reads the
watchlist from Notion. Also flag any issue theme appearing 3+ times
across the period as a repeat pattern (surface in Trends Across
Periods, Step 7 Section 6).

If the CSM name is in `known_departed.names` in
`references/csm-notion-mapping.json`, or a case thread says the CSM
"is no longer with Appcues", add "**CSM reassignment needed**" to the
row's Signal cell. Skip the column value for `Customer Success` and
`CRM Bot`; they are a placeholder and an automation account, not
people.

Cap: the flagged table shows all accounts with `risk_score >= 5`.
Accounts scoring below 5 are not listed.

---

### Step 5c: Product friction signals

**A ticket is a bug ONLY if its Salesforce `Type` is `Bug`.** This is the
support team's own triage decision — do not override it and do not infer
it. If `Type` is anything else (Troubleshooting, How To, Integrations,
etc.), do NOT call it a bug, a defect, "broken", or "a known issue" — no
matter how the customer worded it, and no matter whether it was escalated.
Customer language ("bug", "URGENT", "broken", "not working") and SE-queue
escalation (`Sent_to_SE_Queue__c`) signal urgency, not a defect.

**Output style — keep the mechanic internal.** The `Type` field is how
*you* decide what's a bug; the reader never needs to see it. In the report,
never write "Type=Bug", "Type=Troubleshooting", or otherwise reference the
Type field. Just call a bug a bug — it was determined a bug by support,
full stop. Describe non-bugs by what they are (a how-to question, a config
issue, a Builder connection issue) without naming the type.

This applies everywhere in the report, including the Churn Watchlist
(Step 5b) prose and the Executive Summary — never describe a non-`Bug`
ticket as a bug.

This section surfaces two things:

**1. Confirmed bugs — `Type = Bug` cases.** Group them by product area;
note frequency, affected accounts, and case numbers. To describe the
defect accurately (rather than parroting the customer's subject line),
read the agent's resolution:

```
scripts/salesforce-api.sh case-thread --number <NUM>
```

`Incoming=false` rows are the agent's replies; the latest carry the
resolution and the actual symptom.

**2. Other product friction (optional) — non-`Bug` patterns.** Recurring
UX confusion or missing-feature requests from non-`Bug` cases can still be
worth surfacing — but label them **friction** or **feature request**, NOT
bugs. A recurring confusion is often a doc opportunity instead (route to
Step 6 as a Quality or Discoverability gap).

Cap at 3 signals. Lead with confirmed bugs.

> Example (do NOT repeat): one account's "possible status badge bug"
> was `Type = Troubleshooting`, and the agent confirmed it was user error
> (no unpublish date set). It is NOT a bug and must not be reported as
> one — the customer's subject line saying "bug" is irrelevant.

**Verify before asserting a cause.** Before including a non-`Bug` case as a
friction signal, read its case-thread. What you find changes how you can
write about it:

- **Agent reply confirms a real, unresolved product issue** → describe it
  with that confirmation (cite the agent's words, not just the customer's).
- **Agent reply confirms user error / config issue / "working as intended"**
  → not a friction signal — drop it (see the status-badge example above).
- **No agent diagnosis exists** — only an auto-ack template, the case is
  still open, or the customer never replied to a follow-up — you only have
  the customer's *unverified* self-report. Do not write it up as if the
  cause were established. Specifically:
  - Do not speculate on a root cause ("looks like a publish/cache bug,"
    "not user error") — you have no evidence either way, including that
    it isn't user error.
  - Do not tell Engineering to "investigate this bug" — the recommended
    action should be to get the case a real diagnosis first (e.g., "have
    an agent follow up and confirm root cause"), not to route the
    customer's guess straight to Engineering as if it were confirmed.
  - State the verification gap explicitly in the write-up — e.g.
    "customer-reported, unconfirmed — no agent reply on file / customer
    did not respond to follow-up; could be user error." This applies
    anywhere the signal is mentioned: Product Friction Signals, Churn
    Watchlist prose, Executive Summary, and Recommended Actions alike.
  - You may still report the recurrence (e.g., "2 cases, same feature,
    both unconfirmed") — the pattern itself is a real observation. What's
    not allowed is dressing up the customer's guess as a diagnosis.

---

### Step 6: Documentation gap analysis

#### Exclusions
Spam and sales ops were already removed in Step 1b. Before
cross-referencing against Helpjuice, additionally exclude the
following Type values — these are not documentation opportunities:

| # | Category | Type values to exclude |
|---|---|---|
| 1 | Billing & Account | Billing, Provisioning, Churn, Entitlement |
| 2 | Services | Services |
| 3 | Non-support | Feature Request, Sales, Renewal, Reseller Support |
| 4 | Bug | Bug |

**Note:** Billing cases ARE included in the main analysis (Steps 3-5)
but excluded here because billing questions are not documentation
opportunities.

#### Coverage assessment

Assess each remaining theme in **two stages**:

- **Stage 1 — Is there an article?** The content-gap check. Runs for
  every theme. This is the foundation: net-new functionality won't
  have docs yet, so this is where genuine *content* gaps surface.
- **Stage 2 — Is the coverage working?** Runs only when an article
  DOES exist. In a mature knowledge base almost everything has *some*
  article, so "an article exists" is rarely the end of the story —
  Stage 2 is what keeps this analysis useful by catching articles that
  exist but don't answer the question (quality) or that customers
  can't find (discoverability).

A theme produces at most one gap, typed as **Content**, **Quality**,
or **Discoverability** (or no gap). The type drives the recommended
action: write, revise, or resurface.

**Helpjuice search API usage:**
Use the `/api/v3/search?query=...` endpoint. Results are returned
under the `.searches` key (NOT `.articles` or `.questions`). Each
result includes `.name`, `.url`, and `.categories.current.name`.

If a search returns zero results, verify the jq parsing is correct
before concluding there is no article — silent parse failures on
the wrong key look identical to genuine gaps.

##### Stage 1 — Is there an article? (Content gap)

Run **at least three** Helpjuice search queries using different
phrasings before concluding no article exists:

1. **Acronym / short form** — e.g., `SSO`, `NPS`, `SDK`
2. **Full phrase** — e.g., `single sign-on`, `net promoter score`
3. **Troubleshoot variant** — e.g., `troubleshoot SSO`,
   `troubleshoot flows`, `troubleshoot email`

Check ALL results from each search, not just the top 1-2.

Appcues has troubleshooting and setup articles for most established
experience types (Flows, Pins, Checklists, Banners, Launchpads, NPS,
Embeds) and account features (SSO, SAML, billing, roles) — assume one
exists for established features and prove otherwise before calling a
content gap.

**New-launch caveat:** Do NOT assume an article exists for recently
shipped functionality. Net-new features are the most likely place for
a genuine content gap — when a theme involves a feature that looks
new or renamed (cross-check recent Helpjuice publish dates or the
release-docs-generator output if unsure), treat "no article found" as
a likely real gap rather than a search miss.

**Branch:**
- **An article exists** → go to **Stage 2**.
- **No article exists** → run the **thesis sentence gate** below. If
  the thesis is writeable, this is a **Content Gap** (action: write a
  new article). If not, it's **Not a gap** (route to Step 5c).

**Thesis sentence gate (required before flagging a Content Gap):**
A frequent topic is not automatically a doc gap. Read the actual case
threads for the theme — specifically the support agent's resolution
reply — and try to write the one-sentence thesis the article would
say. Base it on the resolution, not the subject. The agent's closing
reply usually IS the thesis (or proves there isn't one).

Fetch the resolution (the inbound `Description` only shows the
customer's framing, not the agent's answer):
```
scripts/salesforce-api.sh case-thread --number <NUM>
```
`Incoming=false` rows are the agent's replies; the latest carry the
resolution.

Outcomes:
- **Thesis writeable** (e.g., "To target a flow by URL, use the
  pattern field, not the exact match field") → real **Content Gap**.
- **Resolution is "you can't" / "that's not recoverable" / "that's a
  product limitation"** → NOT a doc gap. Surface as a **Product
  Friction Signal** in Step 5c if the pattern is destructive or
  repeated.
- **Resolution is a workaround for a live defect** → NOT a doc gap.
  The help center describes how the product is meant to work. Writing
  up a workaround presents a bug as expected practice and commits
  Appcues to supporting it. Route it to **Step 5c Product Friction**
  with an **Engineering** owner, and say explicitly in the report why
  it is not being filed as a doc gap.
  - Test: *if the bug were fixed tomorrow, would this article need to
    be deleted?* If yes, it's a workaround — don't write it.
  - Distinguish from **intended-but-unintuitive behaviour**, which IS
    a doc gap: a supported configuration step, a documented product
    limitation the customer must design around, or a correct-but-
    surprising default. "Use a stable CSS selector instead of a
    positional one" is guidance and belongs in docs. "Rebuild your
    Theme from scratch to clear the corrupted state" is a workaround
    and does not.
  - When a cluster is genuinely the period's biggest signal but produces
    no writeable thesis, don't pad the Doc Gaps table to reach three
    rows. Report fewer rows and add a short "why this is not a doc
    gap" note beneath the table.

  > Example (2026-07-27 report): the Flows 2.0 / Embeds
  > builder-vs-live rendering mismatch was the top product signal and
  > carried all three escalations, but support's only remedy was
  > "recreate the Theme and reapply it" — a workaround for a defect,
  > and one customers can't even run since Flows 2.0 Themes have no
  > self-serve delete. Filed as Product Friction (Engineering), not a
  > doc gap. Only the adjacent *intended* behaviour was doc-worthy
  > (Auto font inheritance renders a placeholder font in the Studio
  > builder) and that scored Low, not High.

If you cannot read the threads (Description empty, no agent replies in
the fetched data), do not flag a content gap — mark it `Unverified`
and skip it from the main Doc Gaps section. Better to omit than to
manufacture a gap from a subject line.

##### Stage 2 — Is the coverage working? (Quality + Discoverability)

Only when a matching article exists. Run both checks; a theme can hit
either, both, or neither. If both, report the higher-priority one.

**Quality check (read the article):**
Fetch the article via `/api/v3/articles/{id}` and read its
`.article.answer.body`. Compare it against the specific failure modes
in the case threads — not the title.
- Article answers the specific question customers asked → quality OK.
- Article exists but **misses the specific failure mode, is outdated,
  or buries the answer** in an FAQ or unrelated article → **Quality
  Gap**. Action is *revise*: name the article and the section/thesis
  to add. (Example: segment live re-evaluation IS documented, but
  scattered across three articles' FAQs — quality gap, not content.)

**Discoverability check (cross-reference Helpjuice analytics):**
Only meaningful when ticket volume is notable (2+ cases, or any
escalation). Pull analytics for the report's date range (queries
below) and compare:
- The matching article's `views` / `readings` (`analytics/questions`).
- Search interest for the theme's terms (`analytics/keywords`):
  `searches` volume and `found_answers`.

Flag a **Discoverability Gap** when the article is correct (passed the
quality check) AND there's a findability signal:
- High ticket volume but the matching article has **low views/readings**
  relative to the topic's search interest, OR
- A keyword with **high `searches` but low `found_answers`**.

Action is *resurface*: fix the title/synonyms for customer language,
surface the article in-product (error states, builder), and cross-link
from related high-traffic articles. (Example: Chrome Extension /
builder access — many tickets despite a dedicated troubleshooting
article = customers aren't finding it.)

If the article exists, answers the question, and there's no
volume/analytics signal → **Covered & working**. Do not report it.

**Helpjuice analytics queries** (defer to the `helpjuice-analytics`
skill for detail; these two are what you need here):
```bash
# Article views/readings for the period
curl -s "https://appcues.helpjuice.com/api/v3/analytics/questions?since=START&upto=END&limit=100" \
  -H "Authorization: $HELPJUICE_API_KEY" \
  | jq '[.questions[] | {name, views, readings, dislikes, avg_seconds_spent}]'

# Search keywords + whether searchers found an answer
curl -s "https://appcues.helpjuice.com/api/v3/analytics/keywords?since=START&upto=END&limit=100" \
  -H "Authorization: $HELPJUICE_API_KEY" \
  | jq '[.keywords[] | {name, searches, found_answers}]'
```
Caveats: keyword `searches` counts run higher than raw events (use for
relative ranking, not absolute numbers); these endpoints occasionally
return 403 — retry. If analytics are unavailable, fall back to ticket
volume alone (high volume + a correct article = likely discoverability
gap) and note in the row that the analytics signal was unavailable.

**Coverage outcomes:**

| Coverage | Definition | Action |
|---|---|---|
| Content Gap | No article addresses the theme AND thesis is writeable from resolutions | **Write** a new article |
| Quality Gap | Article exists but misses the specific failure mode, is outdated, or buries the answer | **Revise** the named article |
| Discoverability Gap | Article exists and is correct, but notable volume + low views/`found_answers` signal | **Resurface** (title/synonyms, in-product, cross-link) |
| Covered & working | Article exists, answers the question, no volume/analytics signal | None — do not report |
| Not a gap | Recurring topic but resolution is "can't" / product limitation | Route to Step 5c |

#### Priority scoring
Score each gap — Content, Quality, or Discoverability — using three
factors:

1. **Case frequency**: 3+ = high, 2 = moderate, 1 = low
2. **Escalation signal**: Any escalated case in theme → boost one level
3. **Cross-period recurrence** (from trend history): Theme appeared as
   the **same gap type** in a prior report → boost one level

Final priority:
- **High**: 3+ cases, OR any frequency + escalation, OR any frequency
  + recurrence
- **Medium**: 2 cases, OR 1 case + escalation or recurrence
- **Low**: 1 case, no escalation, no recurrence

For Discoverability gaps, a strong analytics signal (very low views
against high search interest) can substitute for frequency — a single
recurring theme with a strong signal can be High.

For the report, only the **top 3 high-priority gaps** appear in the
main body, regardless of type. Medium and low go to the appendix.

---

### Step 6b: Feedback signals (V1 — log only)

Collect what customers want and what they are doing the hard way, so
the accounts can later be targeted in-app. This is a tracking log, not
a theme. The unit is one case with one ask, not a cluster.

Source the signals from the case threads you already read in Steps 5b,
5c and 6. Don't pull extra threads only for this step. A case
description alone can be logged, but set `verified_in_thread: false`.

Log a case when the customer's own words show either:

| Bucket | When | Example |
|---|---|---|
| `feature_gap` | They want something the product doesn't do, or support had to do it for them by hand | Hotspots in the new builder; rotating a SAML certificate without a ticket; bulk archive |
| `solvable_now` | Their pain is already solved by a shipped feature they didn't know about or couldn't find | Finding low-performing live flows (Appcues AI); recurring performance reporting (dashboards) |

The ask must be in the customer's own words. Don't infer one from
what a ticket implies ("they'd probably want a warning", "they had to
email support, so they'd want self-serve").

Do not log:
- Defects. A bug or a support-confirmed product issue goes to Step 5c and Engineering.
- Expected behaviour of an outdated setup, such as new features not working on an old SDK. Upgrading is the answer, not a product change.
- How-to questions the agent answered with existing configuration, unless the customer also asked for an easier way.
- Pure sentiment with no ask. Put that in the Churn Watchlist or Executive Summary.

Append each signal to `data/feedback-signals.json` (gitignored; it holds
account names). Skip a case number already in the file. Fields:

```json
{
  "case_number": "<case-number>",
  "account": "<Account>",
  "sf_account_id": "<sf-account-id>",
  "appcues_account_id": "<appcues-account-id>",
  "requester_role": "builder user",
  "surface": "appcues_app",
  "bucket": "feature_gap",
  "product_area": "Flows 2.0",
  "signal": "One sentence in plain words: what they want or what hurts.",
  "quote": "Short customer quote, under 15 words, or null",
  "answer": "What support told them or did, one line",
  "verified_in_thread": true,
  "notes": null,
  "period": "YYYY-MM-DD to YYYY-MM-DD",
  "date_logged": "YYYY-MM-DD",
  "status": "open",
  "csm": "<CSM Name>",
  "shipped_feature": null,
  "canny": null,
  "notion_page_id": null
}
```

- `csm` comes from `Account.Customer_Success_Manager_Name__c`. Null for `Customer Success`, `CRM Bot`, or no account.
- `shipped_feature` is set only for `solvable_now`: the feature that answers the ask (e.g. "Appcues AI", "Dashboards").
- `requester_role` is a role, never a person's name.
- `product_area` uses the Canny group names (Flows 2.0, Builder & Design, Experiences, Targeting & Delivery, Analytics & Insights, Account & Admin, Integrations & API, Install & Platform, Appcues AI, Mobile, and so on) so the log can feed Canny later without remapping.
- `appcues_account_id` only when a case, thread or Canny company record states it. Otherwise null. Never guess.
- `canny` stays null. **Do not write to Canny from this skill.** Whether the log feeds Canny is undecided (2026-10-08).

Then push the new rows to the **Feedback Signals** Notion database (under
Case Analysis Stats). This is where the signals are read and worked; the
JSON file is the local store.

```bash
source "$APPCUES_HOME/.env"
scripts/feedback-signals-to-notion.py --dry-run   # check what will be pushed
scripts/feedback-signals-to-notion.py
```

The script pushes only rows without a `notion_page_id` and writes the ID
back, so re-running never duplicates. The database ID is read from
`data/notion-feedback-db.json`. Status changes (Contacted, Shipped,
Targeted, Won't do) are made by people in Notion, not by this skill, so
never overwrite a row's Status from the JSON.

---

### Step 7: Generate the report

Produce a structured Markdown report with these sections.
The report should tell a story — what happened, what's getting
worse, who's struggling, and what to do about it.

#### 1. Executive Summary
5-8 bullets that tell the full story. A VP should be able to read
only this section and know what's going on.

Include:
- Total cases analyzed + direction vs. prior period (one line)
- Escalation rate + direction (one line)
- **Appcues App vs. Studio split** — one line: `N Appcues App cases,
  M Studio, U unclear (X% Appcues App)`. Use the Step 4b tags. Skip
  the line only if the tagged counts are all zero.
- Top 2-3 findings (what's notable this period)
- Any cross-period trend worth flagging
- The single most important action to take

Reference the total number of true support cases analyzed — do not
mention spam counts, sales ops removals, or filtering details.

#### 2. Key Metrics
Compact period-over-period comparison table (each period = 14 days):

| Metric | This Period | Prior Period | Change | Direction |
|--------|-----------|-----------|--------|-----------|
| Total cases | 84 | 81 | +3.7% | ➡️ Stable |
| Escalated cases (opened in-period) | 9 (10.7%) | 10 (12.3%) | -1.6pp | ⬇️ Good |
| Escalations actioned in-period | 14 | 17 | -17.6% | ⬇️ Good |
| Median time-to-escalation | 3.5h | 9.8h | -64% | ⬇️ Good |
| Median resolution time | 14.6h | 16.2h | -9.9% | ⬇️ Good |

Include: total cases, escalated cases opened in-period (count + rate),
escalations actioned in-period, median
time-to-escalation, median resolution time (closed cases only),
and 1-2 theme-specific metrics that are notable this period (e.g.,
"Flow-related cases" or "Publishing bug"). Keep to 4-6 rows max.

For median resolution time, add a note beneath the table:
`*Closed cases only (N=58 this period, N=62 prior period).*` Arrow convention
for resolution time: ⬇️ = faster = good, ⬆️ = slower = regression.

If no prior period is available (first report), show current values
only and note "first baseline."

#### 3. Top 5 Issue Themes
Table format:

| Theme | Cases | Trend | Notes |
|-------|-------|-------|-------|
| Flow targeting on mobile | 9 | ⬆️ 3rd report running | 2 escalated |
| Checklist completion events | 6 | 🆕 | |
| ... | ... | ... | ... |

- Capped at 5 themes. Remaining themes listed in appendix.
- Trend column uses: ⬆️ growing, ➡️ stable, ⬇️ declining, 🆕 new
- Notes column: escalation counts, brief context. Keep terse.
- When referencing specific notable cases, include the case number
  inline — e.g., "Builder blocking toolbar (00156194)"

#### 4. Churn Risk Watchlist
The flagged accounts from Step 5b, as one table.

**Scoring method disclaimer** (italic, directly under the heading):
"*Scoring method: Cases are weighted by type (Troubleshooting/Bug =
2pts, others = 1pt), with bonuses for escalations (+3pts each) and
theme concentration (+2pts when >50% of cases hit the same feature).
Accounts need 2+ cases in the two-week period and a score of 5+ to
appear.*"

| Account | CSM | Cases | Score | Type Mix | Concentration | Signal |
|---------|-----|-------|-------|----------|---------------|--------|
| **<Account>** | <CSM Name> | 2 | 6 | 100% Troubleshooting | Email (concentrated) | Two distinct email workflow failures ... |

- Account names **bold**.
- CSM column is plain text. No @-mentions.
- Signal column is prose — describe what the pattern suggests and
  what CS should do. Include case numbers inline. Note "**3rd report
  running**" (or similar) when the account was also flagged in a
  prior report within the lookback window.

If no account scores 5+, write "No accounts flagged this period."
instead of the table.

#### 5. Product Friction Signals
Top 3 signals suggesting product bugs, UX confusion, or missing
features. Each signal should include:
- What's broken / confusing (specific description)
- How many cases and which accounts
- Case numbers inline
- Why it matters (blocking deployment, regression, etc.)

Cap at 3. If fewer than 3 are notable, include fewer.

##### Appcues App callout (conditional)
When Appcues App tagged cases (Step 4b) are **≥3 cases OR ≥10% of the
period's volume**, add a short paragraph at the end of this section:
- Count and percentage.
- The surface(s) driving them (Appcues AI, Key Moments, dashboards,
  campaigns/briefs, Recommendations, tactics).
- Case numbers inline.
- One line on whether the reports are bugs, friction, or how-to —
  don't call anything a bug unless `Type = Bug` (Step 5c rule).

Skip the callout when the threshold isn't met. Do not renumber
sections around it — it's a subsection of Product Friction.

#### 6. Trends Across Periods
Conditional section — only included when there are patterns worth
flagging from the trend history. If nothing notable, omit entirely.

Surface as bullets:
- **Recurring themes** (3+ consecutive reports): "Flow targeting:
  4th report running, grew from 3 → 5 → 7 → 9 cases". When the run
  mixes weekly and biweekly reports, say so rather than implying the
  counts are comparable ("5 and 7 in the last two weekly reports, 14
  this period").
- **Persistent doc gaps**: "Mobile SDK deep linking flagged 6 weeks
  ago, still no article, 14 cumulative cases"
- **Escalation trajectory**: "Escalation rate: 11% → 14% → 17%
  over 3 reports"
- **Resolved patterns**: "Launchpad permissions dropped off after
  docs update on Mar 20" (positive signals worth noting)

Keep this brief — 3-5 bullets max. This is not a full history,
just the patterns that should inform action.

#### 7. Documentation Gaps
Render as a table. Each gap is typed — Content (write), Quality
(revise), or Discoverability (resurface) — per Step 6.

| Gap | Type | Priority | Thesis / Fix | Details |
|-----|------|----------|--------------|---------|
| **Troubleshoot email workflow issues** | Content | High | Email sends fail silently when the trigger event fires before the user is identified — verify identify() runs before track(). | No troubleshooting guide ... 3 cases this period (<Account A> x2, <Account B>). **Recurring gap — also flagged in the prior report.** |
| **Surface "Troubleshoot the Chrome Extension and Builder"** | Discoverability | High | Article is correct but buried — fix title/synonyms and link from builder error states. | 7 cases despite an existing article; article views low vs. search interest for "builder"/"extension". |

- Gap column: bolded. For Content gaps, the suggested article title.
  For Quality/Discoverability gaps, the existing article name plus the
  action (e.g. "Revise X", "Surface X").
- Type column: Content / Quality / Discoverability.
- Priority column: High / Medium / Low (main report shows only High).
- Thesis / Fix column: for Content/Quality, the one-sentence thesis the
  article should state (from the Step 6 thesis gate). For
  Discoverability, the one-line fix (what to change so customers find
  it). If you can't fill this column, the row should not be here.
- Details column: prose — case count, account names, inline case
  numbers, and the signal that drove the priority (escalation,
  recurrence, or the analytics signal for discoverability). Bold any
  "recurring gap" callout.

One italic summary line above the table for excluded cases:
"*X cases excluded from doc gap analysis (Billing, Bug, etc.).*"

If there are no High gaps of any type, state that plainly instead of
the table (e.g. "No high-priority documentation gaps this period.").

Cap at 3 rows. No medium or low priority gaps in the main report.

#### 8. Recommended Actions
Exactly 3, as a numbered list (not dashes). Each action is a full
paragraph with a bolded action phrase, the reason, and an owner.

Format:
```
1. **Action phrase** — why it matters (linked to theme or trend).
   **Owner: team.**

2. **Next action** — ...

3. **Third action** — ...
```

Prioritized. Specific. Actionable before the next report (two weeks). Assign an owner
(Engineering, Documentation, Customer Success, Support Ops).

#### 9. Appendix

**Full Theme List**
All themes ranked 6+ formatted as a numbered list that continues from
the top 5 (so the first entry is `6.`, next `7.`, etc.). Each line:
`6. Theme Name — N cases` (include escalation count if any, e.g.
`4. Account Access & Login — 4 cases (1 escalated: 00158697)`).

**Case Reference**
Table mapping each theme to its case numbers:

| Theme | Case Numbers |
|-------|-------------|
| Builder / Editor Issues | 00156194, 00156210 |
| Billing & Subscription | 00156120, 00156135, 00156198 |

Include ALL themes. Keep compact: theme name + comma-separated
case numbers. No descriptions or additional columns.

**Feedback Signals**
The signals logged this period in Step 6b, as two tables:
`feature_gap` first, then `solvable_now`. Columns: Account | Ask |
Product area | Case. For `solvable_now`, add a column naming the
shipped feature that answers it. Mark unverified rows "(from
description)". One italic line above the tables: "*N signals logged to
the feedback log (X feature gaps, Y solvable now).*" Never include
these in the Slack summary.

---

### Step 8: Update trend history

After generating the report, append an entry to
`data/trend-history.json`. Create the file if it doesn't exist.

The file is a JSON array. Each entry:

```json
{
  "date": "YYYY-MM-DD",
  "period": "YYYY-MM-DD to YYYY-MM-DD",
  "period_days": 14,
  "total_cases": 52,
  "true_customer_cases": 48,
  "escalation_rate": 0.17,
  "escalations_actioned_in_period": 14,
  "median_time_to_escalation_hours": 3.5,
  "median_resolution_hours": 14.6,
  "closed_cases_in_period": 45,
  "app_surface": {"appcues_app": 4, "studio": 42, "unclear": 2},
  "themes": [
    {"name": "Flow targeting on mobile", "count": 9, "escalated": 2},
    {"name": "Checklist completion events", "count": 6, "escalated": 0}
  ],
  "doc_gaps_high": [
    {"name": "Mobile SDK deep linking", "type": "content"}
  ],
  "top_action": "Update mobile targeting docs",
  "accounts": [
    {
      "name": "<Account>",
      "cases": 2,
      "risk_score": 6,
      "escalated": 0,
      "type_mix": "Troubleshooting",
      "themes": ["Email"],
      "signal": "friction"
    }
  ]
}
```

Rules:
- Include ALL themes (not just top 5) so future lookback is complete
- `themes` array is ordered by count descending
- `escalation_rate` is a decimal (0.17 = 17%), computed from cases
  **opened** in the period (measure 1 in Step 3)
- `escalations_actioned_in_period` is measure 2 — every case whose
  `Sent_to_SE_Queue__c` falls in the period, whatever its open date
- `median_resolution_hours` is the median of `(ClosedDate − CreatedDate)`
  in hours across cases closed during the period (see Step 3). Omit or
  set to null if no cases closed in the period.
- `closed_cases_in_period` is the denominator N for the resolution median
- `app_surface` is the Step 4b tag distribution across the filtered
  dataset — counts must sum to `true_customer_cases`. Enables tracking
  Appcues App volume as the rollout progresses.
- `doc_gaps_high` lists only high-priority gaps, each as
  `{"name": ..., "type": "content"|"quality"|"discoverability"}`. The
  `type` lets the Step 6 recurrence boost match same-type gaps across
  reports. Legacy entries that are bare strings should be treated as
  `type: "content"` when reading.
- `top_action` is the #1 recommended action (one line)
- `accounts` captures every flagged account from the
  Churn Risk Watchlist (Step 5b). Fields:
  - `risk_score` — integer, from the Step 5b scoring method
  - `escalated` — count of escalated cases for this account this period
  - `type_mix` — short string summarizing case Types (e.g.
    `"Troubleshooting"`, `"Bug/How To"`)
  - `themes` — array of theme/feature names the cases clustered into
  - `signal` — one of `friction`, `adoption`, `mixed`, `low`
- `period_days` is `14` for biweekly reports. Entries without it are
  legacy weekly reports (7 days).
- If the file has older entries, leave them — they won't be read but
  don't need pruning.
- When reading trend history (Step 2), only look back 12 weeks by
  `date` (6 biweekly reports, plus any weekly entries in that range).

---

### Step 9: Post report to Notion
After saving the Markdown report, post it to the Case Analysis Stats
database under Customer Experience > Support in Notion.

Database ID: 30c47b00773c81c8ba43e7382936cd3f

Publish:
```
scripts/notion-api.sh post \
  --title "Support Trend Report [YYYY-MM-DD]" \
  --file reports/ticket-trend-report-[YYYY-MM-DD].md \
  --date [YYYY-MM-DD]
```

#### Handling the 100-block limit
See CLAUDE.md "Notion API Notes" for overflow handling.

Confirm the Notion page was created and share the page URL with the
user.

---

### Step 10: Post to #customerfacingpeeps (optional — on request only)
Only post to Slack if the user explicitly asks for it. Do not post
automatically after posting to Notion.

**Channel:** `#customerfacingpeeps`, channel ID `C0BQY8HRATS`.
The old `#cx-team` channel was archived in August 2026, and
`scripts/slack-api.sh` still points a webhook at it — do not use that
script for this report. Post with the Slack MCP instead, which takes
the channel as a parameter.

Draft the message in chat, get approval, then send:

```
slack_send_message
  channel_id: C0BQY8HRATS
  message: |
    **Support Trend Report — [YYYY-MM-DD]**

    [2-3 sentence summary, written per the rules below]

    [View the full report in Notion]([url returned from notion-api.sh])
```

The message is standard markdown, not Block Kit or Slack mrkdwn — use
`**bold**` for the title and `[text](url)` for the link, with a blank
line between title, summary and link. Keep the whole thing under a
screenful.

If the user would rather review it in Slack than in chat, use
`slack_send_message_draft` with the same channel and message, and let
them send it themselves.

#### Writing the summary — tell the story, don't restate the metrics

The Slack message carries a link to the full report. Anyone who wants
counts, rates and period-over-period arrows will click through and read
them. So the summary's job is the one thing the numbers *can't* do:
say **what customers were actually struggling with these two weeks**.

Write **2-3 sentences, narrative, in plain language.** Answer:
- What drove the most tickets — described as the customer's
  experience, not as a theme label?
- What drove the most *frustration* — where did customers get stuck,
  repeat themselves, or escalate?
- If there's a single connecting thread across the period's escalations
  or top themes, lead with it.

Rules:
- **Lead with the complaint, not the category.** "Customers don't
  trust what they see in the builder" lands; "builder fidelity is the
  dominant theme" does not.
- **Use concrete symptoms** customers would recognise — "spacing
  collapses, backgrounds go transparent, alignment snaps back" beats
  "rendering inconsistencies."
- **Name the product surface precisely** (Flows 2.0, Embeds, the Open
  Builder, mobile SDK) so readers know whose area it is.
- **At most one or two numbers,** and only when they carry the story
  ("third report running", "all three escalations"). No volume totals,
  escalation rates, resolution times, or doc-gap counts — those are in
  the report.
- **No case numbers and no customer or account names.**
  `#customerfacingpeeps` is a public channel; the Notion page is
  access-controlled.
- Keep it short enough to read without expanding the message. If it
  needs a "show more", it's too long.

#### Tone — plain and factual

Write it the way you'd summarize the last two weeks to a colleague who asked
"what were people struggling with?" Observational, not rhetorical. The
facts are strong enough on their own; the summary's credibility comes
from being obviously neutral. `#customerfacingpeeps` is sales, CXM and
support plus whoever else wanders in, so a reader may be about to take
this into a renewal call — and Engineering or Product may be implicitly
on the hook for it.

**Do:**
- State what happened and what customers experienced. Describe the
  behaviour, let the reader draw the conclusion.
- Use the customer's own concrete symptoms ("spacing collapses,
  backgrounds turn transparent, alignment jumps back to the left").
- Use plain connectives — "Most of the friction these two weeks was…",
  "That covered every escalation on…", "Separately, …".
- Name the surface plainly (Flows 2.0, Embeds, the new builder).

**Don't:**
- Open with a verdict or slogan ("Customers can't trust the builder",
  "The builder is broken"). It reads as advocacy and invites the
  thread to argue with the framing instead of the problem.
- Assign blame, name an owning team, or imply negligence. Ownership
  belongs in the report's Recommended Actions, not the Slack blurb.
- Use urgency words (critical, alarming, unacceptable) or hype
  (huge, massive, exploding).
- Editorialize about severity — "we have no fix" is a judgement;
  "the workaround is manual" is a fact. Prefer the fact, or leave it
  to the report.
- Quote customers verbatim in the Slack summary. It lands harder but
  puts customer words in a channel far wider than the access-
  controlled Notion page. Paraphrase the symptom instead.

> Example (2026-07-27): "Most of this week's friction was in the new
> builder. Customers set up a Flows 2.0 experience or an Embed, it
> looks right on screen, then renders differently once published —
> spacing collapses, backgrounds turn transparent, alignment jumps
> back to the left. That covered every escalation on a case opened
> this week. Tooltip placement was the biggest theme for the fourth
> week running, mostly in apps that scroll inside their own panes
> rather than the page itself."

If the period's story genuinely needs more force than this tone allows,
say so to the user and let them decide — don't escalate the tone
unilaterally.

Draft the summary and show it to the user for approval before sending —
never send unreviewed.

---

## Output

Default: Markdown file named ticket-trend-report-[YYYY-MM-DD].md

On request, also produce:
- Condensed version for pasting into Notion
- Plain text executive summary for Slack or email

---

## Things to Watch For

- If case volume is below 40 for the period, flag that patterns may
  not be statistically meaningful
