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
| Setting | Description |
|---|---|
| Form Name | Internal reference name (e.g., “Main Contact Form”, “Service Request Form”) |
| Form Enabled | Toggle on/off |
| Multiple Forms | Business can create multiple forms for different purposes |
1.2 Field Builder
Each form consists of custom fields. The admin can add, remove, reorder, and configure fields. Field Properties:| Property | Description |
|---|---|
| Field Label | Display name shown to user (e.g., “Your Name”, “Email Address”) |
| Field Key | System identifier for JSON payload (e.g., “name”, “email”, “phone”) - auto-generated from label but editable |
| Field Type | See field types below |
| Required | Yes/No - conversation cannot complete without this field |
| Placeholder | Helper text shown in empty field |
| Validation | Type-specific validation rules |
| Type | Use Case | Validation |
|---|---|---|
| Text | Name, company, general input | Min/max length |
| Email address | Valid email format | |
| Phone | Phone number | Valid phone format (configurable by country) |
| Number | Quantity, budget, age | Min/max value |
| Dropdown | Service type, location, predefined options | Must select from list |
| Multi-select | Multiple services interested in | Must select at least one (if required) |
| Date | Preferred appointment date | Future dates only (optional) |
| Time | Preferred time | Time range restrictions (optional) |
| Long Text | Message, project description, details | Min/max length |
| Hidden | UTM parameters, page URL, referrer | Auto-populated, not shown to user |
1.3 Preset Templates
To speed up setup, offer starter templates:| Template | Fields Included |
|---|---|
| Basic Contact | Name, Email, Phone |
| Service Request | Name, Email, Phone, Service Type (dropdown), Message |
| Appointment Request | Name, Email, Phone, Preferred Date, Preferred Time, Notes |
| Quote Request | Name, Email, Phone, Service Type, Budget Range, Project Description |
1.4 Form Display Options
| Setting | Options |
|---|---|
| Display Mode | Inline (fields appear in chat) / Modal (form pops up) |
| Trigger | AI-initiated (AI decides when to show) / User-initiated (user clicks button) / Always (form appears at conversation start) |
| Submit Button Text | Customizable (default: “Submit”) |
| Success Message | Message shown after form submission (default: “Thanks! Someone will be in touch shortly.”) |
Part 2: AI Integration
2.1 How the AI Uses the Form
The AI needs to know:- What form(s) exist
- When to present the form
- What to do after submission
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
| Setting | Description |
|---|---|
| Enable Email | Toggle |
| Recipient(s) | One or more email addresses (comma-separated) |
- 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
| Setting | Description |
|---|---|
| Enable SMS | Toggle |
| Recipient(s) | One or more phone numbers |
| Message Template | Customizable, supports variables, max 160 characters recommended |
Webhook (JSON Payload)
| Setting | Description |
|---|---|
| Enable Webhook | Toggle |
| Webhook URL | Destination endpoint |
| HTTP Method | POST (default) / PUT |
| Authentication Type | None / API Key / Bearer Token / Basic Auth |
| API Key Header | If API Key auth: header name (default: “X-API-Key”) |
| API Key Value | If API Key auth: the key value |
| Bearer Token | If Bearer auth: the token |
| Basic Auth Username | If Basic auth |
| Basic Auth Password | If Basic auth |
| Custom Headers | Optional additional headers (key:value pairs) |
| Include Transcript | Yes/No |
| Include AI Summary | Yes/No |
3.2 JSON Payload Structure
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
| Feature | Description |
|---|---|
| Test Button | Sends sample payload to configured URL |
| Response Display | Shows HTTP status code and response body |
| Payload Preview | Shows exact JSON that will be sent |
| Recent Deliveries | Log of last 10 webhook attempts with status |
3.4 Redirect Option
After form submission, optionally redirect the user:| Setting | Description |
|---|---|
| Enable Redirect | Toggle |
| Redirect URL | Where to send user (e.g., Calendly link, thank you page) |
| Redirect Delay | Seconds to wait before redirect (default: 2) |
| Redirect Message | Message shown during delay (default: “Taking you to schedule your appointment…”) |
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
- Draggable list of current fields
- Each field shows: Label, Type, Required indicator
- Drag handle for reordering
- Click to edit, X to delete
- Appears when field is selected
- All field properties editable
- Live preview of field appearance
- ”+ Add Field” button
- Dropdown of field types
- Or “Use Template” to load preset
5.2 Routing Configuration Interface
Tab Layout:- Email | SMS | Webhook | Redirect
- Enable toggle at top
- Configuration fields below (grayed out if disabled)
- Test button where applicable
- 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
- Phone
- Form Used
- Delivery Status (icons: ✓ email, ✓ SMS, ✓ webhook)
- Actions: View Details
- 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
- Form builder with basic fields (text, email, phone)
- Email notification only
- Basic leads table
Phase 2: Full Routing
- All field types
- SMS notification
- Webhook with authentication options
- Redirect option
Phase 3: Polish
- Preset templates
- Webhook testing and logs
- Leads dashboard with filtering/search
- AI summary generation