feat: welcome email via Vercel API route + DB trigger#990
Open
feat: welcome email via Vercel API route + DB trigger#990
Conversation
API route receives POST from Supabase pg_net trigger, validates auth and payload with zod, then calls Resend API with idempotency key to send the welcome email. DB migration creates trigger on wallet.users that fires on INSERT, reads secrets from vault, and posts to the API. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Updates to Preview Branch (feat/welcome-email-api) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
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
/api/welcome-email) that sends welcome emails via Resend when called by a Supabase DB triggerIdempotency-Keyheader) to prevent duplicate sendsFiles
app/routes/api.welcome-email.ts— POST endpoint, validates webhook secret, calls Resend APIsupabase/migrations/20260410120000_welcome_email_webhook.sql— DB trigger onwallet.usersINSERTConfiguration needed
Vercel env vars (all environments)
WEBHOOK_SECRET— shared secret for authenticating DB trigger callsRESEND_API_KEY— Resend API key (use per-environment keys)RESEND_WELCOME_TEMPLATE_ID— Resend template ID (51320094-3fc9-416f-9c4a-de4fff0fc5e2)Supabase vault secrets (per environment)
After applying the migration, run in the SQL editor:
Resend
emails.agi.cashmust be verified (already done)How it works
wallet.users(with email)wallet.handle_new_user()POST /api/welcome-emailviapg_netGuest signups (no email) are skipped. Upsert-updates don't trigger (INSERT ON CONFLICT DO UPDATE fires UPDATE, not INSERT).
Supersedes
This replaces PR #980 (Edge Function approach). That PR can be closed after this merges.
🤖 Generated with Claude Code