For support agents

Email API for AI customer support agents

Build AI customer support agents that read inbound email, draft thoughtful replies, and learn from human edits before sending. Real inbox per agent, full thread state, drafts API for human-in-the-loop.

The problem

A modern AI customer support agent isn't a one-shot reply — it's a stateful loop:

  1. Email arrives at [email protected]
  2. Agent reads it, classifies intent, fetches context (account state, recent invoices, prior tickets)
  3. Drafts a reply with the right tone and the right facts
  4. Either sends directly OR queues for human review (depending on the customer's confidence threshold)
  5. Stores the resolved thread for fine-tuning + audit

The hard part isn't the LLM call — it's the email infrastructure: receiving real email reliably, threading replies into prior conversations, surfacing drafts for human edit, sending without tripping spam filters, handling bounces gracefully.

What MyAgentMail gives support agents specifically

  • Real provisioned inbox at your domain — [email protected] works end-to-end. Customers email it, your agent reads it, replies thread correctly back to the original sender's inbox.
  • Full thread state storedmessages.thread_id groups inbound + outbound. The agent can fetch the entire conversation history for a customer in one call.
  • Drafts API for human-in-the-loop — the agent creates a draft (POST /v1/inboxes/:id/drafts), a human reviews and either sends-as-is or edits, the system tracks who approved what. First-class concept, not a hacky "set a flag in a DB" pattern.
  • Real-time WebSocket events — when a new inbound email arrives, your agent's worker gets notified within ~1 second via /v1/ws. No polling. No webhook retry loop.
  • Read receipts (open + click tracking) so the agent can tell whether a customer actually opened the reply they sent.
  • Threaded reply with proper headersIn-Reply-To + References headers preserved across the whole thread so the customer's mail client (Gmail, Outlook, Apple Mail) renders the conversation correctly.
  • Bounce + complaint pipeline — if a customer's address starts bouncing (left the company, mailbox full), your agent gets notified and can update the customer record.

Sketch

import { MyAgentMail } from "myagentmail";
const mam = new MyAgentMail({ apiKey: process.env.MAM_KEY });

// 1. Provision the support inbox once.
const inbox = await mam.inboxes.create({
  username: "support",
  domain: "yourcompany.com",
});

// 2. Subscribe to inbound email — drives the agent loop.
await mam.webhooks.create({
  url: "https://your-app.com/hooks/support",
  events: ["message.received"],
  inboxId: inbox.id,
});

// Your handler:
app.post("/hooks/support", async (req, res) => {
  const { messageId, inboxId } = req.body;
  const message = await mam.messages.get(inboxId, messageId);

  // 3. Generate a reply with your LLM.
  const draft = await llm.generate({
    customerMessage: message.plainBody,
    threadHistory: await mam.messages.threadList(inboxId, message.threadId),
    customerContext: await fetchAccountContext(message.from),
  });

  // 4. If high confidence → send directly. If lower → save as draft.
  if (draft.confidence > 0.85) {
    await mam.messages.reply(inboxId, messageId, {
      plainBody: draft.text,
      htmlBody: draft.html,
    });
  } else {
    await mam.drafts.create(inboxId, {
      to: message.from,
      subject: `Re: ${message.subject}`,
      plainBody: draft.text,
      htmlBody: draft.html,
      // Store the agent's reasoning so the human reviewer has context
      metadata: { confidence: draft.confidence, llmReasoning: draft.reasoning },
    });
    await pingHumanReviewer({ messageId });
  }
  res.json({ ok: true });
});

Why this beats Resend / Postmark for support agents

Both are excellent transactional senders but support has different requirements:

  • Resend / Postmark have inbound webhooks but no stored inbox. You'd build the threading + history layer yourself.
  • Drafts as a primitive — neither Resend nor Postmark have a drafts API. You'd build it. We treat it as a first-class concept because human-in-the-loop is the dominant support agent pattern.
  • Real IMAP fallback — if your support agent goes down, a human can SSH-style log into the inbox via IMAP and respond. We provide that; pure-API senders don't.

Where this is NOT the right fit

  • Native Helpdesk integration. If you're building on top of Zendesk/Intercom/HelpScout, use their APIs — they're optimized for that workflow.
  • Live chat. We do email. Live chat is a different shape.
  • Voice / phone-tree support. Different infrastructure entirely.

Pricing

Email module: $5/month per inbox. 7-day free trial. See /pricing for higher-volume tiers.

Related

Other use cases

Last reviewed 2026-05-02.