AI Reply Drafting for eSIM Customer Support
Decision Trees in Code, the LLM Only Writes
My Role
- Decision tree in code; the LLM only writes
- Graph paths switchable to auto-send later
- Billing and unknown queries always go to humans
Approach at a Glance
Details- 1Single API Call with the Full Context
- 2Decision Tree as a LangGraph Workflow
- 3Escalation Rules
- 4Retrieval over Help Articles
- 5The LLM Only Writes
- 6Guardrails
- 7Feedback Capture and a Path to Automation
Executive Summary
An AI middleware that drafts replies for the support team of an eSIM travel-connectivity provider. For every ticket, an agent used to read the conversation, look up the customer's account and eSIM status, walk through the right troubleshooting steps and write the reply. The middleware takes over the research and the writing. The agent reviews the draft, adjusts it if needed, and sends it.
The core design decision was to not build it as one big RAG prompt. The provider's troubleshooting workflows are strict decision trees: the right answer depends on the eSIM status, the device, whether the customer is abroad, and a few other fields. Those are if/else checks, not judgement calls. So I split the system in two:
- The decision tree runs as code in a LangGraph workflow, which routes every ticket to the exact troubleshooting path.
- The LLM only writes: Claude turns the chosen path, the relevant help articles and the customer's situation into a reply in the company's tone.
The middleware runs in production and handles about 1,000 support queries a day. I was the architect and tech lead, working with one ML engineer and a PM, from the start in June 2026 until my engagement ended in August.
Client Profile
The client sells eSIMs for travellers: data plans that customers install on their phones before or during a trip. Its support questions are repetitive but precise. An eSIM won't activate, the phone doesn't connect abroad, or a QR code is no longer valid. The right answer depends on details:
- the eSIM status: active, inactive, awaiting activation or deleted, each with a different fix;
- the device: Android phones need APN settings, while on iPhones the agent verifies the settings from screenshots;
- whether the customer is already abroad, and whether their eSIM supports multiple networks.
Agents had to collect these details and follow the right branch of the troubleshooting workflow for each ticket, in English or Spanish. As volume grew, this didn't scale without hiring in proportion.
The constraint that shaped the design: a wrong troubleshooting step sends a traveller in the wrong direction, possibly without connectivity. The system had to follow the workflows exactly, not approximately.
Technical Approach
-
Single API Call with the Full Context – The client's systems stay as they are. When a ticket needs a reply, the helpdesk sends one request with everything: the conversation history, account details, eSIM status, and plan and data usage. The middleware validates the payload and checks it for prompt injection before anything reaches a model.
-
Decision Tree as a LangGraph Workflow – Putting every branch of the workflows into one prompt and hoping the model follows each condition every time would be fragile and impossible to test. Instead, the routing runs as code, in a graph of nodes:
- Query type router: activation problem, connectivity issue, invalid QR code, general question, billing or account.
- eSIM status router: active, inactive, awaiting activation or deleted. A deleted eSIM may need a replacement, while an inactive one needs to be switched on.
- Context enrichment: abroad or not, Android or Apple, single or multiple networks, settings correct or not. These are read from the payload, not guessed by a model.
- Troubleshooting path resolver: combines all of the above and selects the exact workflow to follow.
Each path can be tested on its own, like any other code.
-
Escalation Rules – Some tickets should never get an AI draft. Billing and account questions always go to a human, as do monthly-plan customers whose question isn't about a travel eSIM, and any query the router doesn't recognise.
-
Retrieval over Help Articles – The company's help centre and troubleshooting documents are split into segments, embedded and indexed in Qdrant with metadata such as title, category and language. Once the path is resolved, the middleware searches for the articles relevant to that path and this customer's situation, and keeps only results above a relevance threshold. A reindexing endpoint supports full rebuilds and incremental updates when articles change.
-
The LLM Only Writes – By the time Claude is called, the graph has chosen the path, the escalation check is done and the articles are retrieved. The model has one narrow job: write a reply that applies those steps to this customer, in the company's tone. The tone comes from gold-standard replies the company provided, used as guidelines and few-shot examples. For Spanish conversations, the same call writes the reply in neutral Latin American Spanish, plus an English translation for staff who don't speak Spanish. The output is structured: the draft, a confidence score, the language, escalation flags and the translation.
-
Guardrails – Before a draft reaches an agent, an output filter checks it for off-topic content, toxicity and answers outside the support domain. Drafts below a confidence threshold are flagged for closer review. Rate limiting protects the input side.
-
Feedback Capture and a Path to Automation – Every request and response is logged in PostgreSQL. When agents accept, edit or reject a draft, that feedback is recorded per scenario. This builds the evidence to tune prompts and, more importantly, the architecture is designed so that individual paths of the graph can later switch from "draft for review" to "send automatically" once their acceptance rate justifies it, without reworking the system.
Business Outcome
The support team stopped spending its time on research and writing. Each ticket arrives with a draft that follows the correct troubleshooting path for that customer's eSIM, device and location, grounded in the company's own help articles and written in its tone, in English or Spanish. Agents stay in control of every message. The middleware runs in production at about 1,000 queries a day.
The design keeps what must be exact in code and uses the LLM where language matters. That makes the system testable path by path, keeps the LLM's job small and reliable, and gives a clear way to automate: one path at a time, when the feedback shows it's ready.
Technologies
Planning something similar?
Tell me about it on a short call. New projects can start within 2 weeks