Skip to content

Crystal Power Investments - WhatsApp Business API Integration Platform for Real Estate Lead Generation and Property Matching

Notifications You must be signed in to change notification settings

CPInvestMo/crystal-power-whatsapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Crystal Power WhatsApp Business API Integration

A comprehensive WhatsApp Business API integration platform for Crystal Power Investments, designed for real estate lead generation, automated property matching, and intelligent conversation management.

🌟 Project Overview

This platform provides a complete solution for managing WhatsApp Business communications, processing real estate leads through AI-powered analysis, and matching customers with suitable properties. Built specifically for Crystal Power Investments' real estate operations in Egypt.

Key Features

  • WhatsApp Business API Integration: Real API connections with webhook processing
  • AI-Powered Lead Processing: Intent recognition, entity extraction, and lead scoring
  • Property Matching System: Intelligent algorithms for optimal property recommendations
  • Legal Compliance: Full Egypt PDPL (Personal Data Protection Law) compliance
  • Real-time Analytics: Comprehensive dashboard with business intelligence
  • Mobile Responsive: Optimized for all devices and screen sizes

πŸ—οΈ Project Structure

crystal-power-whatsapp/
β”œβ”€β”€ src/                          # Source code files
β”‚   β”œβ”€β”€ server.js                 # Main webhook server
β”‚   β”œβ”€β”€ app.js                    # Core application logic
β”‚   β”œβ”€β”€ whatsapp-api.js           # WhatsApp Business API integration
β”‚   β”œβ”€β”€ ai-processor.js           # AI lead processing engine
β”‚   β”œβ”€β”€ ui-manager.js             # Frontend UI management
β”‚   β”œβ”€β”€ whatsapp-groups.js        # Group messaging functionality
β”‚   └── privacy-compliance.js     # PDPL compliance module
β”œβ”€β”€ public/                       # Frontend files
β”‚   β”œβ”€β”€ index.html                # Main dashboard interface
β”‚   β”œβ”€β”€ privacy-policy.html       # Legal privacy policy
β”‚   └── api-testing-dashboard.html # API testing interface
β”œβ”€β”€ docs/                         # Documentation
β”‚   β”œβ”€β”€ README.md                 # Main documentation
β”‚   β”œβ”€β”€ DEPLOYMENT.md             # Deployment instructions
β”‚   β”œβ”€β”€ PRODUCTION_READY.md       # Production readiness guide
β”‚   β”œβ”€β”€ LEGAL-DEPLOYMENT-CHECKLIST.md # Legal compliance checklist
β”‚   └── MatchPro-Legal-Compliance-Package.pdf # Legal documentation
β”œβ”€β”€ scripts/                      # Deployment and setup scripts
β”‚   β”œβ”€β”€ setup.sh                 # Initial setup script
β”‚   β”œβ”€β”€ deploy.sh                # Production deployment script
β”‚   └── setup-repository.sh      # Repository initialization
β”œβ”€β”€ tests/                        # Test files
β”‚   β”œβ”€β”€ test-webhook.js           # Webhook testing
β”‚   └── TEST_RESULTS.md           # Test documentation
β”œβ”€β”€ config/                       # Configuration files
β”‚   β”œβ”€β”€ env.example               # Environment variables template
β”‚   └── .gitignore                # Git ignore rules
β”œβ”€β”€ package.json                  # Node.js dependencies
└── .gitignore                    # Git ignore configuration

πŸš€ Quick Start

Prerequisites

  • Node.js 16.0.0 or higher
  • WhatsApp Business API credentials from Meta
  • Modern web browser with JavaScript enabled

Installation

  1. Clone the repository

    git clone https://github.com/crystal-power-investments/whatsapp-webhook.git
    cd whatsapp-webhook
  2. Install dependencies

    npm install
  3. Configure environment variables

    cp config/env.example .env
    # Edit .env with your WhatsApp Business API credentials
  4. Start the application

    npm start
  5. Open the dashboard

    • Navigate to http://localhost:3000 in your browser
    • Or open public/index.html directly for frontend-only mode

WhatsApp Business API Setup

  1. Get API Credentials

    • Access Token from Meta Business Manager
    • Phone Number ID for your business number
    • Webhook verification token
  2. Configure Webhook

    • Set webhook URL to your server endpoint
    • Subscribe to message events
    • Verify webhook connection
  3. Test Integration

    • Send test messages to your business number
    • Verify webhook receives and processes messages
    • Check dashboard for lead processing results

πŸ“Š Core Functionality

Lead Processing Pipeline

  1. Message Reception: WhatsApp webhook receives incoming messages
  2. AI Analysis: Extract intent, entities, and sentiment from messages
  3. Lead Scoring: Calculate lead quality score (0-100)
  4. Property Matching: Find suitable properties based on customer criteria
  5. Response Generation: Send automated or template responses
  6. Analytics Update: Update dashboard metrics and charts

Property Matching Algorithm

The system uses a weighted scoring algorithm to match properties with customer requirements:

  • Budget Match (30%): Β±10% = 100%, Β±20% = 80%, Β±50% = 40%
  • Location Match (25%): Exact = 100%, Alias = 100%, None = 0%
  • Property Type (20%): Exact = 100%, Different = 0%
  • Bedrooms (15%): Same = 100%, Β±1 = 70%, Β±2 = 40%
  • Bathrooms (10%): Same = 100%, Β±1 = 80%

Minimum match threshold: 30%

Lead Qualification Scoring

Base scores for different customer actions:

  • Property Inquiry Intent: 40 points
  • Budget Information: 25 points
  • Location Specified: 20 points
  • Contact Information: 15 points
  • Appointment Request: 50 points

Sentiment multipliers:

  • Positive Sentiment: +10 points
  • High Urgency: +15 points
  • Relevant Keywords: +5 points each

πŸ”’ Legal Compliance

Egypt PDPL Compliance

This system is fully compliant with Egypt's Personal Data Protection Law No. 151/2020:

  • Data Minimization: Automated privacy-by-design processing
  • Consent Management: Structured consent with audit trails
  • Data Subject Rights: Access, rectification, erasure, objection, portability
  • Security Measures: Encryption and access controls
  • Audit Logging: Comprehensive activity logging per PDPL Article 28

Required Legal Review

⚠️ IMPORTANT: Before production deployment, this system requires:

  1. Review by qualified Egyptian data privacy counsel
  2. Data Protection Officer certification
  3. Executive authorization from Crystal Power Investments
  4. PDPC registration verification
  5. Insurance coverage confirmation

See docs/LEGAL-DEPLOYMENT-CHECKLIST.md for complete requirements.

πŸ› οΈ Development

Available Scripts

  • npm start - Start the production server
  • npm run dev - Start development server with auto-reload
  • npm test - Run webhook tests
  • npm run health - Check server health status

API Endpoints

The system provides RESTful API endpoints for data management:

// Conversations
GET    /tables/conversations              // List all conversations
GET    /tables/conversations/{id}         // Get specific conversation
POST   /tables/conversations              // Create new conversation
PATCH  /tables/conversations/{id}         // Update conversation

// Messages
GET    /tables/messages                   // List all messages
POST   /tables/messages                   // Send new message
PATCH  /tables/messages/{id}              // Update message status

// Leads
GET    /tables/leads                      // List all leads
POST   /tables/leads                      // Create new lead
PATCH  /tables/leads/{id}                 // Update lead information

// Properties
GET    /tables/properties                 // List all properties
POST   /tables/properties                 // Add new property
PATCH  /tables/properties/{id}            // Update property

Testing

Run the test suite to verify webhook functionality:

npm test

This will test:

  • Webhook message processing
  • AI lead extraction
  • Property matching algorithms
  • Database operations
  • Response generation

πŸš€ Deployment

Production Deployment

  1. Prepare Environment

    chmod +x scripts/deploy.sh
    ./scripts/deploy.sh
  2. Configure Production Settings

    • Set production environment variables
    • Configure HTTPS certificates
    • Set up domain and DNS
    • Configure webhook URLs
  3. Deploy Application

    • Upload files to production server
    • Install dependencies
    • Start application services
    • Verify webhook connectivity

Hosting Options

  • VPS/Dedicated Server: Full control, custom configuration
  • Cloud Platforms: AWS, Google Cloud, Azure
  • PaaS Solutions: Heroku, DigitalOcean App Platform
  • Serverless: AWS Lambda, Vercel Functions

See docs/DEPLOYMENT.md for detailed deployment instructions.

πŸ“ˆ Analytics & Monitoring

Key Performance Indicators

  • Lead Capture Rate: Percentage of WhatsApp messages processed
  • Matching Accuracy: Successful property matches percentage
  • Agent Response Time: Average time to respond to leads
  • Conversion Rate: Leads converted to actual sales
  • System Availability: Uptime and reliability metrics

Dashboard Features

  • Real-time conversation management
  • Lead qualification and scoring
  • Property matching results
  • Response time analytics
  • Message volume charts
  • Performance monitoring

🀝 Contributing

Development Guidelines

  1. Follow existing code structure and naming conventions
  2. Add tests for new functionality
  3. Update documentation for changes
  4. Ensure PDPL compliance for data handling
  5. Test thoroughly before submitting changes

Code Style

  • Use consistent indentation (2 spaces)
  • Add comments for complex logic
  • Follow JavaScript ES6+ standards
  • Use meaningful variable and function names
  • Implement error handling and logging

πŸ“ž Support & Contact

Crystal Power Investments

Technical Support

Legal & Compliance

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ† Acknowledgments

  • Crystal Power Investments LLC - Project sponsor and requirements
  • Meta WhatsApp Business API - Core messaging platform
  • Egypt PDPC - Data protection guidance and compliance framework
  • Open Source Community - Libraries and tools used in development

Built for Crystal Power Investments - Leading multi-sector investment strategy across financial assets, real estate, hospitality, and technology enablement across Egypt and regional markets.

This platform represents a complete, production-ready WhatsApp Business integration system designed specifically for real estate professionals who need to manage leads, automate responses, and close more deals through intelligent conversation management.

About

Crystal Power Investments - WhatsApp Business API Integration Platform for Real Estate Lead Generation and Property Matching

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published