How to Build a Claude-Powered Email Reply Assistant
Building a Claude-powered email reply assistant means connecting your inbox (or helpdesk) to the Claude API so that incoming messages are automatically drafted, summarized, or triaged by the model, with a human reviewing before anything sends. The core pieces are: a trigger that fires on new email, a prompt that gives Claude the right context (thread history, tone, company knowledge), a call to the Claude API that returns a draft reply, and a review step that writes the draft back into your email client or support tool.
This article walks through the whole pipeline — from fetching the email to generating a reply to wiring it into Gmail, Outlook, or a helpdesk API — using plain Claude API calls. If you don't want to manage API keys, billing, and rate limits yourself, you can swap the raw Anthropic SDK for SubToAPI, which exposes the same model through a simple HTTPS endpoint with per-app keys and usage tracking.
Architecture overview
A production email reply assistant has four stages:
- Ingestion — pull new emails via Gmail API, Microsoft Graph, IMAP, or a webhook from your helpdesk (Zendesk, Front, Intercom).
- Context assembly — gather the thread history, sender metadata, and any relevant knowledge base snippets.
- Generation — send the context to Claude with a system prompt that defines tone, constraints, and output format.
- Review and send — surface the draft to a human for approval, or auto-send for low-risk categories (e.g., "order status" replies).
Skipping step 4 is tempting but risky. Even a well-tuned prompt can misread sarcasm, urgency, or a legal threat. Start with human-in-the-loop and only automate sending for narrow, well-tested categories.
Step 1: Structure the prompt
Claude performs best when you separate stable instructions (system prompt) from variable content (the email thread). A system prompt for an email assistant should cover:
- The sender's role (support agent, sales rep, founder)
- Tone and length constraints
- What not to do (never promise refunds, never share internal pricing)
- Output format (plain draft text, or structured JSON with subject + body)
You are a support reply assistant for Acme Co.
Write a draft reply to the customer's email below.
- Keep it under 150 words.
- Match a friendly, professional tone.
- If the customer asks for a refund, do not approve it — acknowledge
and say a human will follow up within 24 hours.
- Output only the reply body, no subject line, no signature.
Step 2: Send the thread to Claude
Pass the full thread (not just the latest message) so Claude has context on what's already been said. Trim very long threads to the last 5–10 messages to control token usage.
curl https://api.subtoapi.app/v1/messages \
-H "Authorization: Bearer $SUBTOAPI_KEY" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 400,
"system": "You are a support reply assistant for Acme Co. ...",
"messages": [
{
"role": "user",
"content": "Thread:\n\nCustomer: My order #4821 hasn'\''t arrived, it'\''s been 9 days.\n\nWrite a draft reply."
}
]
}'
The response contains the draft text in content, plus usage metadata so you can track token spend per email, per team, or per customer tier. See the quickstart and messages reference for the full request and response shape.
Step 3: Add structure for downstream automation
If you want the assistant to also tag the email (e.g., "billing", "bug report", "spam") so it can route to the right queue, ask Claude to return JSON instead of free text, and use tool use to enforce a schema:
{
"name": "draft_reply",
"description": "Return a draft email reply with category tag",
"input_schema": {
"type": "object",
"properties": {
"category": { "type": "string", "enum": ["billing", "bug", "shipping", "general"] },
"reply": { "type": "string" },
"needs_human_review": { "type": "boolean" }
},
"required": ["category", "reply", "needs_human_review"]
}
}
Claude will call this tool with structured arguments instead of writing free-form prose, which makes it trivial to route tickets or flag anything the model marks as risky.
Step 4: Wire it into your email client
For Gmail, use the Gmail API's drafts.create endpoint to push Claude's output as a draft rather than sending it directly — the human agent opens Gmail, sees the pre-written draft, edits if needed, and hits send. For Outlook, the equivalent is the Microsoft Graph /messages draft endpoint. For helpdesks like Zendesk or Front, most have a "internal draft" or "suggested reply" field you can populate via their REST API.
A minimal Node.js version of the generation step:
async function generateDraft(threadText) {
const res = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SUBTOAPI_KEY}`,
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 400,
system: "You are a support reply assistant for Acme Co...",
messages: [{ role: "user", content: threadText }],
}),
});
const data = await res.json();
return data.content;
}
This function slots directly into a webhook handler: new email arrives → fetch thread → call generateDraft → write draft back to the mail client.
Step 5: Handle streaming for long replies
If your assistant drafts longer replies (e.g., detailed technical support), streaming the response lets you show the draft being written in real time in your internal tool rather than waiting for the full generation. See streaming docs for the event format if you want to build that UI.
Keep humans in the loop and measure quality
Log every generated draft alongside the final sent version (if edited). Diffing the two over time tells you where the prompt is weak — too formal, missing details, wrong tone for a specific customer segment — and gives you a dataset to refine the system prompt without guessing.
Why not call Anthropic directly?
You can, and for a single internal script that's fine. But once multiple people on your team are generating drafts, you'll want per-person or per-app API keys, usage caps, and a dashboard showing token spend — without building that tooling yourself. SubToAPI turns your Claude access into exactly that: scoped API keys, streaming, tool use, and usage metadata, with plans starting at €9/month on the pricing page and a free trial at signup.
FAQ
Does the assistant send emails automatically, or just draft them? Start with draft-only mode. Write Claude's output into the email client as a draft or internal note, and have a human approve before sending. Auto-send only for narrow, well-tested categories once you trust the output.
How much email history should I send to Claude? Include the last 5–10 messages in the thread, trimmed to remove quoted signatures and boilerplate. This keeps token usage low while giving Claude enough context to understand tone and unresolved questions.
Can I categorize and route emails with the same call that drafts the reply? Yes — use tool use to have Claude return a structured object with a category tag, a draft reply, and a needs_human_review flag in a single API call, instead of running separate classification and generation requests.