AI-powered email draft assistant built on Cloudflare’s developer platform. Try it yourself: https://cf_ai_jz.justinzhang20711.workers.dev
cf_ai_email_workflow lets a user:
- Paste a resume and target job URL.
- Kick off a Cloudflare Workflow that:
- Fetches the job description from the URL.
- Calls Workers AI to generate a tailored, professional email draft.
- Persists the latest draft and a history of drafts.
- Iteratively refine the draft by sending feedback; each feedback round produces a revised email via the same Workflow.
- View and load past drafts from history.
The app is a single-page React UI talking to a Workers backend over JSON routes.
- React + TypeScript SPA, built with Vite.
- Deployed as static assets under
frontend/distand served by the Worker using theassets.directoryconfiguration inwrangler.jsonc. - UI features:
- Resume + job URL form.
- Live draft panel with status chip.
- Feedback box for incremental refinement.
- Past drafts panel populated from Durable Object storage.
-
Cloudflare Worker
- REST endpoints:
POST /start– create a new Workflow instance for a given resume and job URL.POST /feedback– send auser_feedbackevent to an existing Workflow.GET /status– query Workflow instance status.GET /get-latest-draft– fetch the latest email draft text.GET /list-drafts– fetch a JSON map of past drafts.
- Typed
Envbindings for:STATE: Durable Object namespace.EMAIL_WORKFLOW: Workflow binding.AI: Workers AI binding.
- REST endpoints:
-
Cloudflare Workflows
- Durable, multi-step orchestration for:
- Fetching and slicing the job posting HTML.
- Generating an initial email using a Workers AI LLM.
- Persisting drafts via the Durable Object.
- Waiting for
user_feedbackevents and revising the email until the user signals completion.
- Makes use of
step.doandstep.waitForEventto cleanly separate external calls and long-lived waits.
- Durable, multi-step orchestration for:
-
Durable Objects
- Stores:
"latest-draft"– the most recent email.- Timestamped keys like
"draft:<ISO timestamp>"– history entries with{ draft, createdAt }.
- Exposes:
POST /store-latest-draft– update latest draft + append history.GET /get-latest-draft– read latest draft.GET /list-drafts– list all drafts as a JSON object for the UI.
- Stores:
-
Workers AI
- Uses a hosted LLM (e.g.
@cf/meta/llama-3.1-8b-instruct) viaenv.AI.run. - Prompts:
- Initial: “Write a short professional job application email. Job: … Resume: …”
- Revision: “Revise this email based on this user feedback: …”
- Uses a hosted LLM (e.g.
