Injecting Customer Context — Purchase History and Past Interactions

Feeding EC order history, past tickets, and product data into prompts to prevent off-target drafts

Customer ContextPurchase HistoryPrompt DesignPersonalizationCRM
5 min read

Introduction

When you have AI write reply drafts for inquiries, most people pour their energy into the prompt. That matters, of course, but what truly determines draft quality is, even more, what you show the AI — that is, injecting customer context.

If the AI can only write "we will check your order details" in response to "the product I bought the other day hasn't arrived," it's useless. Only when the AI knows what was bought, and when, can it write a specific reply.

This article explains what information the reply-draft system gathers, and how it weaves that into the prompt.

Without Context, Drafts Miss the Mark

An AI that can only write generalities

Handing the AI only the inquiry text produces generic replies — "you can check your shipping status from My Page," the kind that isn't wrong but isn't helpful. The customer is asking about their own specific order, yet gets what feels like a template.

It's the same for human operators: no one replies without looking at customer information. The AI needs the same materials.

"Time spent researching" is the real bottleneck

Most of the time in handling inquiries goes not to writing but to researching. Who is this customer, what did they buy, what did they ask before? Having the AI take over that research is, I believe, the real value of draft generation.

That's why context gathering isn't a "nice to have" — it's the core function without which nothing starts.

The full picture of injected information

What to Gather and Feed Into the Prompt

Purchase history and order information

The first thing gathered is purchase history from the EC order-management system. Using the inquiring customer's email address as the key, it pulls out recent orders, purchased products, delivery addresses, order statuses, and more.

Even if the message just says "my recent order," if the system knows the latest order, it can infer with high confidence which order is meant. The AI can then write specifically: "Regarding the △△ you ordered on [date]."

Past ticket conversations

What the same customer asked before is also important context. The system pulls the past ticket history from HubSpot and includes recent exchanges in the prompt.

This enables continuity — "regarding the size exchange we guided you through last time." Rather than starting from scratch every time, the reply reflects an accumulated relationship.

Product-name matching

Product names in the inquiry are the customer's own words, so notation varies — abbreviations, omitted colors or sizes. Passing these to the AI as-is risks replying on the premise of a product that doesn't exist.

So the system extracts what looks like a product name from the inquiry and matches it against the product master before passing it along. Tying it to the official name and specs raises the draft's accuracy.

Gathering context and building the prompt
Identify the customer from the ticket

Use the inquiry's email address and name as keys

Query the order-management system

Retrieve purchase history, delivery destination, order status

Retrieve past tickets

Gather the same customer's handling history from HubSpot

Match product names

Tie products in the inquiry to the product master

Inject as structured context

Organize the gathered context, hand it to the LLM, generate the draft

Design Considerations for Injection

More is not better

Just because context matters doesn't mean you should hand over all data wholesale. Loosely related information becomes noise that pulls the AI off course. It also increases token usage, hurting cost and speed.

So the design narrows what to pass — "just the recent order," "just the potentially relevant past tickets" — depending on the inquiry. It's roughly the same scope a human would look at when responding.

Pass it structured

The gathered information isn't just listed; it's handed over in sections — "purchase history," "past handling," "product info." This makes each piece's role clear to the AI and reduces confusion. It also lets the AI distinguish confirmed facts from inferences.

Handling personal information

Since we handle customers' addresses and contact details, care is required. Information included in the prompt is limited to what's needed for draft generation, and the generated draft stays within the internal ticket note. The premise is a design where nothing carelessly leaks outward.

Conclusion

The key to preventing off-target drafts lies less in prompt phrasing and more in injecting customer context.

  • Three kinds of context — purchase history, past tickets, product matching — make drafts specific
  • The essential value is having AI take over the time-consuming "research"
  • Pass information narrowed and structured, and design for where personal data ends up

How to use the gathered context depends on the inquiry's "intent." Next, in Classifying Inquiry Intent, we look at switching response formats by intent. For the big picture, see the hub article.