Replace MailerSend template sprawl with a repo-owned render endpoint - #1065
Draft
hturnbull93 wants to merge 1 commit into
Draft
Replace MailerSend template sprawl with a repo-owned render endpoint#1065hturnbull93 wants to merge 1 commit into
hturnbull93 wants to merge 1 commit into
Conversation
Airtable's onboarding automation sent every welcome email via one of 7
hand-authored MailerSend templates, hardcoding chapter links/leaders that
already drift from the live National Groups data, and only distinguishing
volunteer vs non-volunteer recipients. Adds a render endpoint that composes
subject/html/text from live chapter data, the recipient's actual intent
(act-now/keep-informed/volunteer/lead), and language - so new chapters and
languages no longer need a new MailerSend template + script branch.
- src/lib/server/onboardingEmail/ - chapter lookup (reuses the National
Groups fetch), intent/language copy, HTML + plain-text renderers
- src/routes/api/onboarding-email - bearer-secret POST endpoint returning
{subject, html, text}; render-only, never sends mail itself
- src/routes/api/unsubscribe - suppresses on both MailerSend domains and
flips the Members "Email subscription" checkbox; no unsubscribe
mechanism existed in any of the 7 templates before this
- src/routes/onboarding-email-preview - dev-only QA page, 404s outside dev
- airtable-mailersend-emails.js - tries the new endpoint first, falls
through to the untouched template_id logic on any failure
- email-templates/ - raw MailerSend payloads for all 7 templates, kept as
migration reference and to document the old routing gaps (Canada-FR was
unreachable in practice; Lead hands off via mailto instead of a form
submission)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtQwhn5Fb9eiC4LsmRs47q
👷 Deploy request for pauseai pending review.Visit the deploys page to approve it
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the 7 hand-authored MailerSend templates driven by
airtable-mailersend-emails.jswith a repo-owned render endpoint, matrixed on intent × chapter × language instead of one template ID per combination. Chapter content (leader, links) now comes live from the same Airtable "National Groups" data/api/national-groupsalready uses, instead of being hand-copied per template and drifting out of date.src/lib/server/onboardingEmail/— chapter lookup, intent copy (act-now / keep-informed / volunteer / lead), language handling (en/es/fr), HTML + plain-text rendererssrc/routes/api/onboarding-email— bearer-secret POST endpoint, returns{subject, html, text}. Render-only — never sends mail itself, never touches the MailerSend API key.src/routes/api/unsubscribe— new. No unsubscribe mechanism existed in any of the 7 templates before this (MailerSend'sunsubscribe_rate: 0reflected "no link offered," not "no one wants out"). Flips the MembersEmail subscriptioncheckbox and suppresses on both MailerSend domains.src/routes/onboarding-email-preview— dev-only QA page (404s outsidedev), renders a sample of intent × chapter × language combos.airtable-mailersend-emails.js— tries the new endpoint first; on any failure (network error, timeout, non-OK response, missing fields) falls through to the originaltemplate_idlogic, byte-for-byte unchanged. Worst case is today's behavior.email-templates/— raw MailerSend payloads for all 7 old templates, kept as migration reference and to document routing gaps found along the way (CANADA_FR_TEMPLATEwas unreachable in practice —languagesis always empty at send time;Leadintent normally hands off via amailto:link rather than a form submission, perdocs/join-form-flow.md).Please manually check / review / adjust
eslocale exists elsewhere in the codebase, and the old Spanish template only ever covered the volunteer case. Needs a native/fluent Spanish speaker from the org to read it.messages.ts) uses informal tu; the old Canada-FR MailerSend template used formal vous. Matched vous to stay consistent with the reviewed body copy — meaning the email doesn't literally echo the join form's wording. Confirm that's the right call./onboarding-email-previewand confirm the new subject is acceptable.NationalGroup/Airtable)./onboarding-email-previewlocally and look at real rendered output — only agent/automated smoke-testing has happened so far, no human has eyeballed it.Pre-merge / pre-launch checklist
ONBOARDING_EMAIL_RENDER_SECRETandMAILERSEND_API_KEYin prod (Netlify env vars) — both currently placeholder-only in.env(gitignored, no real values committed).Onboarding email render secret) and the optionalrender_endpoint_urloverride in the Airtable automation's script input config panel — the script references these by name but Airtable-side mapping isn't part of this repo.template_id) sends get any automatic unsubscribe-footer/compliance injection. Docs suggest that's template-engine-only, so the shell here builds its own unsubscribe link + physical address (Box C5957, Kwikstaartlaan 42, 3704GS Zeist, The Netherlands) — never got a definitive answer from MailerSend, worth chasing before this goes live.🤖 Generated with Claude Code
https://claude.ai/code/session_01GtQwhn5Fb9eiC4LsmRs47q