---
title: "AI · Workwae"
description: "Optional AI for email: classify replies to your sends and draft text for a person to edit. Off until you turn it on; never used for training."
url: https://workwae.com/features/ai
---

1. [Features](https://workwae.com/features/)
2. AI

AI

# Know what each reply means, and draft the next one.

Two optional features, off until you turn them on: classifying replies to the mail you send, and drafting email text for a person to edit.

[Request early access](https://workwae.com/early-access/) [Opt-out review guide](https://docs.workwae.com/guides/suppressions)

message.classified

```jsonc
// A reply to one of your sends, as your webhook gets it
{
  "type": "message.classified",
  "data": {
    "classification": {
      "kind": "auto_reply",
      "autoReplyCategory": "left_company",
      "optOutProbability": 0.02,
      "returnDate": null,
      "alternateContacts": ["sam.lee@example.com"],
      "outboxId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d3f"
    }
  }
}
```

What you get

## Replies sorted, opt-outs handled, drafts on request.

Classification runs on replies to your own sends, drafting only on request, and nothing else calls the AI gateway.

### Four kinds of reply

Each reply is `opt_out`, `auto_reply`, `bounce` or `human_reply`, with a probability for each.

### Six auto-reply categories

Out of office, left the company, address changed, ticket acknowledgment, challenge-response or other, with auto-reply headers only a hint.

### Return dates

Read in the sender's time zone, and left empty if not real, before the reply or over a year after it.

### People who moved on

Up to five addresses the reply names, as `alternateContacts`, read from its text, never the model.

### Opt-outs, your way

A likely opt-out from your own recipient is ignored, held for review, or suppressed, per your setting.

### Matched to your sends

By thread or `In-Reply-To` and `References` headers, carrying the send's `outboxId`.

### Drafting

An email body from instructions, in plain text or Markdown, never sent or saved.

### Metered per day

Every answered classification counts toward `aiClassifications` and every draft toward `aiDrafts` in your daily usage.

### Off until you opt in

Classification waits for your workspace to turn it on, since reply text goes to a third party.

### No training

Our providers don't train models on the data we send, and we never use it to train any model.

### Outages delay, they don't lose

Failed replies are retried, backing off to an hour, for up to seven days.

### Limits per workspace

Past a daily cap, replies wait for the next UTC day; drafts past a per-minute limit get `rate_limited`.

[All features](https://workwae.com/features/)

Build it

## Turn it on and work the review queue

Switch on classification, pick how opt-outs are handled, and let a person decide on the held ones.

- **Turning it off drops queued replies unread,** and nothing more is sent.
- **Reviews carry context:** the list, address, source, message and how sure the detection was.
- **Approving suppresses** the address on the review's list; dismissing drops the review.

settings.tssettings.py

```ts
await workwae.settings.update({
  aiReplyClassification: true,
  optOutHandling: "review",
});

// Opt-outs and recipients who moved on, waiting for a person
const reviews = workwae.suppressionReviews;
const { items } = await reviews.list({});
for (const review of items) {
  const ok = await askOwner(review.address, review.source);
  const input = { reviewId: review.id };
  await (ok ? reviews.approve(input) : reviews.dismiss(input));
}
```

```python
workwae.settings.update(
    ai_reply_classification=True,
    opt_out_handling="review",
)

# Opt-outs and recipients who moved on, waiting for a person
reviews = workwae.suppression_reviews
for review in reviews.list().items:
    ok = ask_owner(review.address, review.source)
    if ok:
        reviews.approve(review_id=review.id)
    else:
        reviews.dismiss(review_id=review.id)
```

Build it

## Act on replies as they're classified

Pause a sequence until someone is back, suggest the new contact when someone left, and stop following up once a person answers.

- **Signed and typed.** `parseWebhook``parse_webhook` checks the signature and narrows the event on its type.
- **`outboxId``outbox_id` ties back** to the send, and the event carries the message and its mailboxes.
- **`autoReplyCategory``auto_reply_category`** is null for every kind but auto-replies.

webhook.tswebhook.py

```ts
import { parseWebhook } from "@workwae/sdk";

const body = await request.text();
const event = await parseWebhook(secret, request.headers, body);
if (event.known && event.type === "message.classified") {
  const { message, classification: c } = event.data;
  switch (c.autoReplyCategory) {
    case "out_of_office":
      if (c.returnDate) await pause(c.outboxId, c.returnDate);
      break;
    case "left_company":
    case "address_changed":
      await suggest(message.threadId, c.alternateContacts);
      break;
  }
  if (c.kind === "human_reply") await stopFollowUps(c.outboxId);
}
```

```python
from workwae import UnknownEvent, parse_webhook

body = request.get_data()
event = parse_webhook(secret, request.headers, body)
if not isinstance(event, UnknownEvent) and event.type == "message.classified":
    message, c = event.data.message, event.data.classification
    if c.auto_reply_category == "out_of_office":
        if c.return_date:
            pause(c.outbox_id, c.return_date)
    elif c.auto_reply_category in ("left_company", "address_changed"):
        suggest(message.thread_id, c.alternate_contacts)
    if c.kind == "human_reply":
        stop_follow_ups(c.outbox_id)
```

Build it

## Draft a reply for a person to edit

`POST /v1/ai/draft` returns `{ text }` from instructions and powers "Draft with AI" in the console's compose and template editor.

- **Instructions** of up to 2,000 characters, in the person's own words.
- **Optional context:** the message being answered (`accountId` with `replyToMessageId`) and the draft so far (`currentDraft`).
- **Format** `text` or `markdown`, with an API key that has the write scope.
- **Clear refusals:** `ai_refused` when the model declines, `ai_unavailable` when the gateway fails or times out.

draft.tsdraft.py

```ts
import { isApiError } from "@workwae/sdk";

try {
  const { text } = await workwae.ai.draft({
    instructions: "Shorter, and offer a call on Thursday",
    context: {
      accountId,
      replyToMessageId: messageId,
      currentDraft,
    },
    format: "markdown",
  });
  editor.setValue(text);
} catch (error) {
  if (!isApiError(error, "ai_refused")) throw error;
  showHint("Try rewording the request");
}

// Classifications and drafts per day, next to the rest of your usage
const { days } = await workwae.usage.get({ from: "2026-10-01" });
const ai = days.map((d) => [d.day, d.aiClassifications, d.aiDrafts]);
```

```python
from datetime import date

from workwae import APIError

try:
    draft = workwae.ai.draft(
        instructions="Shorter, and offer a call on Thursday",
        context={
            "account_id": account_id,
            "reply_to_message_id": message_id,
            "current_draft": current_draft,
        },
        format="markdown",
    )
    editor.set_value(draft.text)
except APIError as error:
    if error.code != "ai_refused":
        raise
    show_hint("Try rewording the request")

# Classifications and drafts per day, next to the rest of your usage
days = workwae.usage.get(from_=date(2026, 10, 1)).days
ai = [(d.day, d.ai_classifications, d.ai_drafts) for d in days]
```

Reference

## Details and questions about AI features.

**How a reply is classified**

- Only new inbound mail in the inbox or junk that answers your send is queued; mail over seven days old when indexed isn't classified.
- One decision gives the kind, opt-out probability and any auto-reply category; an out-of-office reply is read again for its return date.
- In about a second, the result is stored as the message's `classification` and announced as `message.classified`.

**What a detected opt-out does**

Your workspace's `optOutHandling` setting decides, `review` by default, for replies from the send's own recipient; an opt-out counts at a probability of 0.9 or more.

Opt-out handling modes

| Setting | Reply asking to opt out | Left the company or changed address |
| --- | --- | --- |
| `off` | Ignored. The reply is still classified. | Ignored. |
| `review` | Waits in the review queue with the message it came from and how sure the detection was. | Waits for review on the global list (source `inactive`), with the alternate contacts. |
| `suppress` | Suppressed at once. Sent to several people, it waits for review unless the receiving server shows [DMARC](https://workwae.com/glossary#dmarc), or an aligned [SPF](https://workwae.com/glossary#spf) or [DKIM](https://workwae.com/glossary#dkim), passing for the sender. | Waits for review, never suppressed at once. |

- Unsubscribe links and one-click unsubscribe always suppress, whatever the setting.
- From anyone but the send's recipient, a left-the-company or address-changed reply keeps no addresses and queues nothing.

**What goes to our AI gateway**

When a feature is on, Workwae sends only the text it needs to Gatewae, the AI gateway we use, which forwards it to a language model provider and returns the results.

Data sent for each AI feature

| Feature | Sent | Not sent |
| --- | --- | --- |
| Reply classification | The reply's subject, the first 2,000 characters of its own text, and whether it carries standard auto-reply headers. For an out-of-office reply, its subject and text again, with the date it was sent. | Quoted history, the rest of the thread, attachments, and anything about the account or the recipient. |
| Draft writing | The person's instructions, their draft so far and, when answering a message, that message's sender, subject and first 4,000 characters. | Anything else in the mailbox. |

The same list is in the [Privacy Policy](https://workwae.com/privacy#ai), and Gatewae is listed among our [subprocessors](https://workwae.com/security#subprocessors).

**Events from AI features**

Events emitted by AI features

| Event | When |
| --- | --- |
| `message.classified` | A reply to one of your sends was classified; carries the message, its mailboxes and the classification. |
| `suppression.created` | A detected opt-out was suppressed, at once or on approval (source `reply`), or an approved review of a recipient who moved on put the address on the global list (source `inactive`). |

**Can I classify replies without suppressing anyone?**

Yes. With `optOutHandling` set to `off`, replies are still classified and announced, and only unsubscribe links suppress.

**What happens when the gateway is down?**

Replies are retried, backing off to an hour, until they are seven days old, so an outage delays classification rather than losing replies. A draft request answers `ai_unavailable`.

Early access

## Let replies sort themselves.

Workwae is in early access. Tell us what you are building, and read the docs in the meantime.

[Request early access](https://workwae.com/early-access/) [AI API reference](https://docs.workwae.com/reference/ai)
