Blog
    AI Solutions8 min

    Automatic Classification and Routing of Emails and Requests with an LLM

    Abstract illustration of envelopes entering a central node and being sorted into three paths of different colours
    November 27, 2026Team 42bites
    LLMClassificationRoutingEmailAI SolutionsAutomation

    An info@ mailbox receives sales enquiries, support reports, invoices, job applications and spam within a single hour. Sorting them by hand takes time and causes delays. A language model can read each message, assign it to a category and flag its urgency, leaving people the work that requires judgement. The benefit is real, provided categories, controls and measurements are set up properly.

    When an LLM Makes Sense

    Fixed rules, such as keywords or the sender's address, work as long as messages are predictable. An LLM is useful when the text is free-form, written in different languages or ambiguous: it understands that "I can't log in" and "invalid password" concern the same problem. For very high volumes and simple categories a smaller, cheaper classifier may be enough, so it is worth comparing the options.

    Defining the Categories

    • Few categories, mutually exclusive and clearly named, six to ten at the start.
    • A description and two or three examples for each, written from real anonymised texts.
    • An "other" or "to review" category for anything that does not fit.
    • A separate field for urgency, with a defined scale.
    • Any fields to extract, such as order number, customer name or product mentioned.

    How to Set Up the Prompt

    The prompt lists the categories with their descriptions, asks for a structured response and forbids inventing information. Using JSON output with a fixed schema makes the answer directly usable by a workflow, for example in n8n. It also helps to ask for a confidence field and a short rationale, which serve for checking and for improving the prompt.

    {

    "category": "technical_support",

    "urgency": "high",

    "language": "en",

    "confidence": 0.92,

    "rationale": "The customer reports a service outage"

    }

    Confidence Thresholds and Human Review

    Not every classification has the same value. Above a chosen threshold, the message is routed automatically; below it, it goes to a review queue where a person assigns it. Manual corrections should be saved: they become new examples for the prompt and a test set for measuring improvements. For sensitive messages, such as legal complaints or personal data requests, human review should always be provided.

    The Complete Flow

    • Receiving the message by email, form or chat.
    • Cleaning the text: removing signatures, quoted replies and unnecessary attachments.
    • Calling the model with the categories and response schema.
    • Validating the result and applying the confidence threshold.
    • Assigning to the department or creating the ticket in the management system.
    • Logging the decision for checks and statistics.

    Privacy and Security

    Emails contain personal data. Before sending them to an external service, check the data processing agreement, the processing location and retention rules, and consider removing or masking unnecessary information. The text of a message must be treated as untrusted: it may contain instructions aimed at the model, so the output should be limited to allowed values and verified before acting.

    How to Measure Quality

    • Build a test set of a few hundred messages already classified by hand.
    • Calculate precision and recall for each category, not just the overall percentage.
    • Check the costliest error cases, such as a complaint that ended up in spam.
    • Measure the average first-response time before and after automation.
    • Repeat the test whenever the prompt or the model changes.

    Key takeaway: an LLM routes requests well when categories are defined with real examples, the output is structured and uncertain cases go through a human review measured over time.

    Want to Route Customer Emails and Requests Automatically?

    We integrate language models and n8n workflows to classify messages, create tickets and shorten response times.