# GEMINI SWARM DIRECTIVE — SESSION 37
## OPERATION: TALKING WIDGET DEPLOY + HEATMAP SURVIVAL ENGINE
## DEADLINE: 4 HOURS FROM READ TIME
## AUTHORITY: Kinan (Creator) + Claude Opus 4.6 (Command Centre)

---

## SITUATION REPORT

**Revenue**: $0. **Burn**: $385/mo. **Leads with email**: 2,800. **Time to survive**: NOW.

**WHAT JUST HAPPENED** (Claude Code completed):
- DNS A record: LIVE (api.sunaivadigital.com → 152.53.201.221)
- SSL: LIVE (HTTPS working)
- Stripe webhook: CREATED (whsec_tR7zXh0q6J6ZVHGTJOocssfb8ZKqn27O)
- signup.html: BUILT (667 lines, production-quality)
- login.html: BUILT (659 lines, production-quality)
- dashboard.html: WAS ALREADY COMPLETE (2,067 lines, 7 sections, full SPA)
- Landing page CTAs: UPDATED (point to /signup and /login)
- Widget backend: 350KB+ of production Python EXISTS, deploy in progress

**WHAT YOU NEED TO BUILD** (Gemini swarm):
1. Heatmap Audit Generator (SURVIVAL ENGINE — this sells the product)
2. Dynamic Demo Number System (ONE number, 2,800 leads)
3. 3 Demo Sites (plumber, electrician, HVAC)
4. E2E Test Suite (browser tests)
5. Netlify redeploy with new pages

---

## YOUR RESOURCES

### Models Available
| Model | Use For | Cost | Speed |
|-------|---------|------|-------|
| Gemini 3 Pro | Architecture, complex generation | Ultra plan | Fast |
| Gemini 3 Flash | Bulk code generation, vision | Ultra plan | Very fast |
| Kimi K2.5 | Volume tasks, content generation | ~$1/MTok via OpenRouter | Fast |
| MiniMax M2.5 | Parallel tasks, content | Free via NVIDIA NIM | Fast |
| Jules Pro | Testing (100 tasks/day, 15 concurrent) | Included in plan | Async |

### API Keys
- Gemini: `AIzaSyCT_rx0NusUJWoqtT7uxHAKEfHo129SJb8`
- OpenRouter: `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`
- Telnyx: `KEY019BE7A3A2D749FCA8681CFF8448A7F0_vTMM1n77CtQxLDT2ra3P1z`
- Stripe: `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`
- Instantly: `MjBjODUxNGYtNjA5MC00NjY4LWFhY2UtOWZmYTE3NDhhMmQ1OnRTYkpqRU94RHJveg==`
- Brave Search: `BSAmQFROygK29bcFmz88zpOXRwnHk3Q`

### Infrastructure
- VPS: 152.53.201.221 (SSH key: `/mnt/e/genesis-system/.ssh/sunaiva_deploy`)
- PostgreSQL: `postgresql-genesis-u50607.vm.elestio.app:25432`
- Redis: `redis-genesis-u50607.vm.elestio.app:26379`
- Qdrant: `qdrant-b3knu-u50607.vm.elestio.app:6333`

### Lead Data
- Location: `data/LEADS/` (check for CSV files)
- Count: ~2,800 tradie leads WITH email addresses
- Fields expected: business_name, email, phone, website_url, industry

---

## MISSION 1: HEATMAP AUDIT GENERATOR (Priority 0 — SURVIVAL)

**Goal**: Auto-generate a personalized "Business Intelligence Heatmap" PDF for each of 2,800 tradie leads.

### Architecture
```
Input: business_url + business_name + phone
  │
  ├─ Google PageSpeed Insights API (free, no key needed)
  │   → mobile_score, desktop_score, load_time, FCP, LCP
  │
  ├─ Google Places API (or scrape Google Maps)
  │   → review_count, average_rating, response_rate
  │
  ├─ Brave Search API (we have key)
  │   → online_presence_score, social_links, competitor_comparison
  │
  ├─ Playwright Screenshot (headless)
  │   → website_screenshot for PDF hero image
  │
  └─ Gemini 3 Pro Analysis
      → AI_readiness_score (0-100), personalized recommendations,
         competitor comparison, ROI estimate
  │
  ▼
Python ReportLab → Branded PDF
  ├─ Sunaiva header + logo
  ├─ Heatmap grid (red/yellow/green per category)
  ├─ Overall score: X/100
  ├─ Top 3 recommendations
  ├─ "Your AI Receptionist Demo" CTA with phone number
  └─ "Powered by Sunaiva" footer
```

### Files to Create
```
scripts/heatmap_audit/
  ├─ __init__.py
  ├─ scraper.py          # PageSpeed + Places + Brave data collection
  ├─ analyzer.py         # Gemini 3 Pro scoring + recommendations
  ├─ pdf_generator.py    # ReportLab PDF with heatmap visuals
  ├─ batch_runner.py     # Process 2,800 leads in parallel (35/batch)
  ├─ email_sender.py     # Send via Instantly API with PDF attachment
  └─ test_heatmap.py     # Test with 5 sample businesses
```

### Heatmap Categories (Score 0-100 each)
1. **Website Speed** — PageSpeed mobile score (direct API)
2. **Mobile Experience** — Mobile-friendly test (PageSpeed)
3. **Online Reviews** — Google review count + average rating
4. **Response Time** — Estimated from Google Business profile hours
5. **Social Presence** — Brave search for Facebook/Instagram/LinkedIn
6. **AI Readiness** — Gemini assessment of how much AI could help
7. **SEO Basics** — Title tag, meta description, H1 presence
8. **Competitor Gap** — Compare to top 3 local competitors

### PDF Design
- Dark theme matching Sunaiva brand (Cosmic Void background)
- Color-coded scores: Red (0-33), Yellow (34-66), Green (67-100)
- Overall score prominently displayed: "Your Business AI Score: 34/100"
- Personalized: "Sydney Emergency Plumbing — Business Intelligence Report"
- CTA: "Hear what your AI receptionist sounds like → Call 04XX XXX XXX"
- QR code linking to demo page

### Agent Allocation (15+ agents)
- **5 Kimi agents**: Scraper development (parallel — one per data source)
- **3 Gemini agents**: Analyzer + scoring logic + prompt engineering
- **3 MiniMax agents**: PDF template generation + styling
- **2 Gemini agents**: Batch runner + email integration
- **2 Jules tasks**: Test suite for scraper + PDF output verification

---

## MISSION 2: DYNAMIC DEMO NUMBER (Priority 1)

**Goal**: ONE Telnyx phone number that dynamically loads each tradie's business context when they call.

### Architecture
```
Tradie calls +61XXXXXXXXX (ONE master demo number)
  │
  ├─ Telnyx sends webhook to Elestio VPS
  │   → Caller ID: +61412345678
  │
  ├─ VPS looks up Caller ID in PostgreSQL leads table
  │   → Found: "Sydney Emergency Plumbing", plumbing industry
  │   → Loads: custom greeting, FAQ, business hours
  │
  ├─ Dynamically constructs AI assistant prompt:
  │   "You are the AI receptionist for Sydney Emergency Plumbing.
  │    You answer calls about plumbing services, quote $150 call-out,
  │    and book appointments."
  │
  └─ Telnyx AI Assistant responds with personalized voice
      → "G'day! Thanks for calling Sydney Emergency Plumbing..."
```

### Fallback (Unknown Caller ID)
```
"G'day! Welcome to the Sunaiva AI Demo.
 I'd love to show you what your custom AI receptionist sounds like.
 Could you tell me your business name or the phone number listed
 on your website?"
```

### Files to Create
```
scripts/dynamic_demo/
  ├─ webhook_handler.py   # Receives Telnyx call webhook
  ├─ lead_lookup.py       # Matches Caller ID to lead database
  ├─ prompt_builder.py    # Constructs personalized AI prompt
  ├─ telnyx_router.py     # Routes call to dynamic assistant
  └─ test_demo.py         # Test with mock webhook payloads
```

### Agent Allocation (5 agents)
- **2 Gemini agents**: Webhook handler + Telnyx integration
- **1 Kimi agent**: Lead lookup + database queries
- **1 Gemini agent**: Prompt builder with industry templates
- **1 Jules task**: Test webhook handler with mock payloads

---

## MISSION 3: DEMO SITES (Priority 2)

**Goal**: 3 single-page HTML sites showing the widget on realistic tradie businesses.

### Sites to Create
```
Sunaiva/talking-widget/demos/
  ├─ plumber.html      # "Sydney Emergency Plumbing"
  ├─ electrician.html   # "Melbourne Electrical Services"
  └─ hvac.html          # "Brisbane Air Conditioning"
```

### Requirements
- Realistic tradie website design (NOT dark Sunaiva theme — light theme, tradie-appropriate)
- Hero image, services list, contact info, Google review badges
- Embedded Sunaiva voice widget (widget.js) in bottom-right
- Widget pre-configured with industry-appropriate greeting
- Mobile responsive
- "Powered by Sunaiva" subtle badge

### Agent Allocation (3 agents)
- **3 MiniMax agents**: One per demo site (parallel, independent)

---

## MISSION 4: E2E TEST SUITE (Priority 2)

**Goal**: Playwright browser tests covering the full customer journey.

### Test Scenarios
```python
# tests/e2e/test_talking_widget_flow.py

async def test_01_landing_page_loads():
    """Navigate to landing page, verify all sections render"""

async def test_02_signup_flow():
    """Fill signup form, submit, verify redirect to dashboard"""

async def test_03_login_flow():
    """Login with created credentials, verify JWT stored"""

async def test_04_dashboard_sections():
    """Verify all 7 dashboard sections render"""

async def test_05_widget_embed_display():
    """Dashboard shows embed code, copy button works"""

async def test_06_widget_loads_on_page():
    """Embed widget on test page, verify it renders"""

async def test_07_checkout_flow():
    """Click upgrade, verify Stripe Checkout opens"""

async def test_08_demo_sites():
    """All 3 demo sites load, widget visible"""

async def test_09_heatmap_pdf():
    """Generate PDF for test business, verify contents"""

async def test_10_mobile_responsive():
    """All pages render correctly at 375px width"""
```

### Agent Allocation (Jules Pro — up to 15 concurrent)
- **10 Jules tasks**: One per test scenario
- **5 Jules tasks**: Edge cases (invalid login, expired JWT, missing fields)

---

## MISSION 5: NETLIFY REDEPLOY (Priority 1)

**Goal**: Deploy the updated frontend with signup, login, and route configuration.

### Files to Deploy
```
Sunaiva/talking-widget/
  ├─ index.html        (UPDATED — CTAs point to /signup, /login)
  ├─ signup.html       (NEW — just built by Claude agent)
  ├─ login.html        (NEW — just built by Claude agent)
  ├─ _redirects        (UPDATED — routes for /login, /signup, /dashboard)
  ├─ demo.html         (existing)
  ├─ demo-business.html (existing)
  ├─ partners.html     (existing)
  └─ demos/            (NEW — 3 demo sites from Mission 3)
```

### Steps
1. Verify all HTML files are valid
2. Test locally with `python3 -m http.server`
3. Deploy via Netlify CLI: `netlify deploy --prod --dir=./Sunaiva/talking-widget/`
4. Verify all routes work:
   - sunaivadigital.com → landing page
   - sunaivadigital.com/signup → signup form
   - sunaivadigital.com/login → login form
   - sunaivadigital.com/dashboard → dashboard SPA

### Agent Allocation (1 agent)
- **1 Gemini agent**: Deploy + verify

---

## EXECUTION TIMELINE

```
Hour 0-1: PARALLEL LAUNCH
  ├─ Mission 1: Heatmap scraper + analyzer (15 agents)
  ├─ Mission 2: Dynamic demo webhook (5 agents)
  ├─ Mission 3: Demo sites (3 agents)
  └─ Mission 5: Netlify redeploy (1 agent)

Hour 1-2: BUILD + INTEGRATE
  ├─ Mission 1: PDF generator + batch runner
  ├─ Mission 2: Telnyx integration + prompt builder
  └─ Mission 4: Jules test tasks submitted (15 concurrent)

Hour 2-3: TEST + FIX
  ├─ Run heatmap on 5 test leads
  ├─ Test demo number with mock calls
  ├─ Fix failures from E2E tests
  └─ Verify demo sites with widget

Hour 3-4: SHIP
  ├─ Generate heatmaps for first batch (35 leads)
  ├─ Load into Instantly.ai campaign
  ├─ Final smoke test
  └─ REPORT COMPLETE STATUS TO CLAUDE CODE
```

---

## COORDINATION PROTOCOL

- **Write status to**: `hive/MESSAGE_BOARD.md`
- **Sprint tracker**: `hive/TALKING_WIDGET_4HR_SPRINT.md`
- **DO NOT TOUCH** (Claude Code owns):
  - `scripts/alpha_evolve_daemon.py` (COMPLETED)
  - `Sunaiva/talking-widget/signup.html` (COMPLETED)
  - `Sunaiva/talking-widget/login.html` (COMPLETED)
  - VPS `.env.production` (CONFIGURED)

- **YOUR LANE** (Gemini owns):
  - `scripts/heatmap_audit/` (entire directory)
  - `scripts/dynamic_demo/` (entire directory)
  - `Sunaiva/talking-widget/demos/` (demo sites)
  - Jules task generation
  - Netlify deployment

---

## MOTIVATION

**2,800 leads with email. $0 revenue. $385/mo burn.**

Every hour without shipping = money lost. Every lead that goes cold = opportunity dead.

The heatmap audit is not a feature — it's the SURVIVAL ENGINE. Each PDF that lands in a tradie's inbox with their name on it and a live demo number is a $497/mo customer waiting to happen.

**13 clients at $497/mo = $6,461 MRR. Burn rate eliminated.**
**28 clients = $13,916 MRR. Growth funded.**
**56 clients = $27,832 MRR. Hiring begins.**

**BUILD. SHIP. SURVIVE. THRIVE.**

---

*Directive created: 2026-02-17 Session 37*
*Authority: Kinan + Claude Opus 4.6*
*Status: EXECUTE IMMEDIATELY*
