Skip to main content
Technical Architecture Case Study

Decoupling Conversational AI from Deterministic Lead Scoring

How LeadFlow eliminates hallucinated qualification scores by treating streaming LLMs purely as entity extractors bound to rigid server-side execution tools.

1. The Problem: The Cost of Unstructured Inbound Friction

In high-value real estate transactions, over 70% of inbound website inquiries fail to convert. Prospective buyers arrive with vague intent, unconfirmed budgets, and fragmented timelines. Sales teams spend up to 20 hours a week manually triaging inquiries, leading to delayed response times where hot buyers drop off before receiving outreach.

Static contact forms fail because buyers dislike lengthy dropdown surveys. Meanwhile, unconstrained conversational chatbots fail because language models consistently hallucinate numerical metrics—giving casual browsers inflated scores and downgrading ready buyers based on linguistic idiosyncrasies.

2. The Core Decision: Deterministic Server-Side Tool Contracts

To solve score hallucination, LeadFlow establishes a strict separation of concerns:

What the LLM Does

Natural language dialogue, conversational rapport, polite inquiry probing, and extracting structured parameters (intent, timeline, budget certainty, contact method).

What Deterministic Code Does

Executes the scoreLead tool via Zod schemas. Calculates mathematical points, enforces business rubrics, and assigns Hot, Warm, or Cold tiers.

If the model triggers the tool prematurely with zero qualifying signal, the system throws a structured ToolUserError that renders a designed warning card client-side, gracefully prompting the prospect to provide additional details.

3. Production Hardening & Abuse Prevention

Deploying an open streaming AI endpoint on public cloud infrastructure introduces significant quota exhaustion risks. LeadFlow hardens app/api/chat/route.js with four defensive tiers:

  • Conversation Turn Limit: Caps sessions to 25 messages to eliminate runaway token loops.
  • Per-Message Length Guard: Limits user messages to 1,500 characters, blocking buffer spam.
  • Total Payload Cap: Caps total session context at 15,000 characters.
  • Serverless Timeout Protection: Configures maxDuration = 30 seconds to protect streaming integrity on edge nodes.

Test the Architecture in Production

Interact with the streaming qualification chat or inspect our alert rules.