Operations setup

Connect `/api/leads` to the CRM and email stack

This page outlines the production workflow for routing every Beverly Hills Local Ledger form submission into a CRM, newsletter audience, internal notification system, and speed-to-lead follow-up process for Don Ashley.

Recommended architecture

Use `/api/leads` as the single intake point

The current endpoint validates name, email, and consent, creates a normalized lead object, writes the record to a local JSONL file for development, sends the record to a Zapier/Make-compatible webhook, and adds eligible newsletter or report contacts to Mailchimp. Production routing is controlled by environment variables, so the front-end forms stay stable.

CRM system of record

Send valuation, consultation, relocation, buyer, seller, and investor leads to the CRM first. The CRM should own pipeline stage, follow-up tasks, notes, and source attribution.

Email and newsletter

Send newsletter and report leads to Mailchimp or your email platform with tags for source page, offer title, audience segment, and consent status.

Automation layer

Use Zapier, Make, or a direct CRM API to send internal alerts, create follow-up tasks, update spreadsheets, and trigger confirmation emails without changing the front-end forms.

Implementation steps

Follow this sequence before going live

The fastest safe path is to deploy with required-mode disabled, prove the webhook and Mailchimp routing logic with test submissions, then decide whether failed delivery should block successful form responses.

1. Choose the destination stack

Start with one system of record, then add supporting systems. For speed, route all real estate leads to a CRM first, newsletter leads to Mailchimp, and backup every submission to Google Sheets or Airtable.

Action: Recommended launch stack: CRM + Mailchimp + Zapier/Make + Google Sheets backup.

2. Keep `/api/leads` as the intake endpoint

The website forms already post to `/api/leads`. Do not change every form. The API route now validates each submission, logs it locally for development, sends the normalized lead to the production webhook, and adds eligible contacts to Mailchimp.

Action: Configure `.env.example` values inside Vercel, then test webhook and Mailchimp results from the form response and hosting logs.

3. Map every field before sending data

Create a field-mapping table inside the CRM before deployment. This prevents lost attribution and makes follow-up automation more precise.

Action: Use `formType`, `source`, and `offerTitle` as mandatory routing fields.

4. Route by lead intent

Home valuation and consultation leads should create immediate sales tasks. Report and newsletter leads should enter nurture campaigns. Press, advertiser, and directory leads should go to separate non-sales pipelines.

Action: Set task priority from `formType` and `timeline`.

5. Add confirmation and notification emails

Every successful submission should receive a confirmation email. Don Ashley should receive an internal alert for high-intent leads, especially valuation, consultation, relocation, and neighborhood alert requests.

Action: Use a transactional email service or CRM workflow for confirmations and internal alerts.

6. Test each lead path before launch

Submit one test for every form type. Confirm the CRM record, email list segment, source field, consent status, internal notification, and follow-up task are correct.

Action: Do not publish paid traffic or outreach campaigns until each form route is verified end-to-end.

Field mapping

Map every form value into the CRM/email stack

The field map below is the operating standard for the current endpoint. Keep these names consistent so reporting, retargeting, segmentation, and follow-up rules stay clean as the platform expands beyond Beverly Hills.

FieldSourceCRM / Email DestinationOperating Note
idGenerated by APICRM external ID or custom fieldUse this for deduplication and audit history.
createdAtGenerated by APILead created dateKeep ISO format for clean sorting and automation rules.
formTypeLead form componentLead type, pipeline, tag, or lifecycle stageUse this to route valuation, consultation, newsletter, report, and press leads differently.
sourcePage/form locationOriginal source or campaign fieldPreserve the exact page source for attribution.
offerTitleCTA or report nameContent offer or conversion assetUseful for follow-up copy and segmentation.
nameRequired user fieldContact nameRequired before sending to CRM.
emailRequired user fieldContact emailValidated by the endpoint before submission.
phoneOptional user fieldMobile phoneUse for SMS only when compliant consent and business rules are confirmed.
addressOptional user fieldProperty addressHighest value for home-valuation and seller-intent workflows.
timelineOptional dropdown/inputBuying/selling timelineUse this to prioritize speed-to-lead follow-up.
consentRequired checkboxMarketing consent flagThe current API rejects submissions unless consent is true.
userAgentRequest headerTechnical attribution notesHelpful for debugging and bot/spam review.

Routing logic

Route leads by intent, not just by page

A Beverly Hills seller valuation request should not receive the same workflow as a newsletter signup. Use the `formType` field as the first routing rule, then refine by `source`, `offerTitle`, and `timeline`.

Form TypeDestinationPriorityAutomation
home-valuationSeller pipelineImmediateCreate task, send valuation intake email, notify Don Ashley, request property details.
consultationActive consultation pipelineImmediateSend booking link, create follow-up task, notify Don Ashley, start call-confirmation sequence.
reportMarket report nurtureMediumSend report link, tag by report slug, start seven-day education sequence.
newsletterMailchimp audienceLowSubscribe to Beverly Hills Weekly Brief and tag by signup source.
pressMedia inquiriesMediumSend press-kit response and notify media contact.
advertise / directory / partnerPartnership pipelineMediumSend media kit, create partner follow-up task, tag by package interest.

Developer handoff

Where to make the production change

The only required code change is inside the API route after the normalized `lead` object is created. The simplest production upgrade is to send that object to a secure webhook and let the automation layer distribute it to the CRM, Mailchimp, Google Sheets, and internal alerts.

Implemented integration call

// Implemented in src/app/api/leads/route.ts
// The endpoint calls src/lib/lead-integrations.ts after validation.
const webhookResult = await sendLeadWebhook(lead);
const mailchimpResult = await sendLeadToMailchimp(lead);

return Response.json({
  ok: true,
  leadId: lead.id,
  integrations: [webhookResult, mailchimpResult],
});

Store webhook URLs and API keys as environment variables in Vercel, Netlify, or your production hosting platform. Never hard-code private keys in the repository.

Environment variables

NEXT_PUBLIC_SITE_URL=https://donashleyrealty.com
LEAD_WEBHOOK_URL=https://hooks.zapier.com/hooks/catch/xxxxx/yyyyy
LEAD_WEBHOOK_REQUIRED=false
MAILCHIMP_API_KEY=replace-with-production-key
MAILCHIMP_AUDIENCE_ID=replace-with-audience-id
MAILCHIMP_REQUIRED=false
MAILCHIMP_ADD_ALL_LEADS=false

Use `.env.example` as the source of truth. If Zapier or Make handles distribution, the webhook URL may be enough for the first production release; Mailchimp can be enabled once the audience ID and API key are confirmed.

Testing checklist

Confirm the full lead journey before campaigns start

Treat this as a revenue-operations launch checklist. A form is not complete until the record lands in the right destination, the right follow-up triggers, and the source attribution is preserved.

QA checklist

  • Submit a test lead from every public form.
  • Confirm invalid email addresses are rejected before CRM submission.
  • Confirm consent is required before any marketing workflow starts.
  • Confirm duplicate email logic does not erase original source attribution.
  • Confirm high-intent leads create internal notifications within five minutes.
  • Confirm newsletter-only leads do not enter aggressive sales automation.
  • Confirm production environment variables are set in the hosting platform.
  • Confirm `donashleyrealty.com/sitemap.xml` and lead forms work after deployment.

Speed-to-lead rule

High-intent leads should create immediate action

Seller valuation, consultation, relocation, and neighborhood-alert requests should trigger an internal alert and a same-day follow-up task. Newsletter and general report downloads can enter nurture first, but every lead should keep its original source and content-offer history.