"We want to delegate initial customer support triage to AI," "We want to send tailored sales follow-up emails"—inquiries like these increased further starting in late April. One catalyst was Cloudflare releasing its inbound and outbound service for AI agents, Cloudflare Email Service, in public beta. By offloading email infrastructure operations—including SPF, DKIM, and DMARC—to Cloudflare, agent developers can concentrate on reading, writing, and categorizing emails via tool calls. This has suddenly emerged as a practical solution for custom development projects.
This article outlines essential design points for custom development projects turning email workflows into agent systems, along with implementation patterns that incorporate human-in-the-loop (HITL) reviews.
Why "Email × AI Agents" is surging again right now
While email automation might seem like a legacy topic, the context in 2026 differs decisively from past RPA trends.
| Dimension | Traditional RPA | Agent era |
|---|---|---|
| Starting point | Human-defined workflows | Natural language goals |
| Exception handling | Humans enumerate branches | Agents assess context |
| Email authentication | Configuring SPF/DKIM in-house | Abstracted by Cloudflare |
| Auditing | Aggregating logs separately | Tool calls form structured logs |
Particularly when sending emails directly from agents, failures in authentication headers carry the risk of damaging overall company-wide deliverability. Cloudflare Email Service manages this complexity, providing clear boundaries of responsibility when building client solutions.
The "use-case-aggregated model" we detailed in design patterns for turning existing SaaS APIs into MCP servers also pairs exceptionally well with email infrastructure.
Overall architectural picture
The standard architecture our firm adopts in client projects is organized across the following four layers.
- Cloudflare Email Service — Outbound email API, inbound routing, SPF/DKIM/DMARC management
- Workers AI / External LLM — Email categorization, summarization, reply draft generation
- MCP server (internal) — Domain-specific tools for agents (customer lookups, project queries, etc.)
- HITL UI — Approval interface in Slack or internal portals
The agent executes the sequential workflow of "inbound trigger → content comprehension → reply draft generation → approval → sending" by calling multiple tools in turn.
Inbound: Deconstructing incoming mail
Incoming mail must not be passed directly to LLMs. Doing so inflates tokens and leads to misunderstandings caused by attachments and signatures. Deconstruct incoming emails across three stages within Cloudflare Workers Email Routing before passing them along.
export default {
async email(message, env) {
const parsed = await parseEmail(message);
const enriched = {
from: parsed.from,
subject: parsed.subject,
thread_summary: await summarizeThread(parsed.history),
latest_body_text: stripQuotedText(parsed.body),
attachments: parsed.attachments.map((a) => ({
name: a.name,
type: a.contentType,
text_preview: a.text?.slice(0, 500),
})),
};
await env.AGENT_QUEUE.send(enriched);
},
};
The key principles are threefold:
- Compress past threads into summaries (lengthy quotes confuse AI)
- Strip out quoted content from the body (pass only the latest message)
- Include only text previews and metadata for attachments (avoid passing massive files directly)
Outbound: Embedding HITL into tool definitions
Sending emails is an external and irreversible action. Maintain an approval-pending state on the MCP tool side, requiring confirmation in the UI prior to final dispatch.
server.tool("send_business_email", async (args, ctx) => {
if (!ctx.userApproved) {
return {
kind: "approval_required",
preview: {
to: args.to,
subject: args.subject,
body_md: args.body_md,
},
approval_token: issueApprovalToken(args),
};
}
return await cloudflare.email.send({
from: env.SENDER_ADDRESS,
to: args.to,
subject: args.subject,
text: args.body_text,
html: renderHtml(args.body_md),
headers: { "Reply-To": args.reply_to ?? env.REPLY_TO },
});
});
As noted in our guide to integrating Anthropic Computer Use into business workflows, defaulting to "two-step calls + approval tokens" is the safest approach for external actions.
Pitfalls of authentication headers (SPF/DKIM/DMARC)
While Cloudflare abstracts away most details, clients must configure the following three points when sending from their own domains in client projects.
| Item | Configuration target | Important precautions |
|---|---|---|
| SPF | DNS (custom domain) | Watch for include conflicts with existing MTAs and SaaS platforms |
| DKIM | DNS (Cloudflare-provided keys) | Key rotation is automated, but review TTL settings |
| DMARC | DNS (internal company policy) | Recommend p=quarantine or higher, aggregate reports via rua |
Companies already using Marketing Cloud or HubSpot frequently run up against the SPF record 10-lookup limit. Checking existing SPF records with dig during initial discovery interviews is an ironclad rule for client projects.
Initial design patterns by use case
Here are three use cases in email and agent projects that can be launched quickly.
A. First-line inquiry response agent
- Classifies incoming mail into three categories (answerable via FAQ / handover to sales / urgent escalation)
- Auto-replies only to FAQ inquiries, sending assignment alerts to team members for others
- Demonstrates clear outcomes and can be deployed as an MVP in 4 to 6 weeks
B. Sales follow-up agent
- Triggered by CRM deal status changes, generating follow-ups that avoid sounding templated
- Always requires sales reps to review via HITL before sending
- Proven to reduce rep workload by 3 to 5 hours per week in production
C. Personalizing notification delivery
- Appends situational AI remarks to standard transactional emails (invoices, shipping notices, renewals)
- Boosts open rates by running segment-level A/B tests
Combining this with our customer touchpoint design using Multimodal AI × MCP allows solutions to scale into omnichannel client projects spanning email, chat, and voice.
Kickoffs should anchor measurable metrics in PoC
Rather than aiming for full automation from the start, testing on narrow use cases—such as first-line triage or follow-up delivery—makes it easier to agree on metrics like reply rates, turnaround times, and zero misdirection, smoothing expansion into production. Timelines depend on scope: an MVP for initial inquiry triage can take several weeks, while broader platform integration covering CRM syncing and DMARC migrations is best delivered in phases.
Summary — Moving past the assumption that email operations require humans
Email workflows historically assumed humans would handle each message individually. Combining Cloudflare Email Service with MCP enables a new division of labor where "agents prepare drafts up to the final stage, while humans focus solely on judgment and approval."
How much to delegate to agents, where to retain human approvals, and how to handle existing SPF/DMARC configurations—the optimal design for all of these issues depends on each project's current state. Even if you are simply at the stage of feeling overwhelmed by customer inquiries or struggling to keep up with sales follow-ups, we can review your existing architecture and map out a path forward together. Please get in touch via our contact form.








