WhatsApp Automation · Agent

WhatsApp Automation Agent —
One Number, Unlimited Businesses

A multi-tenant WhatsApp Automation Agent that serves schools, clinics, academies, and any business from a single WhatsApp number. Customers type a unique business code and get instantly connected to AI-powered 24/7 customer support — no staff required.

Platform WhatsApp Business API
Backend Node.js + Express
AI Model GPT-4o-mini
Database Supabase (PostgreSQL)
WhatsApp Automation SaaS Bot — Main Dashboard

Problem Statement

Schools, clinics, and small businesses worldwide face a recurring customer service crisis — hundreds of repetitive WhatsApp messages flood in every day, mostly after office hours when no one is available to respond. The real cost isn't just missed messages; it's lost trust, lost enrollments, and lost revenue.

No After-Hours Support

Staff goes offline at 5 PM. Parents and patients send messages at night and on weekends — and wait until morning for a reply, damaging trust and causing them to look elsewhere.

Endless Repetitive Queries

"Fees kya hain?", "Admission kab hota hai?", "Timing kya hai?" — the same 10–20 questions answered manually hundreds of times a week, consuming staff time that could go elsewhere.

Manual Broadcast Messages

Sending fee reminders, admission alerts, or announcements to hundreds of contacts manually takes hours — and there's no way to schedule or automate it without expensive tools.

Zero Visibility & Tracking

No record of who asked what, which questions are most common, or whether customers were satisfied. Businesses operate blind with no data to improve service.

High Cost of Human Receptionists

Hiring a full-time receptionist only to answer repetitive WhatsApp messages is expensive — and still leaves gaps during nights, weekends, and holidays.

The core challenge: Can one WhatsApp number serve multiple businesses simultaneously, with AI answering every question instantly from that business's own data — 24 hours a day?

Solution

A multi-tenant WhatsApp SaaS where each business gets a unique code. A customer types the code once — the bot identifies the business, connects to its data, and answers every question from that moment forward. One WhatsApp number, unlimited business tenants, zero manual effort after setup.

For Business Admin

  • Register on the admin dashboard
  • Add website URL, PDF, or manual data
  • Get a unique share link (e.g. wa.me/923...?text=ALNOOR745)
  • Share link on website, pamphlets, or school gate
  • Bot goes live — no further action needed

For Customer / Parent

  • Click the share link (WhatsApp opens)
  • Business code pre-filled — press Send
  • Bot connects instantly to that business
  • Ask any question — get instant AI answers
  • No app download, no login, no friction

The AI answers in a strict data priority order — keeping responses accurate and AI costs minimal:

1st Priority

Website Scrape — Fresh, auto-updated content from the business's own website

2nd Priority

PDF Upload — Fee structures, brochures, admission forms uploaded by admin

3rd Priority

Manual Data — Information typed directly by the admin in the dashboard

4th Priority

OpenAI GPT-4o-mini — Only called when no answer is found in the above sources

Platform in Action

The WhatsApp bot and admin dashboard working together to deliver seamless customer service.

Technical Architecture

The platform is built on Node.js with a clean multi-tenant architecture. Each business's data is fully isolated in Supabase. The system combines Meta's WhatsApp Business API, intelligent web scraping via Playwright, OpenAI GPT-4o-mini, and a 7-day Q&A cache to minimize costs.

┌─────────────────────────────────────────────────────┐
│                  CUSTOMER (WhatsApp)                │
│         "ALNOOR" / "fees?" / "admission info"       │
└────────────────────┬────────────────────────────────┘
                     │  HTTPS
                     ▼
┌─────────────────────────────────────────────────────┐
│           Meta WhatsApp Business API                │
│         Webhook: POST /webhook                      │
└────────────────────┬────────────────────────────────┘
                     │
                     ▼
┌─────────────────────────────────────────────────────┐
│              Node.js + Express Server               │
│  ┌──────────┐  ┌──────────┐  ┌───────────────────┐ │
│  │ webhook  │  │ scraper  │  │   scheduler       │ │
│  │ .js      │  │ .js      │  │   (cron jobs)     │ │
│  └──────────┘  └──────────┘  └───────────────────┘ │
│  ┌──────────┐  ┌──────────┐  ┌───────────────────┐ │
│  │  ai.js   │  │ database │  │   pdfParser.js    │ │
│  │ (OpenAI) │  │ .js      │  │                   │ │
│  └──────────┘  └──────────┘  └───────────────────┘ │
└──────────────┬──────────────────────────────────────┘
               │
        ┌──────┴──────┐
        ▼             ▼
  ┌──────────┐  ┌──────────────┐
  │ Supabase │  │  OpenAI API  │
  │ (DB)     │  │ GPT-4o-mini  │
  └──────────┘  └──────────────┘
               │
               ▼
        ┌──────────────┐
        │  Dashboard   │
        │  (Web UI)    │
        └──────────────┘

Key Features Built

Multi-Tenant Routing System

One WhatsApp number handles unlimited business tenants simultaneously. Phone-based routing maps each customer to their business — they type the code once, then every future message is automatically routed to the correct business data.

  • Unique business codes auto-generated (e.g. ALNOOR745)
  • Phone → business_id mapping stored in Supabase
  • Customers can switch businesses by typing a new code
  • Duplicate message prevention via in-memory Set

Full-Website Intelligent Scraper

The most complex module in the system — scrapes entire websites automatically and keeps content fresh. Built with Playwright as primary and Axios + Mozilla Readability as fallback.

  • Sitemap discovery via robots.txt — up to 80 URLs collected
  • Smart URL prioritization: fees, admission, contact pages first
  • Boilerplate removal — 40% threshold sliding window algorithm
  • Full SPA support including React HashRouter (#/fees, #/about)
  • Anti-bot bypass: Cloudflare detection, cookie consent dismissal

Cost-Optimized AI Engine

GPT-4o-mini is only called as a last resort — the system is designed to answer most questions from cached website content, eliminating the majority of API costs.

  • 7-day Q&A cache — 5,000 entries, oldest auto-evicted
  • 80,000 character website context + 20,000 character PDF context
  • Max 4 sentences per reply — optimized for WhatsApp
  • Custom agent instructions per business (language, tone, restrictions)

Automated Scheduler

Two cron jobs keep the system running without any manual intervention — websites stay current, follow-up messages go out on time.

  • Daily at 2 AM: MD5 hash check — re-scrape only changed websites
  • Every 5 minutes: scheduled follow-up messages sent automatically
  • Zero manual upkeep after initial setup

Admin Dashboard (Vanilla JS)

A clean, framework-free web dashboard for managing all tenants — no React, no heavy dependencies, just fast Vanilla JS that works on any device.

  • Overview: live stats — businesses, customers, messages today/total
  • Business management: add/edit/delete, data source status indicators
  • Per-business: website scrape trigger, PDF upload, manual data, AI instructions
  • Conversations: thread view by customer, filter by business
  • XSS protection via escHtml() on all user-rendered content

Admin Dashboard & Bot Screens

A closer look at the admin panel managing multiple business tenants and the bot answering customer queries in real time.

Customer Journey

From school admin setup to a parent getting an instant AI answer — the entire flow takes under 10 minutes to activate and runs on autopilot forever after.

StepWhoActionResult
1AdminCreates business on dashboardCode auto-generated: e.g. "ALNOOR745"
2AdminAdds website URL or uploads PDFBot scrapes and indexes all content
3AdminCopies share link from dashboardLink: wa.me/923...?text=ALNOOR745
4AdminShares link on website / pamphletsAny parent can now find and tap the link
5ParentTaps link → WhatsApp opens → SendsBot: "Welcome to Al-Noor School! What would you like to know?"
6Parent"Class 5 ki fees kya hain?"Bot answers instantly from scraped website data — no AI call needed

Challenges & How They Were Solved

Challenge 1: Cloudflare-Protected School Websites
Many school and business websites use Cloudflare, which blocks automated scrapers. Integrated Playwright with full browser simulation — behaves like real Chrome. When 2+ Cloudflare signatures are detected, the scraper gracefully skips the site rather than hanging.
Challenge 2: JavaScript-Rendered SPA Websites
React and Vue websites return empty HTML to standard HTTP scrapers. Playwright's headless Chrome executes JavaScript fully. Added specific support for React HashRouter — pages at /#/fees and /#/about are detected and scraped as individual pages.
Challenge 3: Controlling AI API Costs at Scale
With hundreds of daily messages across multiple businesses, uncached GPT calls would cost thousands per month. Three-layer cost control: 7-day Q&A cache eliminates repeated calls, data priority system answers from website cache first, and daily hash check prevents unnecessary re-scraping.
Challenge 4: Routing One Number to Multiple Businesses
A single WhatsApp number cannot natively serve multiple tenants. Built a phone-based routing system — each customer's phone number is mapped to a business_id in Supabase after their first code submission. All future messages from that number automatically route to the correct business context.
Challenge 5: Meta API Sending Duplicate Webhook Events
Meta's WhatsApp API occasionally sends the same webhook event twice, causing the bot to reply to the same message more than once. Fixed with an in-memory Set storing processed message IDs (max 1,000). Any ID already in the Set is silently skipped.
Challenge 6: Navigation and Footer Content Confusing the AI
Scraped content includes nav menus and footer links repeated across every page — this noise confuses GPT and inflates token usage. Implemented a 10-word sliding window boilerplate removal algorithm: any text chunk appearing on 40%+ of pages is removed before being sent to AI.

Tech Stack — Why These Choices

TechnologyRoleWhy Chosen
Node.js v20Backend runtimeAsync I/O handles multiple businesses simultaneously without blocking
ExpressWeb frameworkLightweight, fast REST API — minimal overhead for webhook processing
Supabase (PostgreSQL)DatabaseBuilt-in auth + real-time + generous free tier — no self-hosting needed
PlaywrightWeb scrapingIndustry-standard headless browser — handles Cloudflare and SPA sites
Mozilla ReadabilityContent extractionSame engine as Firefox Reader Mode — clean article-style text extraction
OpenAI GPT-4o-miniAI answers$0.15/1M tokens input — cheapest capable model for Q&A tasks
node-scheduleCron jobsReliable scheduling for daily scrape checks and follow-up messages
multerFile uploadsPDF upload handling with MIME type validation and 10MB size limit
Meta WhatsApp APIMessagingOfficial Business API — the only way to programmatically send/receive WhatsApp messages at scale

Performance Metrics

<200ms Cached response time
1–3s AI response time (live call)
7 days Q&A cache TTL
5,000 Max cache entries
10 MB Max PDF size
60 pages Max per website scrape

Value for Every Stakeholder

StakeholderWhat They Get
School / Clinic Admin24/7 automated replies — no staff needed after hours, zero repetitive manual answers
Parents / PatientsInstant answers at any time via WhatsApp — the app they already use daily
SaaS Owner (Yveloxy)One codebase serves unlimited paying clients — monthly recurring revenue with minimal maintenance
DeveloperClean modular architecture — easy to extend with new features or integrate new data sources

What I Learned

1
Multi-Tenant SaaS Architecture

Designing phone-based tenant routing from the start — rather than retrofitting it — saved enormous complexity. A clean mapping layer between incoming number and business context is the backbone of the entire system.

2
AI Cost Control is a Feature

Treating AI API calls as an expensive last resort — not the default — led to a smarter, cheaper architecture. The cache + priority system means most queries are answered without any AI call at all.

3
Web Scraping in the Real World

Real-world school and business websites are often messy — Cloudflare-protected, React-rendered, inconsistently structured. Building dual-mode scraping with intelligent fallbacks taught far more than any tutorial about production-grade crawlers.

4
Idempotency in Webhook Systems

External APIs like Meta's WhatsApp will send duplicate events. Every webhook-driven system needs idempotency built in from day one — the message ID dedup Set was a simple but critical safeguard.

Want WhatsApp automation for your school or business?

We build AI-powered WhatsApp bots that serve your customers 24/7 — answering from your own data, on your existing WhatsApp number, with zero manual effort. Serving clients in Pakistan, UAE, UK, US, and worldwide.