Skip to content

WIP: rewrite email-agent for Cloudflare Email Service#1279

Draft
whoiskatrin wants to merge 3 commits intomainfrom
rewrite-email-agent-email-service
Draft

WIP: rewrite email-agent for Cloudflare Email Service#1279
whoiskatrin wants to merge 3 commits intomainfrom
rewrite-email-agent-email-service

Conversation

@whoiskatrin
Copy link
Copy Markdown
Contributor

@whoiskatrin whoiskatrin commented Apr 9, 2026

Summary

This PR rewrites the examples/email-agent example around Cloudflare Email Service instead of the older worker-only email routing flow. It turns the example into a full-stack app with a React UI, outbound email sending through the Workers Email binding, inbound routing into an agent, and synced mailbox state that makes the end-to-end flow easier to understand and demo.

What Changed

  • Replace the worker-only examples/email-agent implementation with a full-stack Vite + React example.
  • Add an agent-backed UI for sending outbound email, simulating inbound mail locally, viewing inbox/outbox activity, and toggling auto-replies.
  • Move the worker entrypoint to src/server.ts and add src/client.tsx, src/styles.css, index.html, vite.config.ts, and a small public favicon.
  • Use env.EMAIL.send() for outbound email and keep routeAgentEmail() for inbound delivery into the agent.
  • Parse inbound messages with postal-mime, store recent mailbox activity in agent state, and optionally use EMAIL_SECRET for signed replies via replyToEmail().
  • Update docs/email.md, docs/agent-class.md, docs/getting-started.md, docs/index.md, and the root README.md to use Cloudflare Email Service terminology and setup guidance.
  • Rewrite the example README to document the new local flow, deployment steps, and routing model.
  • Remove the old ad hoc test scripts and the previous worker-only example files that no longer match the new example shape.
  • Replace the concrete default sender address with the neutral example address mailbox-7f3a@example.com in config, generated types, UI defaults, and docs.

Why

The previous example showed only part of the email story and still used older Email Routing language. This rewrite makes the example line up with the current Cloudflare Email Service model, gives users a runnable full-stack demo, and documents the exact pieces needed for both outbound sends and inbound agent routing.

Validation

  • Created commits for the example rewrite and the follow-up generic-address cleanup.
  • Ran npm run check.
  • npm run check did not complete cleanly because of existing repo-level warnings from sherif and because oxfmt --check picked up an untracked local .tmp-playwright-report/ directory that is not part of this PR.

Reviewer Notes

  • The email example now depends on EMAIL_FROM being a verified sender address in Cloudflare Email Service.
  • EMAIL_SECRET is optional. Without it, the example still works, but follow-up replies fall back to address-based routing instead of signed secure reply routing.
  • The local /api/simulate-email endpoint is only a development helper to exercise the inbound path before real routing is configured.

Reviewers

  • Specific reviewer handles were not provided, so no reviewer handles are listed here yet.

Replace the worker-only email routing demo with a full-stack app that shows outbound sends, inbound routing, and synced mailbox state. Update the docs to reflect Email Service terminology and setup.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: b34fc73

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Replace the concrete inboxbuddy.dev mailbox in the email-agent example with a neutral example address. This keeps the sample configuration and docs from pointing at a specific mailbox.
@whoiskatrin whoiskatrin changed the title WIP: rewrite email-agent for Email Service WIP: rewrite email-agent for Cloudflare Email Service Apr 9, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1279

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1279

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1279

hono-agents

npm i https://pkg.pr.new/hono-agents@1279

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1279

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1279

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1279

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1279

commit: ee716a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant