Skip to main content

Web Quotes & Draft Autosave Pipeline

Multi-step insurance questionnaires suffer from high user drop-off rates when applicants are forced to complete extensive questionnaires in a single sitting.

To solve this, veridex-hitech-web-application implements an Asynchronous Draft Autosave & Customer Resumption Pipeline.


1. Two-Step Acquisition Architecture​

The quoting workflow separates rapid lead capture (Step 1) from deep underwriting questionnaire enrichment (Step 2):


2. Step 1: Draft Autosave (/api/forms/quote/draft)​

2.1 Route Implementation​

Located at src/app/api/forms/quote/draft/route.ts. Evaluates client IP against the FORM_SUBMISSION rate limiter tier (10 submissions per 5 minutes) and validates payload attributes via Zod:

// Draft Lead Schema Definition
const draftLeadSchema = z.object({
firstName: z.string().min(1, "First name is required"),
lastName: z.string().optional(),
email: z.string().email().optional(),
phone: z.string().min(10).optional(),
state: z.string().min(2).optional(),
insuranceType: z.string().min(1, "Insurance line is required"),
additionalDetails: z.string().optional(),
recaptchaToken: z.string().optional(),
});

2.2 Sample Request Body​

{
"firstName": "Marcus",
"lastName": "Vance",
"email": "marcus.vance@freightlogistics.com",
"phone": "+12145558912",
"state": "TX",
"insuranceType": "truck-insurance",
"additionalDetails": "Need fast primary liability filing for 3 semi-trucks"
}

2.3 Sample Response (HTTP 201 Created)​

{
"success": true,
"leadId": "66f4a8b1c2e40001a9b8c7d6",
"message": "Draft lead created successfully"
}

3. Step 2: Detailed Questionnaire Enrichment​

Once Step 1 is persisted, the modal transitions to specialized questionnaires based on the selected insurance product line:

3.1 Commercial Trucking Questionnaire​

For commercial transportation, the client captures federal DOT compliance parameters:

  • truckDetails.companyName: Registered legal business entity.
  • truckDetails.dot: FMCSA USDOT registration number.
  • Garaging state, operating radius, and commercial equipment types (Dry Van, Reefer, Flatbed).

3.2 Personal Auto Questionnaire (16-Step Questionnaire)​

For personal auto insurance, the client gathers comprehensive risk attributes:

  • Dwelling & Garaging: address1, address2, city, zipCode, residenceStatus (own | rent), residenceType (single_family | apartment).
  • Driver History Array (drivers):
    • firstName, lastName, dob (Date of birth)
    • gender, maritalStatus
    • requireSR22 (yes | no — high-risk state filings)
    • licensedIn / stateLicensed, licenseStatus (active | suspended)
    • hasViolations (yes | no — past 36-month moving violations or claims)
  • Vehicle Roster Array (vehicles):
    • year, make, model, usage (commute | business | pleasure), vin
  • Coverage History:
    • currentlyInsured (yes | no), policyStartDate (desired inception date)
    • propertyQuote (yes | no — multi-policy bundle inquiry)
  • Contact Preferences:
    • contactMethod (phone | email | text)
    • contactTime, contactDate, contactTimeOfDay (morning | afternoon | evening)

4. Step 3: Atomic Completion (/api/forms/quote/complete)​

4.1 Route Implementation​

Located at src/app/api/forms/quote/complete/route.ts. Validates that the mandatory contact fields are populated, updates the document status from 'draft' to 'completed', triggers confirmation emails, and dispatches the lead to the HTI CRM:

// Atomic Transition in src/app/api/forms/quote/complete/route.ts
const updatedLead = await Lead.findByIdAndUpdate(
leadId,
{
$set: {
status: "completed",
email: data.email,
phone: data.phone,
state: data.state,
truckDetails: data.truckDetails,
autoDetails: data.autoDetails,
updatedAt: new Date(),
},
},
{ new: true }
);

4.2 Downstream CRM Trigger​

If the insurance line is truck-insurance or business-insurance, the route invokes sendLeadToHtiCrm:

await sendLeadToHtiCrm(
{
firstName: updatedLead.firstName,
lastName: updatedLead.lastName,
email: updatedLead.email,
phoneNumber: updatedLead.phone,
state: updatedLead.state,
companyName: updatedLead.truckDetails?.companyName,
usDot: updatedLead.truckDetails?.dot,
source: "Web Application Quote Form",
leadStage: "New Inbound Quote",
},
updatedLead._id.toString(),
updatedLead.insuranceType
);

5. Customer Portal Resumption Workflow​

When an authenticated policyholder logs into /dashboard:

  1. Query Execution (src/server/actions/user-submissions.actions.ts): The server action queries Lead.find({ email: session.user.email, status: 'draft' }).sort({ createdAt: -1 }).
  2. UI Presentation (src/components/feature/dashboard/user-submissions-tab.tsx): Unfinished records render with an amber "Incomplete Draft" status badge alongside an interactive "Resume Application" button.
  3. Modal Population: Clicking "Resume" instantiates InsuranceQuoteModal, passing the stored leadId and existing JSON values, enabling the user to finish the application without re-typing their contact information.