Skip to main content
Normalized for Mintlify from knowledge-base/aiconnected-apps-and-modules/modules/funnelChat/legacy-kb-chat-lead-capture-routing.mdx.

Lead Capture & Routing System

Overview

This specification extends the kbChat platform with lead capture and routing capabilities. The system allows agencies and businesses to create custom forms, capture lead information during chat conversations, and route that information to their preferred destination. Platform Responsibility: Capture the data, deliver the data. Agency/Business Responsibility: What happens after delivery.

Admin Interface: Lead Capture Settings

Location: Business Settings → Lead Capture (or Agency Settings → Default Lead Capture for agency-wide defaults)

Part 1: Form Builder

1.1 Form Configuration

1.2 Field Builder

Each form consists of custom fields. The admin can add, remove, reorder, and configure fields. Field Properties: Field Types:

1.3 Preset Templates

To speed up setup, offer starter templates: Agency can set a default template that applies to all new businesses.

1.4 Form Display Options


Part 2: AI Integration

2.1 How the AI Uses the Form

The AI needs to know:
  1. What form(s) exist
  2. When to present the form
  3. What to do after submission
System Prompt Addition: When generating the business system prompt, append form instructions:

2.2 Conversational vs. Form Collection

Option A: Conversational Collection AI asks for fields naturally within the conversation: > “I’d be happy to have someone reach out to you. What’s the best email to contact you at?” Option B: Direct Form AI triggers form display: > “Let me grab your details so we can follow up. Just fill out this quick form:” > [Form appears] Admin Setting: Collection Style
  • Conversational (AI asks naturally)
  • Form (AI presents form)
  • Hybrid (AI asks 1-2 key fields, then presents form for rest)

Part 3: Routing Configuration

After form submission, where does the data go?

3.1 Routing Destinations

Admin can enable one or more destinations. All enabled destinations fire simultaneously.

Email Notification

| Email Format | HTML (formatted) / Plain Text | | Include Transcript | Yes/No - attach full conversation transcript | | Include AI Summary | Yes/No - include AI-generated lead summary |
Email Body Contains:
  • All captured form fields (label: value format)
  • Timestamp
  • Conversation transcript (if enabled)
  • AI summary (if enabled): “User is interested in [X], asked about [Y], sentiment: [Z]“

SMS Notification

Webhook (JSON Payload)

3.2 JSON Payload Structure

Field Mapping Note: The lead object keys match the Field Key set in the form builder. Agencies can customize these keys to match their destination system’s expected field names, eliminating the need for field mapping on the receiving end.

3.3 Webhook Testing

3.4 Redirect Option

After form submission, optionally redirect the user: This allows: Capture lead info → Send to webhook → Redirect to Calendly The business gets the lead data AND the user can self-schedule. Best of both worlds.

Part 4: Database Schema Additions

4.1 New Tables

4.2 RLS Policies


Part 5: UI Mockup Descriptions

5.1 Form Builder Interface

Header:
  • Form Name (editable)
  • Active/Inactive toggle
  • Save / Delete buttons
Left Panel: Field List
  • Draggable list of current fields
  • Each field shows: Label, Type, Required indicator
  • Drag handle for reordering
  • Click to edit, X to delete
Right Panel: Field Editor
  • Appears when field is selected
  • All field properties editable
  • Live preview of field appearance
Bottom: Add Field
  • ”+ Add Field” button
  • Dropdown of field types
  • Or “Use Template” to load preset

5.2 Routing Configuration Interface

Tab Layout:
  • Email | SMS | Webhook | Redirect
Each Tab:
  • Enable toggle at top
  • Configuration fields below (grayed out if disabled)
  • Test button where applicable
Webhook Tab Extras:
  • Payload Preview panel (shows live JSON)
  • Test Result panel (shows last test response)
  • Delivery Log link

5.3 Leads Dashboard

Table View:
  • Date/Time
  • Name
  • Email
  • Phone
  • Form Used
  • Delivery Status (icons: ✓ email, ✓ SMS, ✓ webhook)
  • Actions: View Details
Detail View:
  • All captured fields
  • Full conversation transcript
  • AI summary
  • Delivery log (what was sent where, when, response codes)

Part 6: Implementation Priority

Phase 1: Minimum Viable

  1. Form builder with basic fields (text, email, phone)
  2. Email notification only
  3. Basic leads table

Phase 2: Full Routing

  1. All field types
  2. SMS notification
  3. Webhook with authentication options
  4. Redirect option

Phase 3: Polish

  1. Preset templates
  2. Webhook testing and logs
  3. Leads dashboard with filtering/search
  4. AI summary generation

Summary

What we built: A form builder and routing system that captures leads and delivers them wherever the business needs. What we didn’t build: Integrations with specific platforms. That’s the agency’s job. The value proposition: “Never miss a lead. Your AI assistant captures contact information and sends it to you instantly—by email, text, or directly into your existing systems via webhook.”