Understand the onboarding pipeline, automated website scraping, and industry template seeding.
The onboarding wizard runs through the server action createOrganizationAction in src/server/actions/onboarding.ts. It is designed to get a new business fully operational in a single pass.
The setup screens follow four sequential steps: 1. URL Discovery: Enter your business website URL to run a live SSRF-safe crawl that extracts business identity and descriptions. 2. Business Profile: Confirm business name, contact phone, contact email, street address, and timezone. 3. Industry Configuration: Select one of 8 industry presets or enter custom parameters. 4. Review & Activation: Generates your organization record, seeds database tables, and initializes a 14-day free trial on the Starter plan.
When you enter a website URL during onboarding:
- The system checks URL validity using validateSafeUrl() to prevent Server-Side Request Forgery (SSRF). Private subnet IPs (10.x, 172.16.x, 192.168.x, 127.x) and cloud metadata services are strictly rejected.
- The crawler fetches the homepage HTML and extracts the page title, meta description, and primary text blocks.
- The extracted text is automatically segmented into knowledge chunks and stored in knowledgeChunks under a source labeled "Website Crawls".
Based on the selected industry, the server automatically populates: - Services (`services`): Default bookable offerings with standard durations (e.g., Teeth Cleaning: 45 min, Root Canal: 90 min). - FAQ Items (`faq_items`): Pre-populated answers for insurance acceptance, cancellation policies, and intake requirements. - Qualification Flow (`qualification_flows`): Questions to qualify leads (e.g., *"Are you a new or returning patient?"*). - Business Hours (`business_settings`): Monday through Friday from 09:00 to 17:00, with Saturday and Sunday marked closed.
When onboarding finishes:
- An organizations record is created with a URL-safe unique slug (e.g., acme-dental-4821).
- The authenticated user is granted an owner role in memberships.
- An active 14-day trial is registered in the subscriptions table, unlocking website widget, voice telephony, and SMS features.