Before: the office manager copied web-form leads into the CRM by hand and emailed quotes the next morning. Now one serverless function does it on submit, with $0 middleware fees. Fill the form and watch each step run.
⚡
1. Webhook received Cloudflare Worker validates and de-duplicates the lead
waiting
🧮
2. Price calculated Tonnage from sq ft, price book, Phoenix-area labor rate
waiting
📄
3. Quote PDF generated Branded 1-page quote, stored in Google Drive
waiting
🗂️
4. CRM contact + deal created HubSpot API: contact, deal, quote attached
waiting
🔔
5. Dispatcher alerted, customer emailed Slack message + email with the PDF
waiting
worker.js (excerpt) pricing.js
export default {
async fetch(req, env) {
const lead = await req.json();
try {
if (await isDuplicate(env.KV, lead.email)) return ok('duplicate' );
const quote = priceJob(lead); // pricing.js
const pdfUrl = await makePdf(env, lead, quote); // Apps Script web app → Drive
const deal = await hubspot(env).createDeal(lead, quote, pdfUrl);
await Promise.all([
slack(env.SLACK_URL, `New ${lead.service} lead: ${lead.name}, ${quote.range}` ),
email(lead.email, 'Your Northwind HVAC quote' , pdfUrl),
]);
return ok(deal.id);
} catch (err) {
await alertOwner(env, err, lead); // owner gets the raw lead, nothing is lost
return ok('queued' );
}
}
};
const PRICE_BOOK = { // owner edits these numbers, nothing else
ac: { perTon: [1650, 2100], base: 2900 },
hp: { perTon: [2100, 2700], base: 3400 },
furn: { perTon: [ 900, 1250], base: 2600 },
tune: { flat: [ 129, 189] },
};
export function priceJob({ service, sqft, urgency }) {
const tons = Math.min(5, Math.max(1.5, Math.round(sqft / 500 * 2) / 2));
const p = PRICE_BOOK[service];
let [lo, hi] = p.flat ?? p.perTon.map(r => p.base + r * tons);
if (urgency === 'now' ) { lo += 150; hi += 250; } // same-day crew
return { tons, lo, hi, range: `$${lo}–$${hi}` };
}