Skip to content

Replies by email, step 1: unread replies are emailed to visitors who have left (ADR-0029) - #221

Open
yatping wants to merge 3 commits into
adr/0029-email-repliesfrom
feat/reply-emails
Open

yatping wants to merge 3 commits into
adr/0029-email-repliesfrom
feat/reply-emails

Conversation

@yatping

@yatping yatping commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Step 1 of ADR-0029, on top of that PR.

What it does

  • A public reply from a member or the AI assistant, in a website conversation, is emailed to the visitor if they gave an email address and have not read it.
  • Whether is decided by the visitor's read cursor. When is decided by their connection: about a minute after the reply with no socket open, at the end of the workspace's wait (5 minutes) with one.
  • Replies sent close together share one email. It never holds an internal note or what the visitor wrote, because the address is unproven.
  • On by default. Supervisors get a switch and the wait on the Email tab. The widget says under its email field that replies are emailed, only where they are.
  • A follow-up is skipped when its last message already went by email.
  • At most 20 reply emails a day for a conversation and 50 for an address.

Answers to the email are not received yet: that is step 2. The email says so.

Changes

  • Migration 0044, additive: two workspace settings, two conversation columns, two indexes. Sets reply_emailed_seq on existing conversations so nothing old is emailed.
  • Job email.reply_check on oc-email, swept every minute.
  • GET/PUT /workspaces/{id}/reply-emails, and replyEmails on the widget bootstrap. No API minor.
  • Dashboard panel, widget hint and the email's fixed words in 11 languages, machine-translated like the rest.
  • Guide, privacy guide, known issues, security, background jobs, data model, amendment A16.

Checked

  • pnpm lint, typecheck, build, and the contracts, migrations, licences, budget, secrets and channel checks pass.
  • Unit and API tests pass, with 17 new ones in reply-emails.test.ts, and the isolation test covers both new routes.
  • Playwright: all 108 pass, with a new test for the switch and a check of the widget hint.

On real Cloudflare

Five real emails from a throwaway installation, since removed, to an outside Gmail address. From D1:

  • No socket: emailed 2 minutes after the reply. Two quick replies shared one email.
  • Socket held open: held back, then emailed 6 minutes after the reply, at the end of the 5-minute wait.
  • Reply marked read: nothing sent.
  • Cloudflare returns each email's Message-ID, so a second commit adds In-Reply-To and References; an email with them was accepted and sent.

Details, and two things learned (a new Worker's cron took 8 minutes to start; oc deploy --cloudflare-email stopped at its own check), are in cloudflare-validation.md.

Not checked

  • How the emails look in the mailbox, and whether Gmail keeps them in one thread: for the owner to look at.
  • The translations have had no native review.
  • The owner's legal check of sending without the tick box. Cloud's privacy policy v8 and DPA v7 are drafted in OpenChat-website M1b: load test on real D1, and fixes from it #29.

🤖 Generated with Claude Code

yatping and others added 3 commits December 4, 2026 21:47
…have left (ADR-0029)

A public reply from a member or the assistant on the website schedules a check a
minute later. The visitor's read cursor decides whether an email goes; whether
they still have a socket decides when: at once without one, at the end of the
workspace's wait with one. Replies sent close together share an email, which
never holds an internal note or what the visitor wrote.

On by default, with a supervisor's switch and wait on the Email tab. The widget
says under its email field that replies are emailed. Migration 0044.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Patrick Ng <yatping0617@gmail.com>
…udflare check

Cloudflare returns each email's Message-ID, so a reply email carries In-Reply-To
and References. Five real emails were sent from a throwaway installation: no
socket, a held socket, a read reply, and one with the thread headers.

ADR-0029: an answer from another address is accepted, by the owner.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Patrick Ng <yatping0617@gmail.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Patrick Ng <yatping0617@gmail.com>
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