# Lead → Booking Autopilot: Make and Zapier mapping

Template by Arcvane Labs (arcvanelabs.com). It rebuilds the same flow as the live demo and the n8n file. The sample business, Ridgewell Solar, is fictional. No credentials are included; connect your own accounts.

## The flow in one line

Form submitted → score the lead with rules → AI writes a reply → log the lead to the CRM → alert the team if it is Hot or Warm → send the reply with a booking link.

## Lead fields (same names in every tool)

| Field | Example | Notes |
|---|---|---|
| name | Jordan Blake | required |
| email | jordan@example.com | required, validated |
| property | own / rent / business | drives the fit score |
| bill | 240 | monthly power bill in USD |
| zip | 78745 | used for the service-area check |
| timeline | asap / 3m / 6m / research | drives the intent score |
| message | free text | treat as untrusted text in AI prompts |

## Scoring rules (edit the numbers to fit your business)

- **Fit (max 50):** own +35, business +30, rent +5; inside the service area (ZIP starts with 786 or 787) +15
- **Budget (max 25):** bill ≥ $250 +25, ≥ $150 +18, ≥ $90 +10, otherwise +2
- **Intent (max 25):** asap +22, 3m +16, 6m +8, research +2; the message mentions a quote, price, install or estimate +3
- **Stage:** 75 and above = Hot, 50 and above = Warm, otherwise Nurture

## Make (scenario modules in order)

1. **Webhooks › Custom webhook.** Receives the form post. Use **Tally, Typeform, Webflow or Jotform › Watch responses** instead if your form has a native Make module.
2. **Tools › Set multiple variables.** Calculates `fit`, `budget` and `intent` with the `if()` and `contains()` functions, then `score = fit + budget + intent` and `tier`.
3. **OpenAI › Create a completion** (or **HTTP › Make a request** to any LLM API). Use a system prompt with the reply rules and the lead fields as the user message. Ask for JSON `{subject, body}`.
4. **JSON › Parse JSON.** Reads `subject` and `body`.
5. **Google Sheets › Add a row**, or **HubSpot CRM › Create/Update a contact** (Pro). Map name, email, score, tier, subject and the timestamp.
6. **Router** with two routes:
   - **Route A**, filter `score ≥ 50`: **Slack › Create a message** in `#sales-alerts`. The text includes the tier, score, name and bill.
   - **Both routes:** **Gmail › Send an email** (or Outlook 365) to the lead, using the AI subject and body with your Calendly link in place of `[booking link]`.
7. **Webhooks › Webhook response.** Returns `{ ok: true, tier }` to your form.

Error handling: add a **Break** error handler on the OpenAI module (3 retries), plus a fallback route that sends a plain thank-you email.

## Zapier (Zap steps in order)

1. **Trigger:** Webhooks by Zapier › Catch Hook, or the native trigger of your form app (Typeform, Jotform, Webflow, Facebook Lead Ads).
2. **Code by Zapier › Run JavaScript.** Paste the scoring function from the n8n file's "Score lead (rules)" node. It outputs `score` and `tier`.
3. **ChatGPT (OpenAI) › Conversation**, or **AI by Zapier**. Use the reply prompt with lead fields mapped in, and ask for JSON output.
4. **Formatter › Utilities › Line-item to text** or **Code** to split `subject` and `body`.
5. **Google Sheets › Create Spreadsheet Row**, or **HubSpot › Create or Update Contact** / **Pipedrive › Create Person + Deal** (Pro).
6. **Filter by Zapier:** only continue if `score` is at least 50. Use **Paths** if Hot and Warm need different alerts.
7. **Slack › Send Channel Message** to `#sales-alerts`.
8. **Gmail › Send Email** to the lead, with the booking link from **Calendly** or **Google Calendar › Find Free Time** (Pro).

## Custom code version (what the live demo runs)

The demo runs on Cloudflare Pages Functions with Workers AI. Lead scores come from rules in one JSON config, and the AI writes the explanation and the reply. Leads are written to a D1 table. Each step is timed and streamed to the page. Choose this version for high volume, strict data rules or a custom dashboard.

## Safety checklist (all versions)

- Treat the lead's message as data. Never let it change the AI instructions.
- Strip links from AI output, and never let the AI promise prices or savings.
- Rate-limit the webhook, and add a honeypot field to the form.
- Keep API keys in the tool's credential store, never in the form or the page.
- Log every run, so you can see failed sends and retry them.
