Spec
3.21.1 WhatsApp Stack Architecture
Specification, workflow, and technical reference for the whatsapp stack architecture module.
TEXTBOOK SPECIFICATION
1. The Current Stack: TimelinesAI
Closed-Source Legacy PatternCurrently, RAIA™ (Real estate Artificial Intelligence Agent) OS relies on TimelinesAI as an external, closed-source SaaS gateway. It provides a quick shared inbox UI but introduces significant systemic weaknesses:
Current closed-source data path
1. HIGH FINANCIAL TOLL
TimelinesAI charges massive monthly subscription fees per connected phone number, restricting our multi-agency and branch expansion scaling.
2. DATA LEAKAGE EXPOSURE
All tenant names, landlord contracts, and conversational PII transit through TimelinesAI's third-party external cloud, exposing our CIC legal wrapper to potential GDPR compliance breaches.
3. LATENCY & SILOS
Outbound and inbound webhooks suffer from SaaS queue latencies (often 5 to 12 seconds), slowing down real-time agentic response speeds.
4. SYSTEM DISCONNECTS
Standard WhatsApp Web session drift frequently disconnects, requiring manual re-scanning of QR codes. When TimelinesAI fails, our background AI goes blind.
2. The Proposed Stack: Self-Hosted Evolution API
Data Sovereignty & Ultra-Low LatencyWe propose migrating to Evolution API (or a self-hosted WPPConnect / Baileys Node). Running as a Dockerized container directly on our Tailscale VPN subnet, it bypasses SaaS systems completely:
Sovereign, self-hosted data path
1. ZERO LICENSING COST
Connect unlimited phone numbers and agents without licensing friction. Add numbers for branches, departments, or individual agent personas on the fly.
2. ABSOLUTE DATA PRIVACY
All message payload caches, SQLite session states, and credentials reside entirely inside our private Tailscale VPN servers. Zero external exposures.
3. SUB-MILLISECOND WEBHOOKS
Webhooks deliver locally inside the LAN with sub-millisecond latencies, enabling our reactive AI loops to trigger and reply almost instantaneously.
4. ROBUST AUTO-RECONNECTS
The self-hosted NodeJS daemon maintains persistent web socket configurations and automatically self-heals dropped connections without human scans.
3. Deep Architecture Comparison
| Capability | TimelinesAI (SaaS Web Wrapper) | Evolution API (Self-Hosted Open-Source) |
|---|---|---|
| Hosting & Control | Hosted on third-party public cloud. Closed-source. | Self-hosted inside private Tailscale VPN. 100% open-source. |
| Scaling Costs | High monthly flat fee per connected number. | **Zero cost**. Limited only by local server RAM/CPU. |
| Conversational Freedom | Unrestricted. (Send free-form texts without templates). | Unrestricted. (Uses Baileys WS emulation). |
| Agent Inbox Interface | Excellent out-of-the-box shared inbox web portal. | None built-in. Requires our custom Next.js UI integration. |
| Security & Encryption | Credentials and chat logs stored on external servers. | Private keys & Redis tokens encrypted locally in Tailscale. |
| Webhook Latencies | 5s to 12s queue-based latency. | Sub-millisecond direct internal LAN delivery. |
4. Developer Integration Blueprint (Direct API Call)
Developers can directly swap the comms backend transport inside comms-delivery-engine by executing direct Evolution API payloads:
NodeJS / Evolution API
// Sending a free-form WhatsApp message autonomously via Self-Hosted Evolution API Node
const axios = require('axios');
async function sendSovereignWhatsApp(number, message) {
const EVOLUTION_API_URL = "http://100.120.31.7:8080"; // Private Tailscale IP
const INSTANCE_KEY = process.env.EVOLUTION_INSTANCE_KEY;
const API_TOKEN=proces...
const payload = {
number: number, // E.g., "447551234567"
options: {
delay: 1200, // Natural human typing delay simulation
presence: "composing"
},
textMessage: {
text: message
}
};
try {
const res = await axios.post(
`${EVOLUTION_API_URL}/message/sendText/${INSTANCE_KEY}`,
payload,
{ headers: { "apikey": API_TOKEN } }
);
return res.data;
} catch (err) {
console.error("Evolution API failure:", err.message);
throw err;
}
}