A small agent that runs as a Vercel serverless function. When Supabase sends a database webhook (on row INSERT), this endpoint receives the payload and sends an email via Resend with a summary of the change.
Compact project context for tools and contributors: SKILL.md (also make skill).
Dependencies are managed with uv (uv.lock + pyproject.toml). Install uv first if needed: curl -LsSf https://astral.sh/uv/install.sh | sh or brew install uv. To refresh locked versions: uv lock --upgrade then uv sync, commit uv.lock, and run make export-requirements before deploy so requirements.txt matches.
make install # uv sync — install dependencies into .venv
make env # copy .env.example → .env.local (then edit with your keys)
make dev # run locally at http://localhost:3000
make ping # health check (with dev server running)
make test-webhook # send a sample POST payload (local)
make deploy # deploy to Vercel
make ping-prod # test production deploymentRun make help for all targets.
- Sign up at resend.com and create an API key.
- Add your domain and verify it if you want a custom "from" address; otherwise you can use
onboarding@resend.devfor testing.
- Local: Run
make env, then edit.env.localwith your values. - Vercel: Project → Settings → Environment Variables.
| Variable | Required | Description |
|---|---|---|
RESEND_API_KEY |
Yes | Your Resend API key |
RESEND_TO_EMAILS |
Yes | Comma-separated recipient emails |
RESEND_FROM_EMAIL |
No | From address (default: onboarding@resend.dev) |
RESEND_FROM_NAME |
No | From display name |
SUPABASE_WEBHOOK_SECRET |
No | If set, requests must send this in Authorization: Bearer <secret> |
make deployNote the deployed URL (e.g. https://agent-supabase-resend-py.vercel.app). Configure it in Supabase as the webhook URL.
- In the Supabase Dashboard, open your project.
- Go to Database → Webhooks (or Project Settings → Database → Webhooks).
- Click Create a new webhook.
- Configure:
- Name: e.g.
Email on change - Table(s): e.g.
public.orders - Events: INSERT, UPDATE, and/or DELETE
- HTTP Request
- Method: POST
- URL:
https://your-project.vercel.app/api/webhook - Headers (optional): if you set
SUPABASE_WEBHOOK_SECRET, addAuthorization: Bearer your_shared_secret
- Name: e.g.
Supabase sends a JSON body like:
{
"type": "INSERT",
"table": "orders",
"schema": "public",
"record": { "id": 1, "email": "user@example.com", ... },
"old_record": null
}The agent turns this into an email and sends it via Resend to RESEND_TO_EMAILS.
- Python 3.12+, uv, and the Vercel CLI (
npm i -g vercel) are required formake dev. - Install uv:
curl -LsSf https://astral.sh/uv/install.sh | shorbrew install uv. - If you don’t have Python 3.12:
uv python install 3.12(uv can fetch a matching interpreter).
make devThen open http://localhost:3000 (root returns service info). Use make ping and make test-webhook against the local server. For Supabase to hit your machine, use a tunnel (e.g. ngrok).
make dev loads .env.local into the environment before starting Vercel. If you see "RESEND_API_KEY is not set", check that .env.local exists, contains RESEND_API_KEY=your_key (no spaces around =), and restart the dev server.
Production URL is set in the Makefile as DEPLOY_URL (default: https://agent-supabase-resend-py.vercel.app).
make ping-prod # GET / and GET /api/webhook (health)
make test-webhook-prod # POST sample payload (sends email if Vercel env vars are set)Override the URL: DEPLOY_URL=https://your-app.vercel.app make ping-prod.
- Tests:
make test(pytest) - Coverage:
make coverage(pytest with terminal report),make coverage-report(addshtmlcov/for browser) - Lint:
make lint(ruff check),make lint-fix(auto-fix),make format(ruff format) - Pre-commit: Run
make pre-commitonce to install hooks; thengit commitwill run ruff (check + format) automatically. Pytest runs in CI only.
CI runs on push/PR (see .github/workflows/ci.yml): ruff check, ruff format --check, pytest with coverage.
| Method | Path | Description |
|---|---|---|
| GET | / |
Service info (rewrites to /api) |
| GET | /api |
Same as / |
| GET | /api/webhook |
Health check |
| POST | /api/webhook |
Supabase database webhook → sends email via Resend |