Deliverable-Type: integration-runbook
Title: ZIION Funnel <-> Sovereign CRM Integration Runbook
## Integration: ZIION funnel pages -> Sovereign CRM
Systems and direction: ZIION funnel pages (Supabase edge function `funnel-submit`) -> Sovereign CRM `contacts` + `events` tables. Direction: one-way write on submit; CRM never writes back to the funnel page.
### Field-mapping table
| source field | destination field | transform |
|---|---|---|
| form.email | contacts.email | lowercase + trim |
| form.name | contacts.full_name | trim |
| form.utm_source | events.attribution_source | passthrough |
| form.self_reported_source | events.self_reported_attribution | passthrough (Chris Walker field) |
Auth method: Supabase service role key referenced via env var `SUPABASE_SERVICE_ROLE_KEY` (never inline); edge function reads it from the Vercel/Mac Mini environment at runtime.
Sync frequency/trigger: real-time, fires on every funnel form submit event (webhook, not polled).
Dedupe rule: match on lowercased email first; if no match, match on phone (E.164 normalized); on conflict, the most recently active record wins survivorship and the older row is merged/archived, never duplicated.
Failure/retry behavior: on write failure, the edge function retries 3x with exponential backoff (1s/4s/16s), then writes to a `sync_failures` dead-letter table and alerts the on-call channel.
Rollback procedure: to roll back a bad sync, restore the affected `contacts` rows from the nightly Supabase point-in-time backup and replay `events` from the `sync_failures` dead-letter table after the fix ships.