This site is not affiliated with or endorsed by Vercel, Inc. Read the docs, then deploy or run each experiment yourself.
AI

Form to CRM Lab

Lead form - Zod validate - AI enrich (companyGuess, urgency) - Neon insert or memory - optional outbound webhook.

Run this experiment yourself

Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.

Local development

cd apps/experiments/form-to-crm-lab
pnpm install
pnpm dev

Then open http://localhost:3010.

This is an experimental demo. Use it as a starting point for your own projects.

Form to CRM Lab accepts a lead form, validates with Zod, enriches via generateObject (companyGuess, urgency), then inserts into Neon when DATABASE_URL is set. Without Postgres it keeps an in-memory list and shows a UI note. Optionally POSTs the lead to a user-provided webhook URL. Missing AI keys return 503.

Features

  • Lead form - CRM row – name, email, optional company/message.
  • AI enrich – company guess + urgency; never fabricates when AI is missing.
  • Neon or memory – experiment_leads table when configured.
  • Optional outbound webhook – timeout-capped POST to your URL.
  • Honest 503 when AI Gateway / OpenAI is not configured.

Server Reference

POST /api/leads

{
  "name": "Alex Rivera",
  "email": "alex@acme.io",
  "company": "",
  "message": "...",
  "webhookUrl": "https://example.com/hooks/leads"
}

Success (200)

{
  "lead": {
    "id": "lead-1",
    "companyGuess": "Acme",
    "urgency": "high",
    "webhookStatus": "ok"
  },
  "storage": "neon",
  "provider": "ai-gateway"
}

GET /api/leads

Lists persisted leads (storage: neon | memory).

StatusCause
503No AI provider
400Invalid name/email

Implementation Details

Validate + enrich

Normalize email, truncate message, generateObject for enrichment.

Persist + webhook

Neon insert or module Map, then optional outbound POST.

Use Cases

  • Learn composition patterns for this lab’s stack.
  • Prototype before wiring production auth and quotas.
  • Deploy the standalone app as a reference implementation.

Limitations

  • Demo-scale caps on input size and lead count.
  • No auth / rate limits on public deploys.
  • Webhook delivery is best-effort (5s timeout).

Use in your project

Copy the Route Handler and logic.ts helpers from apps/experiments/form-to-crm-lab/. Wire your own persistence and auth as needed.

Deployment

Deploy on Vercel

Local Development

cd apps/experiments/form-to-crm-lab
pnpm install
pnpm dev

Configuration

VariableRequiredPurpose
AI_GATEWAY_API_KEYYes (or OPENAI_API_KEY)Preferred provider
OPENAI_API_KEYNoFallback
AI_MODELNoModel override
DATABASE_URLNoNeon persistence

Vercel / Next.js Features Used

  • AI SDK generateObject
  • Neon serverless Postgres
  • Route Handlers
  • Zod

Next Steps

On this page