Ranking support cases for a SaaS help desk through AI-assisted scoring
A support team with hundreds of open cases needed the right one at the top of every queue, every time, without anyone re-sorting by hand. We combined native SLA milestones, a scoring formula anyone can read, and two Prompt Builder pipelines into a single live priority score.
By the Shinden Consulting team
The problem
The client runs a support desk for a family of software products. Cases arrive by email and web form around the clock, from accounts of very different sizes, with severities from "the whole platform is down" to "could you rename this label".
The team already had Service Cloud. What they did not have was an answer to the question every agent asks at the start of a shift: which of these should I open first? Sorting by age punished big accounts with a new outage. Sorting by severity ignored the medium case from a customer who was one bad week away from churning. Sorting by SLA missed the customer whose last three emails were getting shorter and angrier.
Supervisors were compensating by hand, walking the queue each morning and nudging cases up and down. That works with forty cases. It does not work with four hundred, and it evaporates the day the supervisor is on holiday.
Every case should carry a single number that reflects how urgent it really is right now, the number should update itself as things change, and an agent should be able to see why a case has the score it has without asking anyone.
The shape of the solution
We resisted the urge to build one big AI brain that ranks the queue. A model that emits a number nobody can explain is a model nobody trusts, and trust is the whole point of a priority score. Instead the score is a plain formula field, and the interesting work is in the four layers that feed it.
Everything lands in a set of custom Lightning components: a "why this score" panel on the case record, and agent and supervisor dashboards that sort a whole book of work by the same number.
SLA clocks that raise a hand early
The SLA layer is deliberately boring. It runs on standard Entitlement Processes and Milestones, not custom code, starting the clock when a case is created and stopping it when the case closes. Four milestone types run on every case, each with a business-hours target that scales with the case's severity: a critical case needs a first response within the hour, a low severity one within a working day.
Two details made it work in practice:
- The communication clock pauses when the ball is in the customer's court. A small flow flips the case's "stopped" flag whenever the status moves into a waiting state such as a scheduled meeting or an on-hold agreement, and clears it when work resumes. Agents stopped being penalised for a customer who took a week to reply.
- Milestones complete themselves. The first outbound email closes the first-response milestone. Any outbound email closes the communication milestone. Resolving the case closes whatever is still open. Nobody has to remember to tick a box.
The part that matters for prioritization is the early-warning layer. Every milestone has a time trigger sixty minutes before its target that sets a warning checkbox on the case, and a success action that clears it the moment the milestone completes on time. Four checkboxes, one per milestone type. They are the seam between the SLA engine and the score: the formula reads them and gives a temporary boost to any case that is quietly about to blow a deadline.
On an actual breach, the milestone's violation trigger looks up the case owner's manager and sends them a direct message in Slack. The nudge happens where people already are, not in a report someone has to remember to open.
A score anyone can read
Every case carries a 0 to 100 priority score and a derived P1 to P5 band. Both are declarative formula fields: no Apex, no scheduled recalculation, nothing that can drift out of date. The weighting came out of a few workshops with the support lead and was tuned twice after go-live.
- Severity is the classification the triage step assigns, mapped to a ladder from 100 for an outage down to 20 for a cosmetic request.
- Account value comes from a revenue snapshot and support tier on the account. A large, high-touch account scores 100; a small one on the standard tier scores 20.
- Customer risk blends the account's churn-risk band, a penalty for a recent low satisfaction score, and the case's own AI sentiment score, added straight in.
- Case pressure looks at how much the account has been through lately: two critical cases in the last ninety days scores 100, a quiet account scores 0.
Two business rules bypass the maths entirely. A case typed as an outage is always P1. The two lowest severities are always P5. These are policy, not model output, and they live in the formula where anyone can read them.
Humans win
A manual override picklist snaps the score to a fixed band and requires a written reason. A flow stamps who changed it and when, and clears the stamp when the override is removed, so every override is attributed. The override is not a workaround for a bad model; it is part of the design. Some things only a person on the phone with the customer knows.
A second formula field assembles a plain-English audit trail on every case: which rule fired, the weighted contribution of each component, labels like "Large account, high touch" or "Sentiment: clear frustration", and which SLA warnings are currently active.
This is what agents actually read. Nobody has to reverse-engineer the weighting, and when a supervisor disagrees with a rank they can point at the exact line they disagree with.
One small platform wrinkle: formula fields cannot carry field history. A record-triggered flow copies the score into a plain number field whenever it changes, which is how the dashboards show a trend line for a value that is technically recalculated on every read.
Two AI pipelines feeding it
Both pipelines run on Prompt Builder templates invoked from Flow. No external calls, no custom HTTP integration, no keys to rotate. That decision alone saved a security review.
1. Triage and routing, on creation
The prompt encodes the team's real triage playbook: a severity ladder with keyword guidance for each product line, a routing decision tree with its named exceptions, and a spam scanner with an explicit allowlist of domains that can never be flagged. Grounding it against the org's live picklists, rather than values pasted into the prompt, means an admin can add a product area on Tuesday and the model knows about it on Tuesday.
The model is asked to show its working in prose and to append a machine-readable block in delimiters. The flow extracts that block with ordinary string functions and, before trusting a single field, re-checks the combination with Apex. Treating model output as a suggestion to be validated, not a command to be obeyed, is the habit we would carry to any similar build.
2. Sentiment, continuously
A second, much blunter template keeps the sentiment number current. It runs whenever the case is edited and whenever an inbound email arrives, so the number behind the score is never staler than the last thing the customer wrote. It reads the case description plus the last three inbound emails (trimmed down from seven after reply-chain quoting started bloating the prompt) and returns only one of three values: calm, concerned, or clearly frustrated.
The template is told, in so many words, to ignore case age, status, priority and SLA. Sentiment only. Everything else is already in the formula, and the fastest way to make a score unreadable is to let the model double-count what the maths already handles.
A richer sentiment prompt exists too, with a full rubric, escalation-pattern detection and account history. It produces a human-readable write-up for agents and for the Agentforce assistant to quote. It is deliberately not the one feeding the score: prose is for people, the three-value scale is for the formula.
Keeping the inputs honest
Several inputs to the score are rolling windows on the account: cases in the last thirty days, critical cases in the last ninety. Those cannot be formulas or native roll-ups, because a case silently ages out of a window overnight with no record changing. So they are plain number fields maintained by a small flow family that all funnels through one reusable subflow, so the counting logic lives in exactly one place.
- Creating, updating or deleting a case recalculates its account instantly.
- A nightly scheduled flow recalculates every account anyway. It exists for one reason: the calendar moves even when the data does not.
- The latest support satisfaction score is stamped on the account by each new survey response, with a one-time backfill to seed history.
Revenue and churn-risk arrive from the billing and customer-success platforms through an existing integration. Worth knowing for anyone reading the dashboard: a case's rank can move overnight with nobody touching it, because its account's pressure tier rolled over or a sync landed. That is the system working, and the audit trail says so.
Where it shows up
On the case record, a priority panel colours its border by band, draws a small gauge with the raw score, and shows the audit trail verbatim behind a "why" toggle. A separate banner appears only when sentiment hits the ceiling, a visual tripwire for the angriest cases independent of the band. The manual override lives right in the panel, writing straight back to the case with a live "override active" state.
Next to it, a milestones panel lists every open milestone with a countdown that ticks every second in the browser rather than re-querying the server. It carries its own small business-hours calendar in JavaScript so the countdown matches what the Apex controller would say, and agents can complete a milestone from the panel when the automation has no way of knowing it happened.
Above the record, agent and supervisor dashboards put the same score to work across a whole queue: my cases and queue cases sorted by priority, weekly met and missed milestone counts, a satisfaction trend, and for supervisors a drill-down across everyone reporting to them. Same three inputs, just aggregated.
What we would tell another team
- Make the score a formula. Put the AI in the inputs, not the output. When the number is a formula, it is explainable by construction, and the explanation can be a formula too.
- Use the native SLA engine, then bridge it. Entitlements and milestones already know business hours, pauses and breaches. Four warning checkboxes were all it took to make that knowledge available to the score.
- Keep the AI prompts narrow. One template classifies, one template reads mood. Neither is asked to rank. Narrow prompts are cheaper, more consistent and far easier to test.
- Validate everything a model returns against the org's real configuration before writing it to a record.
- Leave a door for humans. An attributed override with a required reason kept the team's trust through the first weeks, when the weighting was still being tuned.

