Reggie SMS V2 Architecture
Status: Superseded by V3
Version: 2.0
Last Updated: 2026-01-10
Note: V2 has been superseded by V3 which addresses exhausted iterations, strict validation, and keyword-guessing issues. V2 remains as a fallback.
1. Overview
Reggie V2 is an intelligent, conversational SMS assistant for DSW staff. Unlike V1's rigid classification system, V2 uses a flexible architecture that:
- Remembers conversations - Knows what you asked before
- Searches multiple sources in parallel - Handbook, Discord, Deputy, Xero, Directory
- Understands authority - Admin guidance carries more weight than casual chat
- Synthesizes intelligent responses - One LLM call with full context
2. Architecture Flow
┌─────────────────────────────────────────────────────────────┐
│ REGGIE V2 PIPELINE │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ │
│ │ 1. IDENTIFY │ YP3000 lookup by phone number │
│ │ CALLER │ → identity_id, staff_id, name │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 2. LOAD HISTORY │ Last 6 messages within 24h │
│ │ │ → conversation context │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 3. EXTRACT │ LLM extracts topic, intent, │
│ │ TOPIC/INTENT │ search terms │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 4. PARALLEL │ ┌─────────────────────────────────┐ │
│ │ SOURCE SEARCH │ │ • Handbook (official policy) │ │
│ │ │ │ • Discord (team discussions) │ │
│ │ │ │ • Deputy (shifts, roster) │ │
│ │ │ │ • Xero (leave, pay) │ │
│ │ │ │ • Directory (who handles what) │ │
│ └────────┬─────────┘ └─────────────────────────────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 5. BUILD │ Combine results with authority │
│ │ CONTEXT │ weights into rich prompt │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 6. GENERATE │ GPT-4.1-mini with system prompt │
│ │ RESPONSE │ + context + conversation history │
│ └────────┬─────────┘ │
│ │ │
│ ┌────────▼─────────┐ │
│ │ 7. SAVE & SEND │ Store in reggie_conversations, │
│ │ │ send via Twilio │
│ └──────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
3. Knowledge Sources
3.1 Official Policy (Highest Authority)
- Source:
resources.documents/resources.chunks - Content: Employee Handbook V1.2026 (21 chunks, 3072-dim embeddings)
- Authority Weight: 1.0 (always authoritative)
- Search: Semantic vector search
3.2 Personal Data (Staff-Specific)
- Deputy: Shifts, roster, timesheets
- Xero: Leave balances, pay info
- Authority Weight: 1.0 (factual, personal)
3.3 Team Discussions (Contextual)
- Source:
comms.discord_messages(8,000+ messages, growing) - Content: Team chat history from Discord
- Authority Weight: Varies by author:
- CEO/COO: 0.8 (semi-official)
- Managers: 0.5 (guidance)
- Staff: 0.3 (contextual only)
- Search: Semantic vector search with recency weighting
3.4 Org Directory
- Source:
core_source.org_directory - Content: Who handles what, contact info
- Authority Weight: 1.0 (factual)
4. Authority System
4.1 Authority Table
comms.reggie_authority
- discord_user_id: Link to Discord
- name, title, department
- authority_level: 1-50 scale
- authority_domains: ['hr', 'operations', 'all']
4.2 Authority Levels
| Level | Role | Example |
|---|---|---|
| 50 | Executive | Sean (CEO) |
| 40 | C-Suite | Brett (COO) |
| 30 | Senior Management | Ami (GM) |
| 25 | Department Manager | Richelle (Service) |
| 20 | Specialist | Melanie (HR) |
| 15 | Officer | Ryan (Assets) |
| 10 | Support | Lloyd (Ops Support) |
| 1 | Staff | Regular employees |
4.3 How Authority Affects Responses
When searching Discord, messages from high-authority users are:
- Weighted higher in relevance scoring
- Labeled in context (e.g., "[Service Manager]")
- Given more credence by the LLM
5. Conversation Memory
5.1 Storage
comms.reggie_conversations
- phone_number: Who's texting
- direction: inbound/outbound
- message: The actual text
- topic: Extracted topic
- sources_used: Which sources contributed
- conversation_id: Thread grouping
5.2 Memory Window
- Last 6 messages
- Within 24 hours
- Passed to LLM as conversation history
5.3 Follow-up Detection
The topic extraction step identifies if a message is a follow-up:
- "What about next week?" → Follow-up to shift question
- "And sick leave?" → Follow-up to leave question
6. System Prompt
You are Reggie, a friendly and knowledgeable work assistant for DSW staff.
PERSONALITY:
- Warm, helpful, and professional
- Speak like a friendly colleague, not a robot
- Use Australian English (mate, cheers, no worries)
- Keep responses concise - this is SMS
AUTHORITY HIERARCHY:
1. Official Policy (Employee Handbook) - Always authoritative
2. Admin/Management guidance on Discord - Semi-official
3. General staff discussions on Discord - Contextual only
RULES:
- Never make up information
- For official policy, cite the handbook
- For Discord info, mention it's from team discussions
- If you can't help, direct to Staff Assist: (02) 8783 0544
7. Database Schema
Conversations Table
CREATE TABLE comms.reggie_conversations (
id UUID PRIMARY KEY,
phone_number VARCHAR(20),
identity_id UUID,
staff_id UUID,
staff_name VARCHAR(100),
direction VARCHAR(10),
message TEXT,
topic VARCHAR(50),
sources_used JSONB,
response_time_ms INTEGER,
conversation_id UUID,
created_at TIMESTAMPTZ
);
Authority Table
CREATE TABLE comms.reggie_authority (
id UUID PRIMARY KEY,
identity_id UUID,
discord_user_id VARCHAR(30),
name VARCHAR(100),
title VARCHAR(100),
authority_level INTEGER,
authority_domains TEXT[],
description TEXT,
is_active BOOLEAN
);
8. Files
| File | Purpose |
|---|---|
backend/services/reggie-sms-v2.js | Main V2 service |
backend/services/reggie-sms.js | V1 fallback |
backend/services/resource-kb.js | Handbook/document search |
bot/discord-kb-sync.js | Discord message sync & search |
backend/routes_v1p/sms.js | Twilio webhook handler |
9. Example Flow
Staff texts: "What's the dress code?"
- Identify: YP3000 → Sarah Johnson, staff
- History: No recent messages
- Topic:
policy, intent:question, terms:["dress code", "policy", "clothing"] - Search:
- Handbook: Found "Smart casual, closed-toe shoes..." (0.48 similarity)
- Discord: Found discussion in #general about polos
- Context: Handbook content prioritized over Discord
- Response: "Hey Sarah! The dress code is smart casual with closed-toe shoes. DSW polo for outings. No excessive jewellery or long nails. (Per the handbook)"
10. Fallback
If V2 fails for any reason, the system automatically falls back to V1:
try {
result = await reggieSmsV2.handleIncomingSMS(from, body);
} catch (err) {
console.log('Falling back to V1...');
result = await reggieSms.handleInboundSMS(from, body);
}
11. Future Enhancements
- Proactive alerts (expiring certs, upcoming shifts)
- Multi-turn conversation threading
- Admin dashboard for authority management
- Analytics on common questions
- Voice call integration (Dialpad)