Skip to content

abhiisdev7/leadestate.ai

Repository files navigation

Leadestate Voice

AI-powered inbound/outbound agent for US real estate. Handles buyer and seller inquiries, qualifies leads, schedules calls, sends confirmation emails, and processes cancellation replies automatically.

Live demo: Conversation chatbot · CRM dashboard


Quick Start

npm install
cp .env.example .env   # Create .env from template
# Edit .env and set your variables (see Environment Variables below)
npm run dev

Open http://localhost:3000 for the voice chat.

Environment Setup

Copy .env.example to create your .env file. The example file lists all required and optional variables with placeholder values. Replace them with your actual credentials:

cp .env.example .env

Then edit .env and set your values (API keys, database URL, email credentials, etc.). Never commit .env to version control—it is gitignored.


Email Flow

The system sends meeting confirmation emails and automatically handles cancellation replies.

1. Schedule a Call (Voice Chat)

Users qualify through the AI voice chat, provide contact details, and confirm a time slot. The AI collects name, phone, and email (required) before scheduling.

AI Chatbot

2. Conversation & Scheduling

The AI proposes available slots and confirms the booking. Once the user confirms, the system creates the schedule and sends a confirmation email.

AI Chatbot Conversation

3. Confirmation Email Sent

A styled HTML email is sent to the customer with the meeting details. The email includes threading headers so replies stay in the same thread.

Schedule Email

Example confirmation email:

Field Content
Subject Your call is scheduled – [date] at [time]
Body Lead name, date, time, purpose. "If you need to reschedule, reply to this email or give us a call."

4. Customer Replies to Cancel

If the customer replies with cancellation intent (e.g. "I wanted to cancel this call, I will reach you later"), the system:

  1. Detects intent – AI classifies the reply as cancel, reschedule, or other
  2. Cancels the schedule – Updates status in the database
  3. Updates the CRM – Removes the appointment, sets next action, adds a note
  4. Sends a threaded reply – Confirms the cancellation and offers to reschedule

Call Schedule Cancel Reply Email

Example cancellation reply:

Field Content
Subject Re: Your call is scheduled – [date] at [time]
Body "We've received your request and cancelled your call scheduled for [date] at [time]. If you'd like to reschedule at a different time, simply reply to this email or give us a call."

Email Observer (Cron)

The email observer runs periodically (every 10 minutes on Vercel, or via npm run email-observer) to:

  • Connect to IMAP inbox
  • Fetch unseen emails that reply to our meeting confirmations
  • Classify intent with AI
  • Execute the cancel flow when appropriate

CRM Dashboard

View leads, meetings, and next actions. Expand rows for full qualification details and suggested properties.

CRM Dashboard


Properties

Properties List

Grid layout with hover actions: view details, mark as Sold, Archive, or Mark active.

Properties List

Add Property

Add new listings with address, city, state, price, beds, baths, and images.

Add Property

Property Details

Image carousel, price and status badges, and full listing details.

Property Details

Property Actions

Sold, Archive, and Mark active actions for status updates.

Property Actions


Environment Variables

Set variables in .env. Use .env.example as a template: copy it to .env and replace the placeholder values with your own.

Variable Required Description
GOOGLE_GENERATIVE_AI_API_KEY Yes Google Gemini API key
DATABASE_URL or DB_* Yes MongoDB connection
SMTP_MAIL For emails Sender email (Gmail: use App Password)
SMTP_MAIL_PASSWORD For emails SMTP password
IMAP_MAIL / IMAP_MAIL_PASSWORD For cancel flow Same as SMTP for Gmail
CRON_SECRET Optional Protects /api/cron/email-observer

See .env.example for the full list.


Scripts

Command Description
npm run dev Start dev server
npm run build Production build
npm run start Start production server
npm run email-observer Run IMAP observer (standalone)

Routes

Route Purpose
/ Voice Chat
/crm CRM Dashboard
/properties Properties grid
/properties/[id] Property details
/contacts Contacts list

Future Roadmap

Additional features we may add—useful to mention in demos:

Feature Description
Reschedule via email When a customer replies "can we move it to next week?", auto-propose new slots and confirm via email thread
SMS channel Send meeting reminders and handle replies via Twilio; qualify leads who text instead of chat
Twilio voice Real phone calls—inbound/outbound with speech-to-text; no browser required
Agent handoff When lead is hot or requests human, flag in CRM and notify agent; warm transfer option
Compliance scripts Auto-check disclosures, fair housing language, and required scripts before closing
Personalization memory Remember preferences across sessions (e.g. "no HOA", "must have backyard") for repeat visitors
Nurture sequences Automated outbound follow-ups for cold leads—objection handling, re-engagement emails
Calendar sync Google Calendar / Outlook integration for real availability and automatic booking
Lead scoring Score leads by intent, budget, timeline; surface hottest leads first in CRM

Technologies Used

Framework & Runtime

Technology Version Purpose
Next.js 16 React framework with App Router, API routes, server components, and Vercel deployment
React 19 UI components, hooks, and client-side interactivity
TypeScript 5 Type safety and better developer experience

AI & Chat

Technology Purpose
Google Gemini Large language model for conversation, lead qualification, property suggestions, and email intent classification
Vercel AI SDK Streaming chat, tool calling, and structured outputs for the voice assistant
Zod Schema validation for AI tool inputs and structured responses

Database

Technology Purpose
MongoDB NoSQL database for leads, contacts, schedules, and properties
Mongoose ODM for schemas, models, queries, and relationships

Email

Technology Purpose
Nodemailer SMTP transport for sending meeting confirmation and cancellation reply emails
ImapFlow IMAP client for fetching inbox and detecting replies to meeting confirmations
mailparser Parsing email bodies and headers (In-Reply-To, References) for threading

Voice & Media

Technology Purpose
Web Speech API Browser-based speech recognition (voice input) and synthesis (text-to-speech)
Lottie Animated illustrations (e.g. email confirmation animation)
Embla Carousel Image carousel on property details page

UI & Styling

Technology Purpose
Tailwind CSS Utility-first styling and responsive design
Radix UI Accessible primitives (dialogs, dropdowns, tabs)
Lucide React Icon set
Motion Animations and transitions
Recharts CRM dashboard charts (leads, meetings over time)

Utilities & Tooling

Technology Purpose
node-cron Scheduled tasks for the standalone email observer script
dotenv Loading environment variables in scripts
tsx Running TypeScript scripts (email observer)
nanoid Unique ID generation

About

Chat Interface: https://leadestate-ai.vercel.app CRM Interface: Chat Interface: https://leadestate-ai.vercel.app/crm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages