- Go to https://vercel.com/terryroach/website
- Click Storage in the left sidebar
- Click Create Database → choose KV
- Name:
plausibleba-leads - Region: pick closest (e.g., US East / SFO)
- Plan: Hobby (free) — 30K requests/month
- Click Create → then Connect to Project → select
website - This auto-adds
KV_REST_API_URLandKV_REST_API_TOKENto your env vars
- Go to https://vercel.com/terryroach/website/settings/environment-variables
- Click Add Environment Variable
- Name:
LEADS_API_KEY - Value: (pick something random, e.g.
pba-leads-2026-xyz123) - Environment: All Environments
- Save
- Go to https://sheets.google.com → Create new spreadsheet
- Name it:
PlausibleBA Leads - In Row 1, add these headers:
Timestamp | First Name | Last Name | Email | Generation # | Source
- In the sheet, go to Extensions → Apps Script
- Delete any existing code in
Code.gs - Paste this:
function doPost(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
sheet.appendRow([
data.timestamp || new Date().toISOString(),
data.firstName || '',
data.lastName || '',
data.email || '',
data.generation || '',
data.source || 'canvas'
]);
return ContentService
.createTextOutput(JSON.stringify({ status: 'ok' }))
.setMimeType(ContentService.MimeType.JSON);
}- Click Deploy → New deployment
- Type: Web app
- Execute as: Me
- Who has access: Anyone
- Click Deploy
- Copy the web app URL (looks like
https://script.google.com/macros/s/AKfyc.../exec)
- Go to https://vercel.com/terryroach/website/settings/environment-variables
- Add:
GSHEET_WEBHOOK_URL= (paste the Apps Script URL from above) - Save
Push the updated generate.ts and new leads.ts to the main branch.
The redeploy will pick up the new env vars automatically.
- Go to
https://www.plausibleba.com/canvasand do a test generation - Check the Google Sheet — a new row should appear
- Check
https://www.plausibleba.com/api/leads?key=YOUR_LEADS_API_KEY— should show the test lead in JSON
- Vercel KV: Reliable rate limiting (3 gens per email, survives cold starts)
- a sorted index of all users for the
/api/leadsendpoint
- a sorted index of all users for the
- Google Sheet: Human-friendly lead list, updated in real-time, viewable from your phone
/api/leads?key=...: JSON endpoint you can hit from anywhere to see all leads, sorted by most recent
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY |
Claude API key (already set) |
KV_REST_API_URL |
Vercel KV endpoint (auto-added by KV setup) |
KV_REST_API_TOKEN |
Vercel KV auth token (auto-added by KV setup) |
LEADS_API_KEY |
Protects the /api/leads endpoint |
GSHEET_WEBHOOK_URL |
Google Apps Script web app URL |