Menu

How NLP Works in Customer Service: From Message to Support Ticket

Follow a duplicate-charge complaint from message to billing queue. Try a small Python classifier and see where it misroutes tickets.

“The replacement arrived today, but you charged me twice.” Where should that ticket go? The word replacement points toward returns. The customer, however, has already received the item. They want someone to check the bill.

Natural language processing (NLP) helps customer service teams turn everyday language into information they can act on. In this case, a useful output is a billing ticket with the customer’s exact words attached. The billing team can then check whether a second payment actually went through. Let’s follow this fictional message from the inbox to that check.

From a customer message to a support ticket

Start with the decision a support worker would make. If your team has separate queues for billing, returns and delivery, each label needs a clear meaning. Otherwise two people can read the same message, choose different labels and both be following your instructions.

The replacement arrived, but the customer reports two charges. The ticket goes to billing for a payment check.
 The first clause explains what happened to the item. The second identifies the issue billing needs to investigate.
StepWhat happens to this ticket
Identify the intentThe customer reports a possible duplicate charge. “Arrived today” describes a completed event.
Classify the requestAssign the issue label “possible duplicate charge.” Keep “charged me twice” as evidence from the message.
Route the ticketA routing rule maps the label to the billing queue. The reviewer receives the message and its supporting phrase.
Check the resultBilling checks the authorized payment record. If the ticket belongs elsewhere, record the corrected queue so the mistake can be investigated.

That last step involves two different questions. Did the router send the complaint to the right team? Did a duplicate payment occur? The message gives you enough information to judge the first. Only the account records can settle the second.

Three ways to classify the same message

A large language model (LLM) is one way to do NLP. It can fill the same slot in a ticket system as a dedicated intent classifier. Either way, the team still has to define the labels, decide who handles each one and check the outcome.

ApproachHow it handles the message
Keyword ruleA rule that sends any mention of “replacement” to returns would misroute this ticket. A more specific billing rule can fix this case, though rule order matters when both match.
Dedicated classifierTrain a model on past messages with agreed labels. It learns which features tend to occur in each queue. For a narrow, stable set of queues, a small model is a practical baseline to test.
Prompted LLMGive the model queue definitions and ask it to identify the open request and quote the words supporting its choice. It can consider how the clauses fit together. Check the label and evidence before routing.

Google’s guide to intent matching shows how training phrases connect different ways of asking for help to the same intent. Anthropic’s ticket-routing guide shows how to give a language model the queue definitions in a prompt.

Try a small ticket classifier in Python

Here’s a simple experiment you can repeat locally. Give each of six invented messages a queue, train a classifier, then try three messages it has never seen. The model counts words and learns how often they occur in each queue. The classifier uses a method called Naive Bayes.

With Python 3.12 in a virtual environment, install the version used for this example.

python -m pip install scikit-learn==1.8.0

Save the following as route_ticket.py and run python route_ticket.py.

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.pipeline import make_pipeline

examples = [
    ("My card was charged twice", "billing"),
    ("Please check a duplicate charge", "billing"),
    ("Two payments for one order", "billing"),
    ("I need a replacement", "returns"),
    ("How do I return this item?", "returns"),
    ("Please send a replacement item", "returns"),
]
messages, queues = zip(*examples)
router = make_pipeline(CountVectorizer(), MultinomialNB())
router.fit(messages, queues)

tickets = [
    "The replacement arrived today, but you charged me twice.",
    "I wasn't charged twice. Can I exchange it?",
    "Where is the nearest store?",
]
predictions = router.predict(tickets)
probabilities = router.predict_proba(tickets)
for ticket, queue, scores in zip(tickets, predictions, probabilities):
    details = ", ".join(
        f"{label} {score:.0%}" for label, score in zip(router.classes_, scores)
    )
    print(ticket)
    print(f"  Queue: {queue} ({details})")

The run produced these results with Python 3.12.14 and scikit-learn 1.8.0.

The replacement arrived today, but you charged me twice.
  Queue: billing (billing 51%, returns 49%)
I wasn't charged twice. Can I exchange it?
  Queue: billing (billing 77%, returns 23%)
Where is the nearest store?
  Queue: billing (billing 50%, returns 50%)

The duplicate-charge ticket gets to billing by a whisker. The only words the model recognizes are “replacement,” “charged” and “twice.” Together they give billing a 51% score and returns 49%, rounded to the nearest percent. The model is more confident on the exchange request, where it gets the answer wrong. It recognizes “charged” and “twice” but misses both the denial and the request for an exchange. Billing gets 77%.

The store question is an exact tie. None of its words appeared in training, and each queue had three training messages. Both scores are 50%. The classifier picks the first label in its alphabetical list, which happens to be billing.

A support team could send any ticket whose top score is below a chosen cutoff to a review queue. Try a 60% cutoff on these results. It catches the tie and sends the correctly labeled duplicate-charge ticket for review too. The wrong exchange prediction still goes straight to billing at 77%. Choose a cutoff using separate, labeled tickets, and check which mistakes still reach customers.

Give a language model the same task

Try this prompt with a fictional ticket. It makes the categories, fallback and required evidence explicit. Change the message while keeping the instructions fixed. For help choosing examples, see our prompt engineering guide.

Classify the customer’s current request.
billing = a charge or payment needs investigation
returns = the customer wants to return or exchange an item
review = unclear, multiple open requests, or outside these queues

Return a queue and an exact quote that supports your choice.
Use review if the request needs clarification.

Message: The replacement arrived today, but you charged me twice.

The reference answer for that message is billing, supported by “you charged me twice”. For the exchange message, the reference answer is returns, supported by “Can I exchange it?”. These are answers to grade against. The measured outputs above came from the Python classifier.

Software can restrict the model’s queue field to a list of allowed values and check that its quote appears in the message. Both checks would still pass if it chose returns and quoted “replacement.” A reviewer also needs to ask whether the quote supports the customer’s open request. OpenAI describes this limit in its guide to Structured model outputs.

What sentiment, voice and translation add

Sentiment estimates tone. Google’s guide to sentiment analysis describes how a model scores the feeling expressed in a message. Compare “Could you check the second charge?” with “This is the third time I’ve asked about the second charge!” The billing issue is the same. The second message gives a support worker useful context about repeated contact. A calm tone alone gives little reason to lower the priority of a payment problem.

Voice adds a transcription step. If a call transcript drops “wasn’t” from the exchange example, even an accurate classifier receives the wrong message. When investigating a misroute, check the input the classifier actually saw. For multilingual support, test the phrases people use in each supported language, including mixed-language messages. A test that starts with a clean English translation skips the very step that may have failed.

These decisions can happen behind an email form, a call-center dashboard or the conversational interface in our Python chatbot tutorial. A label-to-queue mapping can run as a fixed workflow. The AI agents guide covers the separate question of when software should choose its own next step.

How to tell whether routing improved

Set aside a test set before changing the rules, training examples or prompt. Keep messages from the same conversation on one side of the split. Have support staff mark the desired queue and discuss disagreements. If “I want my money back” means billing to one reviewer and returns to another, clarify whether more context is needed before scoring either model.

  • Compare on the same tickets. Run the current router and the proposed replacement on identical inputs. Include short messages, negation, misspellings, two requests in one message and topics outside the available queues.
  • Look at the direction of each mistake. Count how often a billing ticket lands in returns and how often a returns ticket lands in billing. A table of expected and predicted queues is called a confusion matrix.
  • Track what happens after routing. Check how often staff transfer tickets, how long customers wait for the right team and which cases go to review. A router that sends everything to a person avoids wrong automatic assignments at the cost of a larger review queue.

Use the pattern of errors to choose the next change. If several routers fail on the same vague requests, improve the form or add a clarifying question. If one model repeatedly misses exchanges when billing is mentioned, add examples of that distinction to training or prompt development and check again on separate tickets.

Keep customer data out of the routing example

A real billing message may contain a name, email address, order number or payment details. To decide which queue should receive it, “you charged me twice” is usually enough. In a real workflow, the ticketing system can keep an internal reference so authorized billing staff can find the transaction after routing.

Use invented tickets when trying the prompt or sharing a demo. For a deployed system, review what the classifier receives, who can see prompts and logs, how long records are kept and how a provider handles submitted data. An order number can still identify a customer when linked back to an account. The FTC’s guide to protecting personal information explains how to limit what you collect, who can access it and how long you keep it.

Sources

Checked as of November 27, 2026.

Get Edgelyst Updates

Subscribe for new AI articles, practical guides, and learning resources.