Read, classify, and auto-reply to incoming emails with AI-driven classification and outreach drafting.
You are an email operations copilot for early-stage teams. Core workflows: 1) Send intro email: draft concise outreach and call send_intro_email. 2) Review inbox: call read_inbox when user asks to check responses. 3) Auto-reply: call auto_reply to answer the latest inbound or a provided message ID. Rules: - Keep responses concise and execution-focused. - Do not invent product claims or customer facts. - If required input is missing (recipient or user intent), ask one targeted question. - After each send_intro_email call, respond with one short status line. - If any tool returns a failure payload, explain what to fix in plain language.
import { agent, tool } from "@agent-sdk"
import { z } from "zod"
const sendIntroEmailInput = z.object({
to: z.string().email(),
subject: z.string().min(3).max(200),
text: z.string().min(10),
html: z.string().optional(),
})
const readInboxInput = z.object({
limit: z.number().int().min(1).max(50).optional(),
})
const autoReplyInput = z.object({
text: z.string().min(3),
html: z.string().optional(),
messageId: z.string().optional(),
replyAll: z.boolean().optional(),
})
export default agent({
model: "claude-sonnet-4-6",
permissionMode: "bypassPermissions",
maxTurns: 12,
systemPrompt: `...`, // see System Prompt section above
tools: {
send_intro_email: tool({
description: "Send an intro/outreach email",
inputSchema: sendIntroEmailInput,
execute: async ({ to, subject, text, html }) => {
// POST to /v0/inboxes/{id}/messages/send
},
}),
read_inbox: tool({
description: "Read recent inbox messages",
inputSchema: readInboxInput,
execute: async ({ limit = 10 }) => {
// GET /v0/inboxes/{id}/messages?limit={limit}
},
}),
auto_reply: tool({
description: "Auto-reply to latest inbound or specific message",
inputSchema: autoReplyInput,
execute: async ({ text, html, messageId, replyAll }) => {
// POST /v0/inboxes/{id}/messages/{messageId}/reply
},
}),
},
})AGENT_API_KEYServer-side API key for token exchangeAGENTMAIL_API_KEYAgentMail API key for sending and reading emailsAGENTMAIL_INBOX_IDYour AgentMail sender inbox IDAutomate client outreach, inbox triage, and follow-ups. Most businesses spend 15+ hours/week on email ops.