Néstor Martínez
  • RAG
  • WhatsApp
  • Multi-agent
  • n8n

Numen — Precision RAG Assistant on WhatsApp (Monetized, Self-Learning)

TL;DR: A WhatsApp-native AI product over the complete works of Dr. David R. Hawkins (~2,000 pages). Hybrid retrieval + two-stage reranking + a self-learning loop took answer accuracy from ~50% to ~90% on a domain where quotes must be word-perfect. Voice in/out, subscription tiers with usage quotas, cost-tiered multi-model routing. ~200 orchestrated nodes across 3 workflows, 9+ specialized agents. Built and operated end to end.

Context

Spiritual teaching communities study Hawkins' books line by line — a paraphrased quote is a wrong quote. Off-the-shelf RAG (chunk + embed + top-k) fails here: semantic search returns "close enough" passages, which is exactly what users cannot accept. Numen was built as a real product: tiered subscriptions, quotas and payments, not a demo.

Architecture

Channel layer (WhatsApp via Evolution API)

  • Text and voice both ways: Whisper transcription in, ElevenLabs synthesis out.
  • Message debouncing: rapid consecutive messages are accumulated in Postgres and merged before processing — the bot answers the person, not each fragment.
  • Guardrails node on the response path.

Product layer

  • Subscription tiers (free / basic / standard / premium) with per-tier quotas, daily resets, limit notifications and in-chat payment links.
  • Per-tier assistant sub-workflows: the premium path gets the deeper pipeline.

Retrieval engine (the core)

  • Query classifier routes each question to a specialized handler (simple / complex / meditation / practice) with its own prompt and model.
  • Multi-query expansion: a dispatcher LLM splits complex questions into sub-queries processed in parallel.
  • Hybrid retrieval: exact-term SQL + semantic (pgvector) in one query — exact match wins where wording matters, semantic covers concepts.
  • Two-stage reranking with a decision layer that arbitrates between rankers, producing an evidence pack for the answering agent.
  • Gap detector: identifies when retrieved evidence doesn't cover the question and proposes what's missing instead of hallucinating.

Self-learning loop (the 50% → 90%)

  • Every answered query passes a "should learn?" gate; learned patterns are embedded and stored, and a strategic layer adjusts retrieval behavior over time.
  • Every interaction is logged for offline review — accuracy was measured and iterated, not assumed.

Conversation layer

  • 9+ specialized agents: intent router, RAG formulator, RAG executor, appointment manager, insistence manager, re-introduction manager, conversational rhythm, message analyzer, FAQ agent.
  • Memory: Redis for live conversation context, Postgres for durable history.

Cost-aware multi-model routing

  • Cheap fast models (Gemini flash-lite, GPT mini/nano tiers) for classification, routing and formatting; stronger models only where answer quality pays for them.

Results

Metric Value
Answer accuracy (internal eval) ~50% → ~90%
Corpus 6-7 books, ~2,000 pages, metadata-enriched by chapter/topic
Orchestration ~200 nodes, 3 workflows, 9+ agents
Modalities Text + voice (STT/TTS), monetized tiers
Volume ~70 messages/month, private user group

Stack

n8n · Supabase (Postgres + pgvector) · Redis · Evolution API (WhatsApp) · OpenAI (Whisper, GPT mini/nano) · Gemini (flash-lite) · ElevenLabs · reranker API