Phase 2A Lead Capture — Smoke Test Runbook
Pre-deploy
- [ ] All Phase 2A commits merged to main
- [ ]
LEAD_CAPTURE_ENABLED=falseset in production env (we will enable after smoke test stabilizes)
Deploy
# 1. Run migration (additive only — safe to run)
sudo -n bash -c 'docker exec -i huph-postgres psql -U huph -d huph < /opt/huph/scripts/migrate-leads-phase2a.sql'
# 2. Verify schema
sudo -n docker exec huph-postgres psql -U huph -d huph -c "\d leads" | grep -E "channel|registration_id|user_role|captured_via|notified_at"
# 3. Build and deploy api
cd /opt/huph
sudo -n docker compose build huph-api
sudo -n docker compose up -d --no-deps huph-api
# 4. Wait for healthy
sleep 30
sudo -n docker ps --filter name=huph-api --format "{{.Status}}"
# 5. Build and deploy admin (if applicable)
sudo -n docker compose build admin
sudo -n docker compose up -d --no-deps admin
Smoke test phase 1: LEAD_CAPTURE_ENABLED=false (sanity baseline)
- [ ]
curl http://localhost:3101/healthreturns 200 - [ ]
curl http://localhost:3101/api/v1/leads/v2/summaryreturns{success: true, summary: {...}} - [ ] Visit
/admin/leads-v2in browser → empty state shown - [ ] WhatsApp test: send "halo" via test number → bot replies normally (no extraction logic should run)
Enable lead capture
echo "LEAD_CAPTURE_ENABLED=true" | sudo tee -a /opt/huph/.env
sudo -n docker compose up -d --no-deps huph-api
sleep 15
Smoke test phase 2: capture enabled
- [ ] WhatsApp test: send "saya mau daftar" via test number
- Bot replies with "Wah keren!... boleh tau dulu nama kamu?"
- Check
/admin/leads-v2→ no row yet (waiting for name) - [ ] Reply "Budi Santoso"
- Bot replies with CTA langkah 1-6 + email ask
- Check
/admin/leads-v2→ row withfull_name: Budi Santoso, statusnew(because WA auto-phone is set) - [ ] Reply "budi@gmail.com"
- Bot replies with summary "Sip Budi! ✅ ..."
- Check
/admin/leads-v2→ status promoted toqualified - [ ] Webchat test (https://webchat.huph.val.id):
- Same flow but uses
'web'channel — should create a row with NO phone (web doesn't auto-fill) - [ ] Inspect logs for any
[leadCapture]errors:
sudo -n docker logs huph-api --since 10m 2>&1 | grep -i leadcapture
Expected: only the standard "[leadCapture] X failed (continuing)" lines from intentional defensive try/catch — no surprises.
Validation period (24-48h)
- [ ] Monitor
intent_classifications_logandleadstable for normal flow:sudo -n docker exec huph-postgres psql -U huph -d huph -c "SELECT status, COUNT(*) FROM leads GROUP BY status;" - [ ] Sample 10 captured leads manually for accuracy:
sudo -n docker exec huph-postgres psql -U huph -d huph -c "SELECT full_name, phone, email, status, source FROM leads ORDER BY created_at DESC LIMIT 10;" - [ ] Check log volume — should not exceed 10x baseline
Rollback if needed
# Set env var to disable
sudo sed -i 's/LEAD_CAPTURE_ENABLED=true/LEAD_CAPTURE_ENABLED=false/' /opt/huph/.env
sudo -n docker compose up -d --no-deps huph-api
(No DB rollback needed — migration is additive.)
Cutover (after validation passes)
- [ ] Move legacy
/admin/leadsto/admin/lead-pipeline - [ ] Rename
/admin/leads-v2→/admin/leads - [ ] Add redirect
/admin/lead-pipelinefor legacy bookmarks