AI support agent grounded in real order data

Client system Published Sep 24, 2026 Reviewed Nov 21, 2026

A Zendesk-connected LLM agent that drafts replies and typed account actions from each customer's actual purchase history, controlled by per-brand autonomy, code-enforced rules and a reviewed evaluation catalog.

At a glance

Problem
A consumer subscription business operating several brands handled high volumes of multilingual support tickets manually: cancellations, billing questions and login issues, every one tied to what the customer actually bought.
Constraint
Replies and actions touch live subscriptions and real money. The agent could never guess customer identity, act on stale purchase snapshots, or run unmeasured prompt edits.
System built
An LLM agent wired into a Postgres mirror of Zendesk tickets and BigQuery order exports, proposing replies and typed actions checked in deterministic code and governed by per-brand autonomy.
Outcome
Operators review and approve exact drafts instead of writing from scratch, autonomy expands brand by brand, and prompt releases are gated against a reviewed ticket catalog.

Overview

The business runs several consumer subscription products under separate brands, serving customers across many countries and languages. Most incoming tickets repeat a small set of intents: cancel my subscription, explain this charge, restore my access. Answering correctly depends on facts customers rarely state accurately: which brand they bought, which plan is active, when it renews, and whether it was already canceled.

A polished answer built on wrong facts hurts more than a slow reply. The system had to ground every draft and action in verified commerce records, allow autonomy to be tuned per brand, and prove every prompt change against real tickets before customers saw it.

Identity is a ladder of evidence

Zendesk tickets mirror into Postgres, where each requester is matched against commerce records exported from BigQuery. Resolution climbs a fixed ladder: help-desk user ID, email address, a quoted account code, an external purchase reference, and finally order or subscription IDs found inside the message.

One customer often owns multiple accounts, so an email may resolve up to 5 records, or up to 50 when anchored to the requester's own help-desk ID. Any larger set becomes a candidate pool that a later rung must narrow to a single match. Brand never acts as identity proof: filtering by brand to force uniqueness would hide the same person's purchases under sister brands.

Customers frequently mention a second email or an order number mid-thread. Each quoted identifier is probed on its own: a unique hit links automatically with its evidence recorded, while an ambiguous probe adds nothing. An early design held newly linked requesters for manual review; that queue created drag without catching errors, so the hold was removed and queued requesters reopened.

Changing any matching rule requires passing a fixed backtest bar: 600 labeled hits with zero disagreement, or 1,500 with at most one, plus 200 adversarial cases with zero errors.

Data freshness is modeled explicitly. Every commerce snapshot carries a "covered through" timestamp, so missing or lagging coverage never proves a purchase does not exist. Whenever purchase data is mid-refresh, the agent waits and rechecks before acting.

What thousands of unmatched tickets revealed

The weakest early replies boiled down to "we could not find your account." Auditing several thousand unmatched production tickets explained why stricter matching rules would never solve them. Roughly two in five contained no purchase language at all, making an unmatched state right. Another one in five clearly claimed a purchase while giving no order number, alternate email or other reference. No matching rule can invent missing data; the agent had to ask.

When identity stays unresolved and the message describes a purchase, the drafted reply now asks for one concrete detail: the purchase email or an order or invoice number. Once the customer replies, enrichment runs again with the new candidate and re-tries the ladder.

For about a week, a code check rejected any reply that reported a missing account without asking. That check came out alongside every other rule inspecting raw customer prose (below). The ask now lives in the versioned prompt and is graded directly by reviewed catalog cases covering first asks, follow-ups and replies that must never deny an account exists.

The model proposes, code checks the structure

The model never talks directly to customers or billing APIs. It emits a proposal containing typed actions and the target ticket status.

type ProposalAction =
  | { type: "send_reply"; body: string; language: string }
  | {
      type: "cancel_subscriptions";
      clientId: string; // an account linked to this ticket
      subscriptionIds: string[]; // from that account's facts
      scope: "cancel_specific" | "cancel_all_identified";
      evidence: string[]; // the facts the model relied on
    }
  | { type: "apply_tags"; tags: string[] }
  | { type: "internal_note"; body: string }
  | { type: "escalate_human"; reasonTag: string; note?: string };

Simplified from the real schema

Each ticket gets a freshly generated output schema built from its own facts. Tags, intents and escalation reasons are constrained to catalog enums, and cancellation targets are restricted to the exact subscription IDs the facts permit. When nothing is cancellable, the cancellation action disappears from the schema entirely. Generation runs at temperature 0.

After generation, a deterministic gate validates the proposal against structured facts. Any cancellation must reference an account linked to the ticket, a subscription belonging to that account, and a single brand. URLs must come from the brand's knowledge base or stored fields. Quoted currencies must match the customer's billing currency. Unfilled template placeholders are blocked, and only permitted tags pass. An English reply cannot claim a cancellation succeeded unless the proposal cancels it or the facts already show it canceled.

A rejected proposal loops back to the model with the exact violations up to twice. If it still fails, the system swaps it for a human escalation.

Removing brittle rules from customer text

Early builds also ran code checks over the customer's own words: regex nets for cancellation intent, scope and language. On one evaluation catalog, 8 of 13 persistent failures came from those rules disagreeing with the reviewed ground truth and steering the model away during revision.

The fix became a design contract: no deterministic check may inspect raw comment text. Sixty-nine regexes were deleted from the facts module. A second cleanup removed checks that re-derived decisions the model had already made, because every false positive turns a good draft into a needless escalation. Intent judgment belongs in evaluations where accuracy can be measured.

Autonomy and execution

Every brand runs at one of three modes: off, draft for review, or draft and act. In review mode, operators inspect the exact reply, actions, cancellation targets and resulting ticket status before approving. Replies go out in the customer's language while operators read an English translation beside them. A global kill switch pauses execution without stopping drafting, and a suppression flag holds automatic replies until the customer writes again.

Before executing anything, the worker re-verifies that the requester has not changed, no newer customer message has arrived, and the ticket is still open. Each action claims a row by dedupe key with a 30-second lease, so retried requests return the recorded outcome instead of double-replying or canceling twice. When only the final status update fails, operators retry that step alone while leaving completed replies and cancellations untouched.

Evaluations decide what ships

Prompts are stored as immutable versions. Each brand can pin a specific version, track the latest version of a named prompt, or route based on the customer's products.

The evaluation set is a reviewed catalog of real pseudonymized tickets captured with their full conversation, identity links and commerce state. Expected outcomes belong to the catalog and persist across prompt versions; only an independent LLM judge sees them. Tickets with missing or stale facts remain marked unverified and spend zero model calls.

const passRate = passed / (passed + failed); // quality of what was judged
const coverage = (passed + failed) / selected; // how much was judged at all

An unverified case is not a pass

Every evaluation run snapshots its entire input bundle (prompt, knowledge revisions, models, judge configuration and answer key) so later edits cannot rewrite history. Promotion requires two complete passing runs with identical inputs, the same backend build and pinned model providers. Administrators can still force-assign a prompt without that evidence, but the UI flags the missing evidence as warnings rather than a pass.

Operator corrections feed the catalog directly: an edited draft can be sent to a golden review queue and folded into the next catalog version.

Limitations

  • The business metric is customer ticket resolution; evaluation pass rates grade drafts, and a clean draft can still leave a customer needing another reply.
  • Code gates catch bad targets, links and currencies; tone and nuanced judgment still depend on the prompt, the judge, the catalog and human review.
  • Moving the missing-identifier ask from code into the prompt means a prompt regression can drop it, relying on the catalog to catch it.
  • An LLM judge needs calibration against human-reviewed cases; hermetic unit tests verify plumbing, not judgment quality.
  • Unattended execution depends on upstream freshness; whenever purchase exports lag, automated actions wait.

Related case studies

Bring one real problem

One hour, €80. You leave with a written plan for what belongs in AI, what belongs in code, and what a first release takes, whether we work together or not.