Browse the docs

AI

Reply classification settings, the opt-out review queue, the drafting endpoint and limits.

AI features

Two optional features: classifying replies to the mail you send, and drafting email text for a person to edit. Reply classification is off until your workspace turns it on, and drafting runs only when someone asks for a draft. The text a feature needs goes to Gatewae, Workwae's AI gateway, which forwards it to a language model provider that does not train on it.

FeatureSent
Reply classificationThe reply's subject, the first 2,000 characters of its own text, and whether it carries standard auto-reply headers. An out-of-office reply is read once more, with the date it was sent, for its return date.
DraftingThe instructions, the draft so far and, when answering a message, that message's sender, subject and the start of its own text.

Reply classification

Turn on aiReplyClassification with PATCH /v1/settings. New inbound mail in the inbox or junk that answers a message you sent through Workwae, matched by thread or by its In-Reply-To and References headers, is classified about a second after it is indexed. Mail more than seven days old when indexed is not classified. Turning the setting off drops queued replies unread.

curl -X PATCH "https://api.workwae.com/v1/settings" \
  -H "Authorization: Bearer $WORKWAE_API_KEY" \
  -H "content-type: application/json" \
  -d '{ "aiReplyClassification": true, "optOutHandling": "review" }'

Each result is stored as the message's classification and sent as message.classified:

  • kind: opt_out, auto_reply, bounce or human_reply, with optOutProbability.
  • autoReplyCategory, on auto-replies only: out of office, left the company, address changed, ticket acknowledgment, challenge-response, or other.
  • returnDate for out-of-office replies, left empty when the date is not real, falls before the day the reply was sent, or is more than a year after it.
  • alternateContacts: up to five addresses a left-the-company or address-changed reply names, read from its text.
  • outboxId: the send the reply answers.
import { parseWebhook } from "@workwae/sdk";

const event = await parseWebhook(secret, request.headers, await request.text());
if (event.known && event.type === "message.classified") {
  const { message, classification: c } = event.data;
  if (c.autoReplyCategory === "out_of_office" && c.returnDate) {
    await pause(c.outboxId, c.returnDate);
  }
  if (c.kind === "human_reply") await stopFollowUps(c.outboxId);
}

Opt-outs and the review queue

optOutHandling decides what a detected opt-out from the send's own recipient does (probability 0.9 or more): off ignores it, review (the default) holds it in the review queue, and suppress suppresses it at once. Replies saying the person left or changed address always wait for review unless the setting is off. Unsubscribe links always suppress, whatever the setting.

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));
}

The Suppression lists guide covers each mode in detail.

Drafting

POST /v1/ai/draft writes an email body from instructions (up to 2,000 characters) in text or markdown, and returns { text }. Optional context names the message being answered (accountId with replyToMessageId) and the draft so far (currentDraft). Nothing is sent or saved. It needs an API key with the write scope and the AI module in the tenant's plan (plan_module_unavailable otherwise).

curl -X POST "https://api.workwae.com/v1/ai/draft" \
  -H "Authorization: Bearer $WORKWAE_API_KEY" \
  -H "content-type: application/json" \
  -d '{
  "instructions": "Shorter, and offer a call on Thursday",
  "context": { "accountId": "'"$ACCOUNT_ID"'", "replyToMessageId": "'"$MESSAGE_ID"'" },
  "format": "markdown"
}'

Limits and errors

Limit or reasonMeaning
Daily classification capEach workspace has a daily cap on classified replies; past it, replies wait for the next UTC day.
rate_limitedDrafts have a per-minute limit per workspace; past it, 429 with Retry-After.
ai_refusedThe model declines the instructions.
ai_unavailableThe AI gateway fails or does not answer in time.

If the gateway fails, classification retries a reply later, backing off to an hour, for up to seven days. Every answered call counts toward aiCalls in your daily usage (GET /v1/usage).

Every route is in the AI reference.