LangGraph blueprint · E-Commerce
Customer support agent that resolves refunds
A LangGraph agent answers order questions, applies the refund policy and hands big refunds to a person.
- Steps
- 7
- Subjective questions
- 32
- Objective questions
- 32
The problem and the outcome
Problem: Support queues spike after every sale, and customers wait hours for simple refund answers.
Outcome: Routine tickets resolved in minutes; people handle the exceptions.
Architecture
How it works, step by step
- A customer asks about a late order, a return or a refund in chat.
- A small, fast model classifies the intent and loads the customer's recent orders.
- A LangGraph agent plans the next step with the order history held in its state.
- It calls order and courier APIs as tools and retrieves the exact refund-policy clause.
- Refunds above a set amount pause with interrupt() until a human agent approves.
- The agent issues the refund or replacement and replies with tracking and dates.
- Every conversation is traced in LangSmith and logged to the CRM for quality review.
Tech stack
- LangGraph agent
- Small fast model for intent routing
- Order, courier and refund API tools
- Refund policy retrieval
- interrupt() for approvals
- LangSmith tracing
Key design decisions
- Route simple intents (where is my order?) with a cheap model and send only complex cases to the full agent.
- Encode the refund policy as rules in code, with retrieval only for explaining it, so limits are never 'negotiated' by the model.
- Refunds above a threshold pause for a human through interrupt().
Common mistakes
- Letting the model decide refund amounts on its own.
- Tools that accept an order ID without checking it belongs to the signed-in customer.
- No handoff to a human when the customer is angry or the case is unusual.
What to measure
- Automated resolution rate
- Refunds escalated vs. auto-approved
- Customer satisfaction (CSAT)
- Average handling time
Most-asked interview questions
Subjective questions 32
1How do you stop a support agent from issuing refunds it should not?Asked almost every time
Put the policy in code: the refund tool checks eligibility, amount limits and order ownership itself, whatever the model asks for. Anything above a threshold or outside policy goes through a human-approval step. Log every refund with its trace and review samples.
2Design the graph for a refund-resolving support agent.Asked almost every time
Classify intent with a small model, look up the order and customer with read-only tools, check the refund policy with deterministic code (eligibility, window, amount), propose a resolution, route amounts above the auto-approve limit to a human via interrupt(), execute the refund with an idempotent tool, confirm to the customer and log the case.
3How do you verify the customer owns the order?Asked almost every time
Use the authenticated session's customer ID, never an order number alone typed in chat; for unauthenticated channels require verification (email OTP or order email match) before revealing details or acting.
4How do you measure whether the agent is doing a good job?Asked almost every time
Resolution rate without human help, correct refund decisions against audited samples, customer satisfaction, escalation rate, time to resolution, refund amount accuracy, cost per conversation, and complaints or reopened tickets.
5How do you protect against prompt injection from customers?Very often asked
Treat customer text as data. Tools enforce permissions and ownership server-side, the agent cannot reveal system prompts or other customers' data because its tools cannot fetch them, and suspicious requests are escalated. Test with adversarial examples in the evaluation set.
6When should the bot hand over to a human?Very often asked
When confidence is low, the customer asks for a person, sentiment turns negative, the action needs approval, or the same issue has failed twice. The handoff should pass a summary and the trace, so the customer does not repeat themselves.
7How do you keep refund policy rules out of the prompt?Very often asked
Encode eligibility (return window, item condition, category exceptions, amount caps) in code or a rules engine called as a tool; the model explains the result but cannot override it.
8How do you make the refund tool safe?Very often asked
Make it idempotent with an order-specific key, enforce limits server-side, require approval context for large amounts, log every call with the conversation ID, and restrict it to the authenticated customer's orders.
9How does the agent hand over to a human well?Very often asked
Create a ticket with the conversation summary, verified customer and order details, what the agent tried and why it escalated, and tell the customer the expected response time.
10How do you handle angry or abusive customers?Very often asked
Detect sentiment, respond calmly and briefly, prioritise escalation to a human for strong frustration, avoid arguing about policy, and apply abuse rules for threats.
11How do you support order tracking and other non-refund requests?Very often asked
Add focused read-only tools (track shipment, change address before dispatch, cancel unshipped order) behind the same authentication, with their own policy checks and approvals where needed.
12How do you test the agent before launch?Very often asked
Build a dataset of realistic conversations covering eligible, ineligible, edge and adversarial refund requests, run them against the graph with mocked commerce APIs, and score decisions, tool calls and tone, then pilot in shadow mode.
13How do you prevent the agent from promising things it cannot do?Very often asked
List allowed actions in the system prompt, ground promises in tool results (for example, only say a refund is issued after the tool confirms), and add an output check for unsupported commitments.
14How do you design the agent's state for a support conversation?Very often asked
Keep structured fields separate from the message history: verified customer ID, order ID, order snapshot, detected intent, eligibility result, actions taken and their IDs, and escalation status. Tools read and write these fields, so decisions never depend on re-reading the chat.
15How would you support a partial refund for one item in a multi-item order?Very often asked
Fetch the order lines, let the customer pick the item, check eligibility per line (return window, condition, final-sale flags), compute the amount including its share of discounts and tax, and call the refund tool with the line ID and an idempotency key.
16Why use a small model for intent routing and a larger one for resolution?Often asked
Classification is easy and frequent, so a small model saves cost and latency; complex reasoning about the case uses a stronger model only when needed.
17How do you handle multiple languages?Often asked
Detect the language, respond in it, keep policy logic language-independent in code, and test with native speakers for tone and accuracy.
18How do you keep conversations within context limits?Often asked
Summarise older turns, keep order data in structured state rather than message text, and pass only relevant tool results.
19How do you stop fraud through the refund bot?Often asked
Check customer refund history and velocity, block refunds for flagged accounts, require evidence (photos) for damage claims above limits, and escalate unusual patterns.
20How should the bot communicate refund timing?Often asked
State clearly when the refund was issued and typical bank processing times by payment method, and send a confirmation email with the reference number.
21How do you update the agent when the policy changes?Often asked
Update the rules engine and its tests, update the policy summary used for explanations, rerun the evaluation dataset, and version the change with a release note.
22What should be logged for audits?Often asked
Every decision with the policy rule applied, tool calls and results, human approvals with reviewer identity, and the final message to the customer.
23How do you use customer history in decisions?Often asked
Fetch past orders, refunds and tickets through tools, let rules consider them (for example loyal customers get goodwill credits), and avoid exposing other customers' data.
24How do you handle a customer who asks for something outside policy?Often asked
Explain the policy plainly and offer the closest allowed alternative, such as store credit or an exchange. If the case has unusual circumstances, hand over to a human with a summary instead of bending the rule in the bot.
25How do you keep the agent's answers about stock and delivery accurate?Often asked
Never answer from the model's memory: call inventory and shipping tools for live data, show timestamps or carrier status as returned, and say when information is unavailable rather than estimating.
26How do you support voice or phone channels with the same agent?Often asked
Keep the agent logic channel-agnostic and add a speech-to-text and text-to-speech layer, shorten responses for speech, confirm critical details like order numbers by reading them back, and transfer to a person on the same call when needed.
27How do you analyse conversations to improve the agent?Often asked
Tag each conversation with intent, outcome and whether it was escalated, review a sample of failures weekly, cluster common reasons for escalation, and turn them into new tools, clearer policies or test cases.
28How do you roll out the agent gradually?Sometimes asked
Start with a small share of traffic or specific request types, monitor metrics and reviews closely, then expand once resolution quality matches human agents.
29What happens when the commerce API is down?Sometimes asked
Tools return clear errors, the agent apologises and creates a ticket for follow-up rather than guessing, and alerts notify the team.
30How do you collect feedback after a conversation?Sometimes asked
Ask a short satisfaction question at the end, link it to the trace, and review low scores to improve prompts, tools or policies.
31How do you keep the bot's tone on-brand?Sometimes asked
Provide tone guidelines and examples in the system prompt, evaluate tone with an LLM judge on samples, and review a selection of conversations each week.
32How do you handle proactive messages, such as a delayed delivery notice?Sometimes asked
Trigger them from order events, not the chat agent, send through the notification system with the customer's preferred channel, and let a reply open a conversation with the agent preloaded with that order's context.
Objective questions 32
1Where should the maximum auto-refund amount be enforced?Asked almost every time
Why: Code enforces the limit reliably; a prompt can be ignored or manipulated.
2Where should refund eligibility rules be enforced?Asked almost every time
Why: The model cannot override code.
3How should order ownership be verified?Asked almost every time
Why: Prevents acting on others' orders.
4What makes the refund tool safe to retry?Asked almost every time
Why: Retries must not double refund.
5Why use a small model for intent routing?Very often asked
Why: Routing is an easy task, so a small model saves cost and latency on every message.
6When should the agent say a refund is issued?Very often asked
Why: Ground promises in results.
7What should a handover ticket include?Very often asked
Why: Humans should not re-ask.
8Which metric shows the agent resolves issues alone?Very often asked
Why: Pair with decision accuracy.
9How should the agent be tested before launch?Very often asked
Why: Then pilot it in shadow mode.
10What helps stop refund fraud?Very often asked
Why: Escalate unusual patterns.
11Frustrated customers should be…Very often asked
Why: Calm and brief responses.
12Decisions in the support agent should be based on…Very often asked
Why: Structured state is reliable and auditable.
13A partial refund must account for…Very often asked
Why: Otherwise the customer is over- or under-refunded.
14Which LangGraph feature pauses for a manager's approval?Often asked
Why: interrupt() saves the state and waits for a resume value from a person.
15Why keep order data in structured state?Often asked
Why: Avoids bloated message history.
16What must be logged for each refund decision?Often asked
Why: These records are needed for audits.
17When the commerce API is down the bot should…Often asked
Why: The bot must never invent data.
18How should a policy change be released?Often asked
Why: Version every policy change.
19Which action may need photo evidence?Often asked
Why: Reduces false claims.
20Refund timing messages should include…Often asked
Why: Set expectations clearly.
21Why use a small model for routing?Often asked
Why: Save cost and latency.
22How is tone kept on-brand?Often asked
Why: Review samples weekly.
23An out-of-policy request should get…Often asked
Why: Bots must not bend policy on their own.
24Delivery dates should come from…Often asked
Why: Only live data is accurate.
25On a voice channel, order numbers should be…Often asked
Why: Speech recognition errors are common on numbers.
26Escalation reasons should be clustered to…Often asked
Why: Common failure reasons show what to build next.
27How should the agent be rolled out?Sometimes asked
Why: Expand once quality matches.
28Where should the post-chat survey score go?Sometimes asked
Why: Review low scores to improve.
29Customer history may be used to…Sometimes asked
Why: Within privacy limits.
30Non-refund actions like address changes need…Sometimes asked
Why: They need the same safety bar.
31Old turns in long chats should be…Sometimes asked
Why: Keeps context within limits.
32Proactive delay notices should be triggered by…Sometimes asked
Why: Events reach customers who never opened a chat.
Track your progress through every blueprint in your dashboard.
Start learning