Skip to content

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

LeadCatch.ai

Turn missed calls into conversations.

Watch the Demo

The Problem

Small businesses lose up to 62% of phone calls — customers call after hours, during busy periods, or when staff can't pick up. Each missed call is a lost lead. Most callers won't leave a voicemail. They just move on to the next business.

Our Solution

LeadCatch.ai bridges that gap by instantly converting missed calls into AI-powered text conversations. When a customer calls and no one answers, the system:

  1. Plays a brief voice greeting via Twilio
  2. Immediately texts the caller through iMessage
  3. Uses GPT-4 to carry on a natural conversation — answering questions about services, pricing, hours, and more
  4. Saves a conversation summary so the business owner can follow up later

No lead goes cold. No customer gets ghosted. The AI handles the first touch while the business owner catches up.

Tech Stack

Technology Role
Python 3 Core language
Flask Lightweight web server to receive Twilio webhooks
Twilio Telephony — receives incoming calls and triggers the webhook
OpenAI GPT-4 Turbo Generates natural, context-aware responses to customer messages
Apple iMessage (via AppleScript) Sends and receives text messages through the macOS Messages app
SQLite Reads the local iMessage database (chat.db) to detect new incoming messages
ngrok Exposes the local Flask server to the internet during development

How It Works

Customer calls ──> Twilio webhook ──> Flask server (app.py)
                                          │
                                          ├── Plays voice greeting
                                          └── Spawns iMessage responder
                                                  │
                                                  ├── Sends initial text via iMessage
                                                  ├── Monitors for replies (polls chat.db)
                                                  └── Responds with GPT-4 using business data
  1. A customer calls your Twilio number
  2. Twilio forwards the call to your Flask webhook
  3. The caller hears: "Thank you for calling. Our AI assistant will text you shortly."
  4. The system launches an iMessage responder for that caller
  5. GPT-4 generates responses using your business data from business_data.json
  6. Conversation summaries are saved per customer in summaries/

Features

  • Automatic call-to-text conversion via Twilio
  • AI-powered responses using GPT-4 Turbo
  • Per-customer conversation summaries for business owners
  • Business info loaded from a single JSON config file
  • Deduplication — prevents multiple responders for the same caller
  • Persistent conversation history across sessions

Prerequisites

  • macOS (required for iMessage integration via AppleScript)
  • Python 3.7+
  • Twilio account with a phone number
  • OpenAI API key
  • ngrok or similar tunnel (for local development)

Setup

1. Clone and install dependencies

git clone <repo-url>
cd LeadCatch.ai
pip install -r requirements.txt

2. Configure environment variables

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_api_key_here

3. Set up business data

Edit business_data.json with your business information:

{
  "name": "Your Business Name",
  "services": {
    "Service A": "$25",
    "Service B": "$50"
  },
  "hours": "Mon-Sat: 10 AM to 7 PM",
  "address": "123 Main Street, City, ST",
  "contact": "555-123-4567",
  "email": "you@example.com",
  "about": "A short description of your business."
}

4. Configure Twilio

  1. Log in to your Twilio Console
  2. Navigate to your phone number settings
  3. Under Voice & Fax, set the webhook URL to your server (e.g., https://abc123.ngrok.io/)
  4. Set the HTTP method to POST
  5. Enable call forwarding on your Twilio number

5. Start a local tunnel (development)

ngrok http 5001

Copy the HTTPS URL and use it as your Twilio webhook.

6. Grant iMessage permissions

Your terminal needs Full Disk Access to read the iMessage database:

  1. Open System Settings > Privacy & Security > Full Disk Access
  2. Add your terminal app (Terminal, iTerm, etc.)
  3. Add Python if needed

Usage

python app.py

The server starts on http://0.0.0.0:5001.

Project Structure

LeadCatch.ai/
├── app.py                    # Flask webhook server — receives Twilio calls
├── imessage_responder.py     # iMessage monitor + GPT-4 response logic
├── business_data.json        # Your business info (services, hours, contact)
├── requirements.txt          # Python dependencies
├── .env                      # API keys (not committed)
├── summaries/                # Per-customer conversation summaries (auto-created)
│   └── +15551234567.json
└── README.md

Customization

AI personality

Edit the system_prompt in imessage_responder.py:

system_prompt = f"""
You are a smart, friendly assistant for {business_data['name']}.
# Add your custom instructions here
"""

Initial greeting

Modify initial_message in imessage_responder.py:

initial_message = "Hi! Thank you for calling. How can I help you today?"

Polling interval

Adjust how frequently the responder checks for new messages:

time.sleep(3)  # seconds between checks

Troubleshooting

Problem What to check
iMessage not sending Verify Full Disk Access permissions; check iMessage is signed in; ensure phone numbers include country code (+1...)
Webhook not received Confirm ngrok is running and the Twilio webhook URL matches
OpenAI errors Check .env API key; verify account has credits; review rate limits
Duplicate responders Restart the Flask server to clear active_processes; kill orphaned Python processes

Limitations

  • macOS only — iMessage integration requires macOS with Messages.app
  • Local execution — the responder must run on a Mac with iMessage configured
  • iMessage only — SMS fallback depends on your carrier and Apple ID setup

License

This project is provided as-is for educational and business purposes.

Releases

Packages

Contributors

Languages