> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebuly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write good classes

> How to write class descriptions that classify accurately, improve a first draft, and prepare for features that aren't launched yet.

Good classes give you accurate reports. This page shows which method to pick for a new class and how to write class descriptions that work, with an example and ideas from real projects.

To create groups and classes, see [Manage groups](https://docs.nebuly.com/documentation/setup/taxonomy.md) and [Manage classes](https://docs.nebuly.com/documentation/setup/taxonomy-classes.md).

## Which method to select when creating new classes

Ask yourself one question: **can you describe the class in words, or is it an exact rule?**

> [card] Description: describe it in words
>
> Use it for most classes. You explain what belongs in the class, and Nebuly matches interactions by meaning, in any wording or language.
>
> **Examples**
>
> * **Refund requests**: "Inquiries where the user asks for money back or for the status of a refund."
> * **Assistant refuses**: "The assistant says it can't help with the request."

> [card] Regex: match exact text
>
> Use it when the class is defined by a precise pattern, such as a code or a name.
>
> **Examples**
>
> * **Order numbers**: `ORD-\d{6}`
> * **Product mentioned**: `(?i)pro plan|enterprise plan`

> [card] Filter: reuse what Nebuly already knows
>
> Use it to build a class from existing Nebuly filters. The result is deterministic: an interaction is in the class when it matches the filters.
>
> **Examples**
>
> * **Frustrated users**: `User emotion = Frustrated`
> * **Mobile traffic**: a tag filter such as `channel = mobile_app`

> [card] Customized: combine conditions
>
> Use it when one method isn't enough. Combine descriptions, regex and filters with **AND** and **OR**, and nest them in groups.
>
> **Example**
>
> * **Angry billing complaints**: `User emotion = Frustrated AND (description matches a billing issue OR regex matches "refund|charge")`

> [!TIP]
>
> Start with **Description**. Switch to Regex, Filter or Customized only when you need an exact rule.

## Why good descriptions matter

* **Overlapping classes split your data.** If two classes fit the same interaction, it can land in either one, or in Other. Neither total can be trusted.
* **Vague classes catch everything.** They keep growing and hide the real trends.

## Rules for a good description

1. **Start the way Nebuly expects.** For **User query**: "Inquiries where the user..." or "When the user...". For **Agent answer**: "The assistant...".
2. **One subject per class**, in one sentence, with a matching name.
3. **Including**: list edge cases you want in.
4. **Excludes**: list similar cases you want out.
5. **Don't send readers to other classes.** Write "Excludes refund requests", not "those go to Refunds". Then make sure Refunds includes them.
6. **Fix both sides.** When two classes overlap, edit both together.
7. **Don't create an "Other" class.** Nebuly already has one.

## Example: from a first draft to a good taxonomy

Brightwing Airways, an invented airline, connects its chatbot to Nebuly. Lena, who leads customer care, writes the Topic classes.

### Attempt 1: too vague

Lena reuses her team's email categories: "Travel issues: problems during the journey", "Customer service: general requests", "Other requests: anything else".

* Almost anything fits "Travel issues" or "Customer service".
* "Other requests" copies Nebuly's own Other.
* The descriptions don't start the way Nebuly expects.

### Attempt 2: clear, but overlapping

Lena rewrites each class more precisely. Two still overlap:

* **Flight disruptions**: "Inquiries where the user asks about a delay or a cancellation decided by the airline, **and what they can do about it**."
* **Refunds**: "Inquiries where the user asks for money back or for the status of a refund."

"My flight was cancelled, can I get my money back?" fits both. Neither total is reliable.

### Attempt 3: clear, no overlaps

<table>
  <colgroup>
    <col width="218" />

    <col width="504" />
  </colgroup>

  <thead>
    <tr>
      <th>Class</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Flight disruptions</td>
      <td>Inquiries where the user asks about a delay or a cancellation decided by the airline. Excludes requests to be rebooked or refunded.</td>
    </tr>

    <tr>
      <td>Rebooking</td>
      <td>Inquiries where the user asks to be moved to another flight, including after a delay, a cancellation or a missed connection.</td>
    </tr>

    <tr>
      <td>Refunds</td>
      <td>Inquiries where the user asks for money back or for the status of a refund, including after a cancelled flight.</td>
    </tr>

    <tr>
      <td>Unexpected charges</td>
      <td>Inquiries where the user asks about a charge they don't recognise or think is wrong. Excludes refund requests.</td>
    </tr>

    <tr>
      <td>Booking changes</td>
      <td>Inquiries where the user asks to change the date, time or passenger name of a booking. Excludes changes caused by a disruption.</td>
    </tr>

    <tr>
      <td>Lost or damaged baggage</td>
      <td>Inquiries where the user reports a bag that is missing, late or damaged.</td>
    </tr>
  </tbody>
</table>

**Why it works**

* **No overlaps.** Including and Excludes keep related classes apart.
* **A clear rule for mixed messages.** When a user describes a problem and asks for something, the request wins.
* **No catch-all.** What fits nothing goes to Other.

Now Lena sees that Refunds is growing fastest, and that most refund requests follow cancellations. She knows what to fix first.

## Improving a first draft

**1. Read real interactions**

Read 20 to 30 interactions the class should catch. Also read the near misses: similar ones that ended up in another class.

**2. Turn near misses into rules**

Add the recurring ones as Including or Excludes lines.

**3. Update related classes**

If another class overlaps, edit it at the same time.

**4. Test on recent data**

Reprocess the last 7 days and check the result before going further back.

## Classes for a feature that isn't launched yet

1. **Guess how users will ask about it**, in their words, not your internal feature name. Also guess how the assistant will reply when it can't help yet.
2. **Write the class on User query**, or on **Agent answer** for fallback replies. If the feature has a unique name, add a regex condition with OR.
3. **Check the first real interactions** after launch, and refine with the steps above.
4. **Don't judge results on dev or staging.** There isn't enough traffic. Use them only to check your setup.

## Ideas from real projects

<table>
  <colgroup>
    <col width="255" />

    <col width="548" />
  </colgroup>

  <thead>
    <tr>
      <th>Idea</th>
      <th>How to build it</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>**Off-topic**</td>
      <td>A Topic class that describes your domain, such as "anything not about the software, the company or microscopy". Teams can then filter it out.</td>
    </tr>

    <tr>
      <td>**More detailed intents**</td>
      <td>Split support into hardware support, lifetime support and buying a new device. Purchase intents with high error rates point to unmet demand.</td>
    </tr>

    <tr>
      <td>**Commercial signals**</td>
      <td>Upsell, churn and channel deflection ("the bot sends the user to the app"), on User query.</td>
    </tr>

    <tr>
      <td>**Assistant behaviour**</td>
      <td>Classes on Agent answer, such as a silent fallback: the bot answers about a different time period without telling the user.</td>
    </tr>

    <tr>
      <td>**Wrong routing**</td>
      <td>Describe what should go where, so mistakes show up as a class.</td>
    </tr>

    <tr>
      <td>**Work vs personal use**</td>
      <td>For internal assistants: off-topic or personal-use classes, left out of ROI.</td>
    </tr>
  </tbody>
</table>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.