Sync vault notes: April-November 2026 sessions, projects, and architecture
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe4fe656be
commit
994c7ae577
379 files changed
+55216
-107
No files matched your search
@@ -0,0 +1,199 @@
|
||||
# SquareMCP Products — Navigation & Planning Hub
|
||||
|
||||
**Updated:** 2026-06-15
|
||||
**Purpose:** Central index for all SquareMCP product specs, roadmaps, and planning documents
|
||||
**For:** Product managers, engineers, designers, marketers, and AI agents
|
||||
|
||||
---
|
||||
|
||||
## Current Products
|
||||
|
||||
### 1. Living Brief (v1 — Launched June 13, 2026)
|
||||
|
||||
**Status:** ✅ LIVE
|
||||
**What it is:** User-owned Obsidian vault that follows you across ChatGPT, Claude, and other AI agents
|
||||
**Target:** Multi-agent users who need persistent context
|
||||
**Key docs:**
|
||||
- `2026-06-13-office-hours-chatgpt-living-brief-session.md` — GTM & positioning
|
||||
- `2026-06-13-chatgpt-living-brief-full-session-sanitized.md` — Implementation details
|
||||
|
||||
---
|
||||
|
||||
### 2. Chat-First Communications Manager (Next — In Development)
|
||||
|
||||
**Status:** 🔨 APPROVED DESIGN — Ready for engineering sprint
|
||||
**What it is:** AI-powered communications operator for non-technical SMB professionals (mortgage brokers, publishers, coaches)
|
||||
**Target:** Independent professionals spending 3-5+ hours/week on manual social + email posting
|
||||
**Key metric:** 1 week of multi-platform content in <15 minutes
|
||||
**Key doc:** **→ START HERE:** `chat-first-communications/2026-06-15-comprehensive-product-spec.md`
|
||||
|
||||
**Quick links within that doc:**
|
||||
- **Product managers:** Sections II (Problem), III (Users), IV (Spec), VIII (Metrics)
|
||||
- **Engineers:** Sections V (Architecture), VI (Roadmap), IX (Technical Q's)
|
||||
- **Designers:** Section IV.3 (Chat UI), IV.4 (Platforms), onboarding flow
|
||||
- **Marketers:** Sections III (Personas), VII (GTM), IX (Marketing Q's)
|
||||
- **Social/Content teams:** Sections I, II, VII.2 (Distribution), VII.3 (Messaging)
|
||||
|
||||
---
|
||||
|
||||
### 3. Future Products (Planned)
|
||||
|
||||
| Product | Target | Status | Earliest Launch |
|
||||
|---------|--------|--------|-----------------|
|
||||
| **Social Publisher (Post-MVP)** | Communications retention + expansion | Planned for Phase 2 | Aug 2026 |
|
||||
| **Marketing Intelligence Co-Pilot** | Lodge Brothers / Alex Ferrari vertical | Design approved 2026-06-04 | Phase 2-3 |
|
||||
| **WhatsApp Business Automation** | Mortgage broker follow-up (inbound) | Technical spec ready | Jul 2026 |
|
||||
| **Email Newsletter Builder** | Publishers + coaches | Planned | Q3 2026 |
|
||||
| **Team Collaboration** | Agencies, brokerages | Planned Phase 3 | Q3 2026 |
|
||||
|
||||
---
|
||||
|
||||
## How to Use This Hub
|
||||
|
||||
### If you're a **product manager** refining the roadmap:
|
||||
1. Read `2026-06-15-comprehensive-product-spec.md` — Sections I-III
|
||||
2. Review success gates in Section VIII
|
||||
3. Check "Open Questions" in Section IX for decisions needed
|
||||
4. Cross-reference `2026-06-04-marketing-intelligence-lodge-first.md` for Alex/Lodge context
|
||||
|
||||
### If you're an **engineer** starting the sprint:
|
||||
1. Read `chat-first-communications/2026-06-15-comprehensive-product-spec.md` — Sections V & VI
|
||||
2. Map out database schema (Section V.1)
|
||||
3. Estimate effort for each phase
|
||||
4. Identify blockers in Section IX
|
||||
|
||||
### If you're a **designer** building the UI:
|
||||
1. Read `2026-06-15-comprehensive-product-spec.md` — Sections IV.3 & IV.4
|
||||
2. Study the flow diagram in 4.1
|
||||
3. Note constraints: mobile responsiveness, vertical-aware prompt chips
|
||||
4. Design approval flow (4.6)
|
||||
|
||||
### If you're a **marketer** planning the launch:
|
||||
1. Read `2026-06-15-comprehensive-product-spec.md` — Sections III, VII, VIII
|
||||
2. Review customer personas in detail (Section III)
|
||||
3. Plan GTM sequence: direct outreach (Alex) → case studies → organic → paid
|
||||
4. Draft positioning for each vertical (mortgage brokers vs. publishers)
|
||||
|
||||
### If you're a **social/content team** building awareness:
|
||||
1. Read `2026-06-15-comprehensive-product-spec.md` — Sections I, II, VII.2
|
||||
2. Extract key narrative: "Mortgage broker who spent 5 hours/week posting now does it in 15 minutes"
|
||||
3. Plan content pillars:
|
||||
- **Founder story:** "I automated my social marketing"
|
||||
- **Customer story:** Alex Ferrari / Lodge Brothers case study (post-MVP)
|
||||
- **Product story:** "Talk to Claude. It posts for you."
|
||||
- **Social proof:** Testimonials from pilot users
|
||||
|
||||
### If you're an **AI agent** (future work):
|
||||
This document is designed to be machine-readable. Every section is:
|
||||
- **Clearly labeled** with purpose and audience
|
||||
- **Structured** with headings, tables, JSON examples
|
||||
- **Actionable** with explicit next steps
|
||||
- **Linked** to related documents in Obsidian
|
||||
|
||||
**Quick reference:** Search vault for "comprehensive-product-spec" to find the full canonical spec.
|
||||
|
||||
---
|
||||
|
||||
## Key Contexts
|
||||
|
||||
### The Mortgage Broker Wedge (Why this vertical first?)
|
||||
|
||||
From customer interview (2026-05-13):
|
||||
> "I send out lots of emails and social media, it burns my time, and I get little response. I want a way to push out information and videos and monitor my email and respond with appropriate answers and questions."
|
||||
|
||||
**Signals:**
|
||||
- Acute pain (lost leads, wasted time, low conversion)
|
||||
- High willingness to pay ($99-300/month earns $150k-500k/year)
|
||||
- Network effects (loan officers refer to loan officers)
|
||||
- Compliance moat (NMLS/TILA/RESPA create defensibility)
|
||||
- First hot customer: Alex Ferrari (Lodge Brothers) replied twice in 24 hours to initial demo
|
||||
|
||||
### The Product Positioning (Why "Chat-First Communications Manager"?)
|
||||
|
||||
**NOT:** Generic AI content generator, social media scheduling tool, MCP integration platform
|
||||
|
||||
**IS:** An AI communications operator that learns your voice, understands your vertical (mortgage, publishing, coaching), and executes your outbound + inbound workflows with human approval
|
||||
|
||||
**Differentiation:**
|
||||
- Chat-first (vs. form-based scheduling tools like Buffer)
|
||||
- Vertical-aware (vs. generic content generation)
|
||||
- Learning system (vs. one-off generation)
|
||||
- Trust ladder (approval → autonomous mode progression)
|
||||
- Compliance built-in (NMLS disclaimers, regulatory guardrails)
|
||||
|
||||
---
|
||||
|
||||
## Timeline & Milestones
|
||||
|
||||
| Date | Milestone | Status |
|
||||
|------|-----------|--------|
|
||||
| 2026-06-13 | Living Brief launches on ChatGPT | ✅ Done |
|
||||
| 2026-06-15 | Chat-First spec published (this doc) | ✅ Done |
|
||||
| 2026-07-01 | Chat-First v1 MVP shipped | 🔨 In progress |
|
||||
| 2026-07-15 | Alex Ferrari + publisher pilot completing (4+ weeks) | 📋 Scheduled |
|
||||
| 2026-08-01 | Public launch on ChatGPT / Claude GPT stores | 📋 Scheduled |
|
||||
| 2026-08-15 | First 20 paid customers acquired | 📋 Target |
|
||||
| 2026-09-01 | Phase 2 expansion features (scheduling, real estate vertical) | 📋 Planned |
|
||||
|
||||
---
|
||||
|
||||
## Document Locations
|
||||
|
||||
All product documents live in the SquareMCP vault under `/SquareMCP/products/`:
|
||||
|
||||
```
|
||||
SquareMCP/
|
||||
├── products/
|
||||
│ ├── README.md (← you are here)
|
||||
│ ├── chat-first-communications/
|
||||
│ │ └── 2026-06-15-comprehensive-product-spec.md
|
||||
│ └── living-brief/
|
||||
│ ├── 2026-06-13-office-hours-chatgpt-living-brief-session.md
|
||||
│ └── 2026-06-13-chatgpt-living-brief-full-session-sanitized.md
|
||||
├── 2026-06-13-office-hours-chatgpt-living-brief-gtm-design.md
|
||||
├── 2026-06-04-marketing-intelligence-lodge-first.md
|
||||
└── [other SquareMCP docs]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Getting Unstuck
|
||||
|
||||
**If you're unclear on:** → **Check this section:**
|
||||
- Product positioning | 7.1 (Positioning) + this README's "Product Positioning"
|
||||
- Customer personas | Section III (Target Users)
|
||||
- Technical architecture | Section V (Tech Architecture)
|
||||
- Implementation timeline | Section VI (Roadmap)
|
||||
- Go-to-market strategy | Section VII (GTM)
|
||||
- Success criteria | Section VIII (Metrics)
|
||||
- Open decisions | Section IX (Open Questions)
|
||||
|
||||
**If you need:** → **Do this:**
|
||||
- To start engineering | Read Sections V & VI; estimate effort
|
||||
- To finalize pricing | Run sensitivity analysis on mortgage broker WTP (~$99-300/month)
|
||||
- To write social copy | Extract narratives from Sections II (problem) & VII.2 (distribution)
|
||||
- To onboard new contributor | Point them to Section X (Use Cases for Different Audiences)
|
||||
- To make a decision | Check Section IX for the open question + recommendation
|
||||
|
||||
---
|
||||
|
||||
## Feedback & Updates
|
||||
|
||||
This hub is a living document. As the product evolves:
|
||||
1. Update existing docs in place (use `updated_at` timestamps)
|
||||
2. Link new related docs here
|
||||
3. Archive completed milestones
|
||||
4. Keep Section III (Future Products) current
|
||||
|
||||
**Last updated:** 2026-06-15 by Claude Code
|
||||
**Next review:** After Chat-First v1 MVP ships (target: 2026-07-01)
|
||||
|
||||
|
||||
## Phase 1 Engineering Sprint Plan (added 2026-06-15)
|
||||
**→** `chat-first-communications/2026-06-15-phase1-mvp-sprint-plan.md` — Week-by-week backlog for the Chat-First Communications Manager Phase 1 MVP (Sections IV/V/VI of the comprehensive spec, broken into day-level tasks). Exit criterion is "ready for Alex Ferrari + publisher pilot," not a ChatGPT Store listing — that follows pilot gates per Section VII.2/VIII.
|
||||
|
||||
|
||||
|
||||
## Phase 1 Engineering Design Doc (added 2026-06-15)
|
||||
**→** `chat-first-communications/2026-06-15-phase1-engineering-design.md` — Expanded DDL (with FKs/indexes/CHECK constraints), API contracts, generation pipeline design (per-platform parallel Claude calls), compliance injection, and approval/publish sequence for the Phase 1 sprint plan above. Includes a "Deviations from Spec" section (new `drafts.generation_id`, `business_profiles.email_recipients`) and open items for the engineer to confirm before Week 1.
|
||||
|
||||
+800
@@ -0,0 +1,800 @@
|
||||
# SquareMCP Chat-First Communications Manager
|
||||
## Comprehensive Product Specification & Implementation Guide
|
||||
|
||||
**Date:** 2026-06-15
|
||||
**Status:** APPROVED DESIGN — Ready for implementation
|
||||
**Primary Audience:** Product managers, engineers, designers, marketers, social media teams, future AI agents
|
||||
**Repo:** `hermes-mcp`
|
||||
**Related:** Living Brief (v1 — launched 2026-06-13)
|
||||
|
||||
---
|
||||
|
||||
## I. Executive Summary
|
||||
|
||||
### What It Is
|
||||
**SquareMCP Chat-First Communications Manager** is an AI-powered communications operator that allows non-technical business professionals to manage their entire outbound and inbound communication workflow through natural conversation.
|
||||
|
||||
### One-Sentence Pitch
|
||||
> Talk to Claude about your business. It drafts, adapts, and publishes your communications across email and social platforms with your approval — learning your voice with every post.
|
||||
|
||||
### Core Value Proposition
|
||||
- **Time savings:** 1 week of multi-platform content in under 15 minutes
|
||||
- **Effectiveness:** AI understands vertical-specific strategies (mortgage brokers know what drives leads)
|
||||
- **Control:** Human approval on every post before publishing; trust ladder to autonomy
|
||||
- **Compliance:** Built-in regulatory guardrails (NMLS, state disclosures, financial disclaimers)
|
||||
- **Learning:** System learns user's approved style and improves drafts over time
|
||||
|
||||
### Market Position
|
||||
This is NOT:
|
||||
- Buffer/Hootsuite with AI (that's still a scheduling tool)
|
||||
- Generic AI content generator
|
||||
- MCP integration platform for developers
|
||||
|
||||
This IS:
|
||||
- An AI communications operator for relationship-driven SMB professionals
|
||||
- A new product category: "talk to your business manager, it executes"
|
||||
|
||||
---
|
||||
|
||||
## II. Problem Statement & Demand Evidence
|
||||
|
||||
### The Problem
|
||||
|
||||
Non-technical business professionals (mortgage brokers, publishers, real estate agents, coaches, consultants) experience:
|
||||
|
||||
1. **Outbound inefficiency:** Manual copy-paste across 3-5 platforms takes 3-5 hours/week
|
||||
2. **Effectiveness gap:** "I send lots of emails and social media, it burns my time, and I get little response"
|
||||
3. **Inconsistent presence:** Sporadic posting = invisible online = lost visibility and referrals
|
||||
4. **Lost leads:** Slow follow-up means competitors get the customer
|
||||
5. **No system:** Each tool (Buffer, email, Facebook, LinkedIn) is a separate workflow
|
||||
|
||||
### Demand Evidence
|
||||
|
||||
**Mortgage broker interview (2026-05-13):**
|
||||
> "I send out lots of emails and social media, it burns my time, and I get little response. I want a way to push out information and videos and monitor my email and respond with appropriate answers and questions."
|
||||
|
||||
**Key signals from this quote:**
|
||||
1. "Gets little response" = effectiveness problem, not just time-saving
|
||||
2. "Videos" = first-class content need
|
||||
3. "Monitor email and respond" = inbound management is as critical as outbound posting
|
||||
|
||||
**First two pilot customers:**
|
||||
- **Matthew:** Product launch context (not primary verticals, but validates cross-agent continuity need)
|
||||
- **Alex Ferrari (Lodge Brothers):** Mortgage broker actively seeking WhatsApp + email + social coordination. Two replies to initial demo in 24 hours = hot signal.
|
||||
|
||||
**Publisher ready to pilot:** Book/magazine publisher, same outbound + inbound pain, different content type.
|
||||
|
||||
---
|
||||
|
||||
## III. Target Users & Customer Personas
|
||||
|
||||
### Primary Wedge: Mortgage Broker (Highest Confidence)
|
||||
|
||||
| Attribute | Profile |
|
||||
|-----------|---------|
|
||||
| **Role** | Independent loan officer, 5-30 originations/month |
|
||||
| **Pain** | Rate update blasts, pre-approval follow-up, closing reminders across WhatsApp, email, Facebook |
|
||||
| **Current solution** | Manual copy-paste, SimpleTexting, BombBomb (email-only video) |
|
||||
| **Willingness to pay** | $99-300/month (earns $150k-500k/year; one extra deal = $3k-15k commission) |
|
||||
| **Network effects** | Brokers talk to brokers; Facebook groups are primary discovery channel (50k-200k members) |
|
||||
| **Compliance burden** | NMLS/TILA/RESPA requirements; compliance-ready templates are a competitive advantage |
|
||||
| **Success signal** | Repeats rate update workflow weekly; invites peers; makes payment without prompting |
|
||||
|
||||
### Secondary: Publisher
|
||||
|
||||
| Attribute | Profile |
|
||||
|-----------|---------|
|
||||
| **Role** | Book author, magazine editor, content producer |
|
||||
| **Pain** | Manual promotion across LinkedIn, Instagram, email; inconsistent publishing schedule |
|
||||
| **Current solution** | Manual posting + Buffer for scheduling |
|
||||
| **Willingness to pay** | $49-99/month (revenue varies; book launch drives 2-3 month peaks) |
|
||||
| **Network effects** | Slower; word-of-mouth through publishing communities |
|
||||
| **Success signal** | Uses for book launches + ongoing author platform building; stays past first month |
|
||||
|
||||
### Tertiary (Future): Real Estate, Coaches, Consultants
|
||||
|
||||
Defer these until mortgage broker vertical is proven.
|
||||
|
||||
---
|
||||
|
||||
## IV. Product Specification
|
||||
|
||||
### 4.1 Core User Flow
|
||||
|
||||
```
|
||||
User signs up
|
||||
↓
|
||||
Guided onboarding (business profile + vertical selection)
|
||||
↓
|
||||
Vertical-aware prompt suggestions appear
|
||||
↓
|
||||
User types or selects a prompt: "Write me a rate update post"
|
||||
↓
|
||||
Claude generates multi-platform variants simultaneously
|
||||
↓
|
||||
User reviews, optionally edits individual platform versions
|
||||
↓
|
||||
User clicks "Approve & post" or "Approve & schedule"
|
||||
↓
|
||||
Posts publish immediately or at scheduled time
|
||||
↓
|
||||
System records approved post in user_content_examples
|
||||
↓
|
||||
After 10+ approvals: "Autonomous mode" toggle appears
|
||||
↓
|
||||
Optional: Enable auto-posting; future approved content posts without review
|
||||
```
|
||||
|
||||
### 4.2 Onboarding
|
||||
|
||||
**Objective:** Eliminate blank canvas. Guide new users to immediate value in under 5 minutes.
|
||||
|
||||
**Steps:**
|
||||
|
||||
1. **Business Profile Form** (required fields)
|
||||
- Business type: dropdown → [Mortgage Broker, Publisher, Real Estate, Coach, Consultant, Other]
|
||||
- Vertical-specific fields load:
|
||||
- **Mortgage Broker:** NMLS number, state(s) of licensure, required disclosure text
|
||||
- **Publisher:** Book title(s), target audience (indie, traditional, hybrid), genres
|
||||
- **Real Estate:** MLS region, primary listing types, target demographic
|
||||
- Tone preference: [Professional, Conversational, Energetic, Educational]
|
||||
- Primary platforms: checkboxes → [LinkedIn, Facebook, Instagram, Email]
|
||||
- Optional: Brand voice examples (paste 1-2 previous posts they like)
|
||||
|
||||
2. **First Suggested Prompts** (vertical-aware)
|
||||
- Mortgage Broker chips: "Rate update," "New listing," "Market commentary," "Client testimonial request," "Refinance education"
|
||||
- Publisher chips: "Book announcement," "Author bio," "Excerpt preview," "Behind-the-scenes," "Reader testimonial"
|
||||
- User taps one or types freely
|
||||
|
||||
3. **First Generation** (pre-generated async)
|
||||
- Claude generates 4 platform variants for user's selected platforms
|
||||
- Results shown immediately (or in <5sec if async)
|
||||
- User edits or approves each platform individually
|
||||
|
||||
4. **Approval & First Post**
|
||||
- One-click "Approve & post all" or individual platform toggles
|
||||
- Success state: "Your first post is live. Continue in chat or see all posts here."
|
||||
|
||||
**Success criteria for onboarding:** User reaches their first approved post in under 5 minutes without coaching.
|
||||
|
||||
### 4.3 Chat Interface
|
||||
|
||||
**Technology:** Web SPA (React) at `app.squaremcp.com` with chat panel.
|
||||
|
||||
**Interaction:**
|
||||
- Left panel: Conversation history (reads from `chat_sessions` table)
|
||||
- Right panel: Live draft previews for each enabled platform
|
||||
- Bottom: Input field + "Generate," "Approve & post," "Schedule" buttons
|
||||
|
||||
**Prompt Input Options:**
|
||||
1. Free-form natural language: "Write a post about rate drops affecting refinance demand"
|
||||
2. Vertical-aware chips (contextual suggestions change weekly)
|
||||
3. Template picker (future): pre-built structures like "testimonial request" or "market update"
|
||||
|
||||
**Draft Preview:**
|
||||
- Tabs for each platform (LinkedIn, Facebook, Instagram, Email)
|
||||
- Each platform shows:
|
||||
- Generated text (truncated to platform character limit)
|
||||
- Platform-specific metadata (hashtags for Instagram, subject line for email)
|
||||
- "Regenerate this platform" button (if one platform's draft is weak)
|
||||
- Edit box for user tweaks before approval
|
||||
|
||||
**Generation behavior:**
|
||||
- All platform variants generated in parallel (not sequentially)
|
||||
- If one platform fails (e.g., Instagram credentials invalid), show error state but don't block others
|
||||
- Partial failure is recoverable: user regenerates just that platform
|
||||
|
||||
### 4.4 Platform Support & Content Specifications
|
||||
|
||||
| Platform | v1 Status | Content Type | Limits | API Method | Notes |
|
||||
|----------|-----------|--------------|--------|-----------|-------|
|
||||
| **LinkedIn** | Launch | Text post | 800-1300 chars | REST API `/share` | Long-form, bullet-friendly, B2B tone |
|
||||
| **Facebook** | Launch | Text + optional image | 150-400 chars | Graph API `/feed` | Conversational, personal tone |
|
||||
| **Instagram** | Deploy before launch | Caption + hashtags | 138-150 chars | Graph API `/caption` | User provides image URL; Claude generates caption + 5-10 hashtags |
|
||||
| **Email** | Launch | Subject + body | Subject 50 chars, body 200-400 | SMTP via `smtp.ts` | Uses existing `email_accounts` table, per-customer SMTP |
|
||||
| **WhatsApp** | Post-MVP | Business template messages | Platform limits | Twilio API | Requires WhatsApp Business Account approval; valuable for mortgage follow-up |
|
||||
| **TikTok** | Not v1 | Video + caption | Platform limits | Pending app review | Out of scope for v1 |
|
||||
| **Discord** | Not v1 | Text + embeds | Platform limits | REST API | Niche; low priority for initial verticals |
|
||||
|
||||
**Instagram v1 workflow:**
|
||||
- User has option to provide image URL or skip
|
||||
- If image provided: Claude generates caption + hashtags optimized for the image
|
||||
- If no image: Caption generated but marked as "image required before posting"
|
||||
- User can paste image URL in chat or upload directly (UI design pending)
|
||||
|
||||
### 4.5 Content Generation System Prompt
|
||||
|
||||
Claude's system prompt includes:
|
||||
|
||||
```
|
||||
You are an AI communications operator for [business_type] professionals.
|
||||
Your user is a [vertical] who [pain_point].
|
||||
They have requested: [user_prompt]
|
||||
|
||||
Generate multi-platform content variants optimized for each platform's audience and format:
|
||||
- LinkedIn: Professional, value-driven, longer-form (800-1300 chars)
|
||||
- Facebook: Conversational, personal touch (150-400 chars)
|
||||
- Instagram: Energetic, hashtag-rich, caption format (138-150 chars)
|
||||
- Email: Direct, scannable, clear CTA (subject + body)
|
||||
|
||||
Important constraints:
|
||||
[VERTICAL-SPECIFIC CONSTRAINTS]
|
||||
|
||||
Examples of this user's previously approved style:
|
||||
[user_content_examples — last 3 approved posts per platform]
|
||||
|
||||
Generate now. Format as JSON:
|
||||
{
|
||||
"linkedin": "...",
|
||||
"facebook": "...",
|
||||
"instagram": { "caption": "...", "hashtags": ["...", ...] },
|
||||
"email": { "subject": "...", "body": "..." }
|
||||
}
|
||||
```
|
||||
|
||||
**Vertical-specific constraints (baked into prompt):**
|
||||
- **Mortgage Broker:** Always append NMLS disclaimer if content mentions rates, loans, APR, or financial advice. Format: "[NMLS #X, licensed in CA/TX/NY]. This is not an offer to enter into an agreement. Not all customers will qualify. Information is subject to TILA."
|
||||
- **Publisher:** Avoid spoilers unless explicitly requested. Include call-to-action (buy link, mailing list signup).
|
||||
- **Real Estate:** Include fair housing disclaimer if property/neighborhood is mentioned.
|
||||
|
||||
### 4.6 Approval & Publishing Workflow
|
||||
|
||||
**Draft Review:**
|
||||
1. User sees all platform variants simultaneously
|
||||
2. User can:
|
||||
- Click "Approve & post all" → publishes to all platforms immediately
|
||||
- Toggle individual platforms on/off before approving
|
||||
- Click "Edit" on any platform to fine-tune before approval
|
||||
- Click "Regenerate" on weak drafts
|
||||
|
||||
**Posting:**
|
||||
- Once approved, post is pushed to all enabled platforms via their respective APIs
|
||||
- Errors on individual platforms are logged but don't stop other platforms
|
||||
- User receives confirmation: "Posted to LinkedIn, Facebook. Instagram failed (invalid credentials). Regenerate and retry?"
|
||||
|
||||
**Scheduling (v1.1+):**
|
||||
- User can choose "Post now" or "Schedule for [date/time]"
|
||||
- Scheduled posts queued in `scheduled_posts` table
|
||||
- Background job (cron) publishes at scheduled time
|
||||
- User can reschedule or cancel before publish time
|
||||
|
||||
### 4.7 Learning System: `user_content_examples`
|
||||
|
||||
**Purpose:** System learns from approved posts; future generations improve based on user's approved style.
|
||||
|
||||
**Schema:**
|
||||
```sql
|
||||
CREATE TABLE user_content_examples (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
platform VARCHAR(50),
|
||||
original_prompt TEXT,
|
||||
approved_text TEXT,
|
||||
metadata JSON, -- {hashtags, tone, length, etc.}
|
||||
created_at TIMESTAMP,
|
||||
feedback_score INT DEFAULT 0 -- user can upvote/downvote for future learning
|
||||
);
|
||||
```
|
||||
|
||||
**Workflow:**
|
||||
1. User approves a post → automatically inserted into `user_content_examples`
|
||||
2. At next generation time, system queries:
|
||||
```sql
|
||||
SELECT approved_text FROM user_content_examples
|
||||
WHERE user_id = ? AND platform = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 3;
|
||||
```
|
||||
3. Those 3 approved posts are injected into Claude's system prompt as style examples
|
||||
4. Claude generates new variants influenced by past approved style
|
||||
|
||||
**Future enhancement (post-MVP):** Add thumbs-up/thumbs-down on generated drafts to weight examples.
|
||||
|
||||
### 4.8 Autonomous Mode (Trust Ladder)
|
||||
|
||||
**Trigger:** After user approves 10+ posts across all platforms, "Autonomous mode" toggle appears in settings.
|
||||
|
||||
**Behavior when enabled:**
|
||||
1. User approves a draft
|
||||
2. System publishes immediately (no additional review step)
|
||||
3. Post still recorded in `user_content_examples` and `posts` table
|
||||
4. User can disable autonomous mode at any time
|
||||
5. Posts already queued when disabling are cancelled
|
||||
|
||||
**Safety:**
|
||||
- Autonomous mode off by default
|
||||
- Confirmation dialog required when toggling on: "Your approved content will post automatically. You can disable this anytime."
|
||||
- User sees a clear toggle state in navbar: "Autonomous: ON/OFF"
|
||||
- Audit log records all autonomous posts for user review
|
||||
|
||||
**Rationale:** Mortgage brokers must manually approve compliance content initially (NMLS); as trust builds and compliance templates mature, autonomous mode lets them batch-generate and let Claude post.
|
||||
|
||||
---
|
||||
|
||||
## V. Technical Architecture
|
||||
|
||||
### 5.1 Data Model
|
||||
|
||||
**New tables:**
|
||||
|
||||
```sql
|
||||
-- Chat sessions (preserves conversation history)
|
||||
CREATE TABLE chat_sessions (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
created_at TIMESTAMP,
|
||||
last_message_at TIMESTAMP,
|
||||
metadata JSON
|
||||
);
|
||||
|
||||
CREATE TABLE chat_messages (
|
||||
id UUID PRIMARY KEY,
|
||||
session_id UUID NOT NULL,
|
||||
role VARCHAR(20), -- 'user' or 'assistant'
|
||||
content TEXT,
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
|
||||
-- Draft content (pending approval)
|
||||
CREATE TABLE drafts (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
session_id UUID NOT NULL,
|
||||
platform VARCHAR(50),
|
||||
original_prompt TEXT,
|
||||
draft_text TEXT,
|
||||
status VARCHAR(50), -- 'pending', 'approved', 'rejected', 'published'
|
||||
generated_at TIMESTAMP,
|
||||
approved_at TIMESTAMP,
|
||||
error_message TEXT,
|
||||
regeneration_count INT DEFAULT 0
|
||||
);
|
||||
|
||||
-- Published posts (audit trail)
|
||||
CREATE TABLE posts (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
platform_id UUID, -- reference to drafted content
|
||||
platform VARCHAR(50),
|
||||
content_text TEXT,
|
||||
platform_post_id VARCHAR(500), -- native platform ID (LinkedIn post ID, etc.)
|
||||
published_at TIMESTAMP,
|
||||
scheduled_at TIMESTAMP,
|
||||
autonomous BOOLEAN DEFAULT FALSE,
|
||||
error_message TEXT
|
||||
);
|
||||
|
||||
-- User content examples (for learning)
|
||||
CREATE TABLE user_content_examples (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
platform VARCHAR(50),
|
||||
original_prompt TEXT,
|
||||
approved_text TEXT,
|
||||
metadata JSON,
|
||||
created_at TIMESTAMP,
|
||||
feedback_score INT DEFAULT 0
|
||||
);
|
||||
|
||||
-- Business profiles (onboarding data)
|
||||
CREATE TABLE business_profiles (
|
||||
id UUID PRIMARY KEY,
|
||||
user_id UUID NOT NULL,
|
||||
business_type VARCHAR(50), -- 'mortgage_broker', 'publisher', etc.
|
||||
nmls_number VARCHAR(20), -- optional, mortgage broker only
|
||||
states_licensed JSON, -- array of state codes
|
||||
nmls_disclaimer_text TEXT,
|
||||
tone_preference VARCHAR(50),
|
||||
enabled_platforms JSON,
|
||||
brand_voice_examples TEXT,
|
||||
created_at TIMESTAMP,
|
||||
updated_at TIMESTAMP
|
||||
);
|
||||
```
|
||||
|
||||
**Modified tables:**
|
||||
|
||||
```sql
|
||||
-- Add to users table:
|
||||
ALTER TABLE users ADD COLUMN (
|
||||
autonomous_mode_enabled BOOLEAN DEFAULT FALSE,
|
||||
approved_posts_count INT DEFAULT 0
|
||||
);
|
||||
|
||||
-- Add to oauth_clients table (already exists from Living Brief work):
|
||||
-- allowed_capabilities already supports 'communications'
|
||||
```
|
||||
|
||||
### 5.2 API Endpoints
|
||||
|
||||
**Chat:**
|
||||
- `POST /api/communications/chat` — Submit user prompt, get response with drafts
|
||||
- Request: `{ session_id, user_prompt, enabled_platforms: ["linkedin", "facebook", ...] }`
|
||||
- Response: `{ drafts: [{ platform, text, ... }], session_id }`
|
||||
|
||||
**Drafts:**
|
||||
- `GET /api/communications/drafts/:draft_id` — Retrieve draft details
|
||||
- `POST /api/communications/drafts/:draft_id/approve` — Approve and publish
|
||||
- `POST /api/communications/drafts/:draft_id/regenerate` — Regenerate one platform's draft
|
||||
- `POST /api/communications/drafts/:draft_id/reject` — Reject draft
|
||||
|
||||
**Scheduling:**
|
||||
- `POST /api/communications/posts/schedule` — Schedule a post for future publishing
|
||||
- `PUT /api/communications/posts/:post_id/reschedule` — Change scheduled time
|
||||
- `DELETE /api/communications/posts/:post_id/cancel` — Cancel scheduled post
|
||||
|
||||
**Learning:**
|
||||
- `GET /api/communications/examples` — Retrieve user's approved examples
|
||||
- `POST /api/communications/examples/:example_id/feedback` — Thumbs up/down for learning
|
||||
|
||||
**Vertical profiles:**
|
||||
- `GET /api/communications/profile` — User's business profile
|
||||
- `PUT /api/communications/profile` — Update profile
|
||||
- `POST /api/communications/profile/generate-onboarding` — Generate first prompts based on vertical
|
||||
|
||||
### 5.3 Integration with Existing SquareMCP Infrastructure
|
||||
|
||||
**Reuse existing:**
|
||||
- OAuth clients + credential storage (per-customer credentials in Redis)
|
||||
- `src/tools.ts` platform connectors (Facebook, LinkedIn, Instagram, Email)
|
||||
- SMTP/email sending via `smtp.ts`
|
||||
- Multi-tenant user isolation
|
||||
- API key authentication
|
||||
|
||||
**New:**
|
||||
- `src/chat.ts` — Chat endpoint handler (calls Claude via Anthropic SDK)
|
||||
- `src/communications.ts` — Business logic for drafts, approvals, publishing
|
||||
- `src/learning.ts` — `user_content_examples` queries for prompt enrichment
|
||||
- `src/schedule.ts` — Background job for scheduled post publishing
|
||||
|
||||
**Deployment:**
|
||||
- No new services required; all new endpoints added to existing `hermes-mcp` Express app
|
||||
- Cron job for scheduled posting (can use Node.js `node-cron` or K8s CronJob)
|
||||
- No new database migrations beyond the new tables listed above
|
||||
|
||||
### 5.4 Claude Integration
|
||||
|
||||
**Model:** Claude 3.5 Sonnet (latest available; supports 200k context window for future vertical learning)
|
||||
|
||||
**API call structure:**
|
||||
```typescript
|
||||
const response = await anthropic.messages.create({
|
||||
model: "claude-3-5-sonnet-20241022",
|
||||
max_tokens: 2000,
|
||||
system: `[business profile] [vertical constraints] [examples from user_content_examples]`,
|
||||
messages: [
|
||||
{ role: "user", content: user_prompt }
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
**Response parsing:** Extract JSON from response, validate platform keys, return drafts.
|
||||
|
||||
**Cost management:**
|
||||
- Monitor token usage per user (already tracked in existing usage system)
|
||||
- Estimated cost: ~2000 tokens/generation × 1000 calls/month/user = monitor before setting $99/month price
|
||||
- Consider rate limiting: 10 generations/hour per user to prevent abuse
|
||||
|
||||
### 5.5 Platform Integration Details
|
||||
|
||||
**LinkedIn:**
|
||||
- Endpoint: `POST /v2/ugcPosts` (shares API)
|
||||
- Auth: OAuth token from `oauth_credentials` table
|
||||
- Character limit: 3000 (we generate 800-1300 for room for edits)
|
||||
|
||||
**Facebook:**
|
||||
- Endpoint: `POST /{page_id}/feed`
|
||||
- Auth: Page access token from `oauth_credentials`
|
||||
- Supports: text + image URL
|
||||
|
||||
**Instagram:**
|
||||
- Endpoint: `POST /{ig_user_id}/media` then `POST /{media_id}/caption`
|
||||
- Auth: Instagram Graph API token
|
||||
- Requires image media object created first
|
||||
- Caption + hashtags via separate call
|
||||
|
||||
**Email (SMTP):**
|
||||
- Use existing `smtp.ts` logic
|
||||
- Each customer has their own SMTP credentials in Redis
|
||||
- Send to user's configured recipient list (new field: `email_recipients`)
|
||||
|
||||
**Approval & Confirmation:**
|
||||
- Actual post happens only after user clicks "Approve"
|
||||
- No auto-posting in v1 (autonomous mode comes at 10+ approvals)
|
||||
- Error handling: if any platform fails, show error for that platform, offer retry
|
||||
|
||||
---
|
||||
|
||||
## VI. Implementation Roadmap
|
||||
|
||||
### Phase 1: MVP (Weeks 1-3, Target: Launch by July 1, 2026)
|
||||
|
||||
**Goal:** Mortgage broker can create 1 week of multi-platform content in <15 minutes.
|
||||
|
||||
**Scope:**
|
||||
- ✅ Business profile form (mortgage broker + publisher fields)
|
||||
- ✅ Chat interface (React SPA component)
|
||||
- ✅ Multi-platform draft generation (LinkedIn, Facebook, Instagram, Email)
|
||||
- ✅ Approval workflow (Approve & post all)
|
||||
- ✅ Publishing via existing platform APIs
|
||||
- ✅ NMLS compliance injection into prompts
|
||||
- ✅ `user_content_examples` table and learning system (basic, no weighting)
|
||||
- ✅ Pilot testing with Alex Ferrari + one publisher
|
||||
|
||||
**Excluded:**
|
||||
- Scheduling (v1.1)
|
||||
- Autonomous mode (v1.1)
|
||||
- Image upload for Instagram (user provides URL in v1)
|
||||
- WhatsApp (post-MVP)
|
||||
- Advanced analytics
|
||||
|
||||
**Engineering effort:** 2-3 weeks full-time (one engineer)
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.1: Quality & Trust (Weeks 4-5)
|
||||
|
||||
**Goal:** MVP works reliably; users trust it with their brand voice.
|
||||
|
||||
**Scope:**
|
||||
- ✅ Regenerate individual platform drafts (if one variant is weak)
|
||||
- ✅ Edit workflow (user can tweak before approval)
|
||||
- ✅ Error handling & graceful partial failures
|
||||
- ✅ Approval audit log (compliance + transparency)
|
||||
- ✅ Mobile responsiveness for approval workflow
|
||||
- ✅ Rate limiting (10 generations/hour per user)
|
||||
- ✅ Feedback on generated content (thumbs up/down for learning, phase 1.1)
|
||||
|
||||
**Effort:** 1 week full-time
|
||||
|
||||
---
|
||||
|
||||
### Phase 1.2: Autonomous Mode (Week 6)
|
||||
|
||||
**Goal:** Users who trust the system can enable autonomous posting after 10 approvals.
|
||||
|
||||
**Scope:**
|
||||
- ✅ Approval counter on `users.approved_posts_count`
|
||||
- ✅ Autonomous mode toggle in settings
|
||||
- ✅ Autonomous post publishing via background job
|
||||
- ✅ Audit log for autonomous posts
|
||||
- ✅ Disable toggle (cancels queued posts)
|
||||
|
||||
**Effort:** 1 week full-time
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Expansion Features (Weeks 7-10)
|
||||
|
||||
**Goal:** Retain pilot users; prepare for secondary verticals.
|
||||
|
||||
**Scope:**
|
||||
- ✅ Scheduling (POST now vs. schedule for [date/time])
|
||||
- ✅ Real estate agent vertical (with fair housing disclaimers)
|
||||
- ✅ Prompt templates (pre-built structures for common posts)
|
||||
- ✅ Content calendar view (list + calendar of scheduled/published posts)
|
||||
- ✅ Analytics (impressions, clicks, engagement per platform)
|
||||
- ✅ Image upload for Instagram (not just URL)
|
||||
- ✅ WhatsApp Business API integration (follow-up use case)
|
||||
|
||||
**Effort:** 3-4 weeks
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Growth & Monetization (Weeks 11+)
|
||||
|
||||
**Goal:** Self-serve signup; paid customer acquisition.
|
||||
|
||||
**Scope:**
|
||||
- ✅ Stripe billing integration
|
||||
- ✅ Tiered pricing (Free, Pro $99/mo, Enterprise custom)
|
||||
- ✅ Coach & consultant vertical
|
||||
- ✅ Multi-language support (Spanish, Mandarin)
|
||||
- ✅ Team collaboration (multiple users per business)
|
||||
- ✅ Advanced prompting (custom system instructions per user)
|
||||
- ✅ Vertical-specific templates library
|
||||
- ✅ Email newsletter integration (Substack, Mailchimp)
|
||||
|
||||
**Effort:** 4-6 weeks
|
||||
|
||||
---
|
||||
|
||||
## VII. Go-To-Market Strategy
|
||||
|
||||
### 7.1 Positioning
|
||||
|
||||
**For Mortgage Brokers:**
|
||||
> Stop wasting 3+ hours per week manually posting. Generate a week of rate updates, client testimonials, and market commentary in one chat. Post to LinkedIn, Facebook, and email simultaneously. Every post pre-approved by your NMLS compliance checks.
|
||||
|
||||
**For Publishers:**
|
||||
> Turn your book launch into a month-long viral moment. Generate post variants for every platform (LinkedIn, Instagram, TikTok, email) in minutes. Learn what messaging resonates and adapt as you go.
|
||||
|
||||
**For Coaches & Consultants:**
|
||||
> Talk to an AI that knows your business. Say "write me a post about common client struggles," and Claude generates platform-specific variants with your voice. Publish to LinkedIn and email in one click.
|
||||
|
||||
**For Marketers/Agencies:**
|
||||
> Manage your clients' social presence without the copy-paste. Generate, approve, and schedule content for multiple clients from one dashboard.
|
||||
|
||||
### 7.2 Distribution Channels
|
||||
|
||||
**Direct outreach (Weeks 1-4):**
|
||||
- Alex Ferrari (Lodge Brothers) — warm lead from Living Brief beta
|
||||
- Book publisher pilot customer — identified, ready to test
|
||||
- Mortgage broker Facebook groups (50k+ members): ActiveRain, "Mortgage Professionals," "Loan Officer Marketing"
|
||||
- LinkedIn: #mortgagepro #mortgagebroker hashtags, direct messages to brokers
|
||||
- Founder content: "I automated 15 hours of social media weekly" — video + blog post
|
||||
|
||||
**Organic (Weeks 5-8):**
|
||||
- Referral from Alex to lodge network (potential 20-100 brokers)
|
||||
- Case study: "How Alex Ferrari went from 3 posts/month to 15 using AI"
|
||||
- Reddit: r/mortgages, r/realestate, r/publishing
|
||||
- SEO content: "Best AI tool for mortgage brokers," "Social media manager for loan officers"
|
||||
|
||||
**Paid (Weeks 9+):**
|
||||
- Google Ads: "AI social media for mortgage professionals" (vertical-specific)
|
||||
- Facebook/LinkedIn ads targeting loan officers and brokers
|
||||
- Sponsorships: mortgage industry podcasts, real estate mastermind groups
|
||||
|
||||
**Marketplace (Post-MVP):**
|
||||
- ChatGPT GPT Store (Living Brief launches first; Communications GPT follows once product is stable)
|
||||
- Claude AI MCP Directory (already submitted, can add Communications actions)
|
||||
|
||||
### 7.3 Pricing Strategy
|
||||
|
||||
| Tier | Price | Users | Posts/month | Platforms | Autonomous | Use case |
|
||||
|------|-------|-------|------------|-----------|-----------|----------|
|
||||
| Free | $0 | 1 | 10 | 2 | ❌ | Try it out |
|
||||
| Pro | $99/month | 1 | Unlimited | 5 (LinkedIn, FB, IG, Email, WhatsApp) | ✅ | Mortgage brokers, publishers (wedge) |
|
||||
| Team | $199/month | 3 | Unlimited | 5 | ✅ | Small agencies, brokerages |
|
||||
| Enterprise | Custom | Unlimited | Unlimited | All + API | ✅ | Large teams, agencies, franchises |
|
||||
|
||||
**Mortgage broker logic:** 1 extra closed deal at 0.5% commission on $300k loan = $1500. Spending $99/month to earn $1500 is <7% cost. Easy sell.
|
||||
|
||||
---
|
||||
|
||||
## VIII. Success Metrics & Gates
|
||||
|
||||
### Pilot Phase Gates (Before public launch)
|
||||
|
||||
**Alex Ferrari (Mortgage Broker):**
|
||||
- ✅ Creates 1 week of content in <15 minutes without coaching
|
||||
- ✅ Uses rate-update workflow weekly for 4 consecutive weeks
|
||||
- ✅ Approves 10+ posts (autonomous mode unlocked)
|
||||
- ✅ Says unprompted: "I'd pay for this"
|
||||
- ✅ Invites 1+ other loan officer to try
|
||||
|
||||
**Publisher:**
|
||||
- ✅ Creates 1 week of book promotion content in <15 minutes
|
||||
- ✅ Uses for book launch or ongoing author platform
|
||||
- ✅ Approves 10+ posts
|
||||
- ✅ Makes payment commitment
|
||||
|
||||
**Pilot success:** Both customers complete 4 weeks of active use; 1+ makes a paid commitment.
|
||||
|
||||
### Marketplace Launch Gates (Public availability)
|
||||
|
||||
**Activation:**
|
||||
- 60%+ of new signups create a business profile
|
||||
- 50%+ of profiled users generate their first drafts
|
||||
- 40%+ of first-draft users approve and post
|
||||
|
||||
**Retention:**
|
||||
- 30%+ of users active 4+ weeks in
|
||||
- Average user generates 15+ posts in first month
|
||||
- 20%+ hit autonomous mode unlock
|
||||
|
||||
**Trust:**
|
||||
- 0 NMLS/compliance violations in mortgage broker posts (100% success rate on disclaimer injection)
|
||||
- 0 accidental posts due to UX confusion
|
||||
- 95%+ posting success rate across platforms
|
||||
|
||||
**Quality:**
|
||||
- User satisfaction: 4.5+/5 stars on marketplace
|
||||
- Average editing time: <2 minutes per post (low friction on drafts)
|
||||
- Platform error rate: <2% (occasional Instagram/WhatsApp credential issues are recoverable)
|
||||
|
||||
---
|
||||
|
||||
## IX. Open Questions & Decisions
|
||||
|
||||
### Technical
|
||||
|
||||
1. **Async generation timing:** Should Claude generation be synchronous (user waits <5sec) or async (drafted in background)? Tradeoff: UX (instant feedback) vs. timeout risk (if Claude times out, user loses draft).
|
||||
- *Recommendation:* Async with polling + real-time WebSocket updates to UI.
|
||||
|
||||
2. **Image handling for Instagram:** Should we auto-generate images via DALL-E or require user to provide URLs in v1?
|
||||
- *Recommendation for v1:* User provides image URL in chat. Auto-generation is v2 feature after budget is validated.
|
||||
|
||||
3. **Conflict resolution:** If two agents (ChatGPT + Claude Code) both try to update a Living Brief and a Communications post simultaneously, how do we merge?
|
||||
- *Recommendation:* Out of scope for v1. Communications writes are isolated to its own tables. Living Brief remains a read-only source for context.
|
||||
|
||||
4. **Rate limiting:** Should we throttle generations per user? At what limit?
|
||||
- *Recommendation:* 10 generations/hour per user. Prevents accidental runaway token consumption.
|
||||
|
||||
### Product
|
||||
|
||||
1. **Content calendar view:** Should it be a visual calendar (April 2026 view) or list view (ordered by date)?
|
||||
- *Recommendation for v1:* List view. Calendar is v1.2 feature.
|
||||
|
||||
2. **Editing: fine-grained or holistic?** Should users edit individual platforms or request a full regeneration with feedback?
|
||||
- *Recommendation:* Both. Individual platform editing for tweaks; regenerate button for full overhaul.
|
||||
|
||||
3. **Vertical-specific templates:** Which prompts should we ship as pre-built chips for mortgage brokers?
|
||||
- *Recommendation:* "Rate update," "New loan type," "Client testimonial request," "Market commentary," "Refinance education." Validate with Alex.
|
||||
|
||||
4. **Email recipients:** Should each email go to a fixed list or should users select recipients per-message?
|
||||
- *Recommendation for v1:* Fixed recipient list configured during onboarding. Per-message selection is v1.1.
|
||||
|
||||
### Marketing
|
||||
|
||||
1. **Founder narrative:** Should we lead with "I automated my mortgage marketing" or "I built an AI communications OS"?
|
||||
- *Recommendation:* Lead with the wedge. "I automated my mortgage marketing in 15 minutes/week." The OS narrative is a retention story later.
|
||||
|
||||
2. **Social proof:** Which mortgage broker success story should be the first case study (Alex or another pilot customer)?
|
||||
- *Recommendation:* Alex Ferrari / Lodge Brothers if they grant permission. If not, find a published testimonial from a happy beta user post-launch.
|
||||
|
||||
3. **SEO keywords:** Should we target "AI social media manager" or "mortgage loan officer tools"?
|
||||
- *Recommendation:* Both, but start with vertical-specific: "AI social media for mortgage brokers," "AI marketing for loan officers." Broader keywords later.
|
||||
|
||||
---
|
||||
|
||||
## X. Use Cases for Different Audiences
|
||||
|
||||
### For Product Managers
|
||||
- **Read:** Sections II (Problem), III (Users), IV (Product Spec)
|
||||
- **Action:** Validate pricing, confirm vertical priorities, define success gates
|
||||
|
||||
### For Engineers
|
||||
- **Read:** Sections V (Technical Architecture), VI (Implementation Roadmap), IX (Open Questions)
|
||||
- **Action:** Estimate effort, identify dependencies, plan sprints
|
||||
|
||||
### For Designers
|
||||
- **Read:** Section IV.3 (Chat Interface), IV.4 (Platform Specs), VI (Implementation)
|
||||
- **Action:** Create wireframes for chat panel, draft approval flow, design vertical-specific onboarding
|
||||
|
||||
### For Marketers
|
||||
- **Read:** Sections III (Users), VII (Go-To-Market), VIII (Success Metrics), IX (Open Questions — marketing)
|
||||
- **Action:** Draft positioning docs, identify early influencers in mortgage + publishing communities, plan content calendar
|
||||
|
||||
### For Social Media & Awareness Teams
|
||||
- **Read:** Sections I (Executive Summary), II (Problem Statement), VII.2 (Distribution Channels), VII.3 (Pricing)
|
||||
- **Action:** Create viral social narrative, identify founder story angles, plan hashtag strategy (#MortgageAI, #AIForLoanOfficers, #SmallBizAI)
|
||||
|
||||
### For Future AI Agents
|
||||
- **Read:** All sections in order
|
||||
- **Use:** Planning (Sections I-III), implementation (Sections V-VI), deployment (Sections VII-VIII), refinement (Section IX)
|
||||
|
||||
---
|
||||
|
||||
## XI. Success Definition (One Sentence Per Audience)
|
||||
|
||||
**Product:** Mortgage brokers create a week of multi-platform content in under 15 minutes and say unprompted, "I'd pay for this."
|
||||
|
||||
**Engineering:** Shipping reliable multi-platform generation, approval, and publishing without errors or data loss.
|
||||
|
||||
**Design:** Users never ask "what should I post?" because onboarding and prompt suggestions eliminate the blank canvas.
|
||||
|
||||
**Marketing:** First 100 paid customers acquired within 60 days of public launch, with 60%+ organic referral rate.
|
||||
|
||||
**Social/Awareness:** Video of a mortgage broker generating a week of content in 5 minutes gets 10k+ views and generates qualified leads.
|
||||
|
||||
---
|
||||
|
||||
## XII. Related Documents
|
||||
|
||||
This spec supersedes and integrates:
|
||||
- `2026-05-13-office-hours-chat-first-communications-design.md` (original design doc)
|
||||
- `2026-06-13-office-hours-chatgpt-living-brief-session.md` (architecture notes for Living Brief)
|
||||
- `2026-06-04-marketing-intelligence-lodge-first.md` (mortgage broker context)
|
||||
- `2026-06-10-ceo-plan-lodge-first-launch.md` (GTM validation)
|
||||
|
||||
---
|
||||
|
||||
## XIII. Document History
|
||||
|
||||
| Date | Author | Change |
|
||||
|------|--------|--------|
|
||||
| 2026-06-15 | Claude Code | Created comprehensive spec from vault research + design docs |
|
||||
|
||||
**For questions or clarifications:** Reference this document's section numbers in subsequent planning, implementation, and marketing sprints. Each section is self-contained but linked for context.
|
||||
|
||||
@@ -0,0 +1,695 @@
|
||||
# Chat-First Communications Manager — Phase 1 Engineering Design
|
||||
|
||||
**Date:** 2026-06-15
|
||||
**Author:** Claude Code
|
||||
**Sprint plan:** → `2026-06-15-phase1-mvp-sprint-plan.md`
|
||||
**Spec:** `2026-06-15-comprehensive-product-spec.md` (Sections IV–VI)
|
||||
**Status:** DRAFT — ready for Week 1 implementation
|
||||
|
||||
This is the implementable companion to the sprint plan. Read it alongside the week-by-week tasks. It resolves spec ambiguities, provides complete DDL with FKs/indexes/CHECK constraints, locks API contracts, and lists what to confirm before Day 1.
|
||||
|
||||
---
|
||||
|
||||
## Contents
|
||||
|
||||
1. [Deviations from Spec](#1-deviations-from-spec)
|
||||
2. [Database Schema — Full DDL](#2-database-schema--full-ddl)
|
||||
3. [API Contracts](#3-api-contracts)
|
||||
4. [Generation Pipeline](#4-generation-pipeline)
|
||||
5. [NMLS Compliance Injection](#5-nmls-compliance-injection)
|
||||
6. [Approval / Publish Sequence](#6-approval--publish-sequence)
|
||||
7. [Open Items — Confirm Before Week 1](#7-open-items--confirm-before-week-1)
|
||||
|
||||
---
|
||||
|
||||
## 1. Deviations from Spec
|
||||
|
||||
Two fields added that the spec referenced but omitted from the DDL. Two spec errors corrected.
|
||||
|
||||
### 1.1 `drafts.generation_id` — added
|
||||
|
||||
The spec puts one `drafts` row per platform per generation but provides no way to group them. The approval UI needs "all drafts from this generation" to render platform tabs side-by-side. The `/regenerate` endpoint needs it to fetch original context without re-querying the chat session.
|
||||
|
||||
**Fix:** Add `generation_id CHAR(36) NOT NULL` to `drafts`. Every call to `POST /api/communications/chat` generates one UUID and writes it into every platform row produced by that call. Rows from a `/regenerate` call keep the same `generation_id`.
|
||||
|
||||
### 1.2 `business_profiles.email_recipients` — added
|
||||
|
||||
Spec Section 5.5: "Send to user's configured recipient list (new field: `email_recipients`)." The field is named in prose but absent from the Section V.1 DDL.
|
||||
|
||||
**Fix:** Add `email_recipients JSON NULL` to `business_profiles`. Shape: `["alex@lodge.com", "lisa@lodge.com"]`. Populated during onboarding via `PUT /api/communications/profile`. Validation: if `enabled_platforms` includes `"email"` and `email_recipients` is null or empty, return a 400 on profile save.
|
||||
|
||||
### 1.3 `posts.draft_id` — spec correction
|
||||
|
||||
Spec V.1 names this column `platform_id UUID`. That name is wrong — it references `drafts.id`, not a platform. Renamed to `draft_id` throughout this doc.
|
||||
|
||||
### 1.4 `drafts.draft_metadata` — added
|
||||
|
||||
The spec stores the entire draft as `draft_text TEXT`. This doesn't work for two platforms:
|
||||
|
||||
- **Instagram:** Claude returns a caption (TEXT) + hashtags (array) — two fields
|
||||
- **Email:** Claude returns a subject (VARCHAR) + body (TEXT) — two fields
|
||||
|
||||
**Fix:** Add `draft_metadata JSON NULL` alongside `draft_text`. Convention:
|
||||
- Instagram: `draft_text` = caption; `draft_metadata = {"hashtags": ["#mortgage", "#rateupdate"]}`
|
||||
- Email: `draft_text` = body; `draft_metadata = {"subject": "Rate alert: what the Fed cut means for you"}`
|
||||
- LinkedIn / Facebook: `draft_metadata = null`; `draft_text` = full post
|
||||
|
||||
### 1.5 Claude model — spec correction
|
||||
|
||||
Spec says `claude-3-5-sonnet-20241022`. Current production model is `claude-sonnet-4-6`. Use `claude-sonnet-4-6` in all implementation. (See open item #7.)
|
||||
|
||||
---
|
||||
|
||||
## 2. Database Schema — Full DDL
|
||||
|
||||
### Migration order
|
||||
|
||||
Create in this order; rollback scripts drop in reverse:
|
||||
|
||||
1. `business_profiles`
|
||||
2. `chat_sessions`
|
||||
3. `chat_messages`
|
||||
4. `drafts`
|
||||
5. `posts`
|
||||
6. `user_content_examples`
|
||||
7. `ALTER TABLE users` (last — additive only)
|
||||
|
||||
### Requirements
|
||||
|
||||
- **MySQL 8.0.16+** for CHECK constraint enforcement (silently ignored on earlier versions — confirm before running; see open item #1)
|
||||
- **MySQL 8.0.13+** for `DEFAULT (UUID())` expression defaults (see open item #3)
|
||||
- All FKs assume `users.id` is `CHAR(36)` (see open item #2)
|
||||
|
||||
---
|
||||
|
||||
### `business_profiles`
|
||||
|
||||
```sql
|
||||
CREATE TABLE business_profiles (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
user_id CHAR(36) NOT NULL,
|
||||
business_type VARCHAR(50) NOT NULL,
|
||||
nmls_number VARCHAR(20) NULL,
|
||||
states_licensed JSON NULL, -- ["CA","TX","NY"]
|
||||
nmls_disclaimer_text TEXT NULL,
|
||||
tone_preference VARCHAR(50) NOT NULL DEFAULT 'professional',
|
||||
enabled_platforms JSON NOT NULL, -- ["linkedin","facebook","instagram","email"]
|
||||
brand_voice_examples TEXT NULL,
|
||||
email_recipients JSON NULL, -- ["user@domain.com"] — NEW (§1.2)
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uq_bp_user_id (user_id),
|
||||
CONSTRAINT fk_bp_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT chk_bp_type CHECK (business_type IN ('mortgage_broker','publisher','real_estate','coach','consultant','other')),
|
||||
CONSTRAINT chk_bp_tone CHECK (tone_preference IN ('professional','conversational','energetic','educational'))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `chat_sessions`
|
||||
|
||||
```sql
|
||||
CREATE TABLE chat_sessions (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
user_id CHAR(36) NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_message_at DATETIME NULL,
|
||||
metadata JSON NULL,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_cs_user_last (user_id, last_message_at DESC),
|
||||
CONSTRAINT fk_cs_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `chat_messages`
|
||||
|
||||
```sql
|
||||
CREATE TABLE chat_messages (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
session_id CHAR(36) NOT NULL,
|
||||
role VARCHAR(20) NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_cm_session_time (session_id, created_at),
|
||||
CONSTRAINT fk_cm_session FOREIGN KEY (session_id) REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
||||
CONSTRAINT chk_cm_role CHECK (role IN ('user','assistant'))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `drafts`
|
||||
|
||||
```sql
|
||||
CREATE TABLE drafts (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
generation_id CHAR(36) NOT NULL, -- groups all platform rows from one chat turn — NEW (§1.1)
|
||||
user_id CHAR(36) NOT NULL,
|
||||
session_id CHAR(36) NOT NULL,
|
||||
platform VARCHAR(50) NOT NULL,
|
||||
original_prompt TEXT NOT NULL,
|
||||
draft_text TEXT NULL, -- NULL if this platform's generation failed
|
||||
draft_metadata JSON NULL, -- {hashtags:[...]} or {subject:"..."} — NEW (§1.4)
|
||||
status VARCHAR(20) NOT NULL DEFAULT 'pending',
|
||||
generated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
approved_at DATETIME NULL,
|
||||
error_message TEXT NULL,
|
||||
regeneration_count INT NOT NULL DEFAULT 0,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_drafts_generation (generation_id),
|
||||
KEY idx_drafts_user_status (user_id, status, generated_at DESC),
|
||||
KEY idx_drafts_session (session_id),
|
||||
CONSTRAINT fk_drafts_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_drafts_session FOREIGN KEY (session_id) REFERENCES chat_sessions(id) ON DELETE CASCADE,
|
||||
CONSTRAINT chk_drafts_platform CHECK (platform IN ('linkedin','facebook','instagram','email')),
|
||||
CONSTRAINT chk_drafts_status CHECK (status IN ('pending','approved','rejected','published','failed'))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `posts`
|
||||
|
||||
```sql
|
||||
CREATE TABLE posts (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
user_id CHAR(36) NOT NULL,
|
||||
draft_id CHAR(36) NULL, -- was platform_id in spec — renamed (§1.3)
|
||||
platform VARCHAR(50) NOT NULL,
|
||||
content_text TEXT NOT NULL,
|
||||
platform_post_id VARCHAR(500) NULL, -- native ID returned by platform API
|
||||
published_at DATETIME NULL,
|
||||
scheduled_at DATETIME NULL,
|
||||
autonomous TINYINT(1) NOT NULL DEFAULT 0,
|
||||
error_message TEXT NULL,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_posts_user (user_id, published_at DESC),
|
||||
KEY idx_posts_draft (draft_id),
|
||||
CONSTRAINT fk_posts_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_posts_draft FOREIGN KEY (draft_id) REFERENCES drafts(id) ON DELETE SET NULL,
|
||||
CONSTRAINT chk_posts_platform CHECK (platform IN ('linkedin','facebook','instagram','email'))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `user_content_examples`
|
||||
|
||||
```sql
|
||||
CREATE TABLE user_content_examples (
|
||||
id CHAR(36) NOT NULL DEFAULT (UUID()),
|
||||
user_id CHAR(36) NOT NULL,
|
||||
platform VARCHAR(50) NOT NULL,
|
||||
original_prompt TEXT NULL,
|
||||
approved_text TEXT NOT NULL,
|
||||
metadata JSON NULL, -- {hashtags:[...], tone:"professional", length:842}
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
feedback_score INT NOT NULL DEFAULT 0,
|
||||
|
||||
PRIMARY KEY (id),
|
||||
KEY idx_uce_user_platform (user_id, platform, created_at DESC),
|
||||
CONSTRAINT fk_uce_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT chk_uce_platform CHECK (platform IN ('linkedin','facebook','instagram','email'))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `users` table additions
|
||||
|
||||
```sql
|
||||
ALTER TABLE users
|
||||
ADD COLUMN autonomous_mode_enabled TINYINT(1) NOT NULL DEFAULT 0,
|
||||
ADD COLUMN approved_posts_count INT NOT NULL DEFAULT 0;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. API Contracts
|
||||
|
||||
### 3.1 Business Profile
|
||||
|
||||
#### `GET /api/communications/profile`
|
||||
|
||||
**200:**
|
||||
```json
|
||||
{
|
||||
"id": "uuid",
|
||||
"user_id": "uuid",
|
||||
"business_type": "mortgage_broker",
|
||||
"nmls_number": "123456",
|
||||
"states_licensed": ["CA", "TX"],
|
||||
"nmls_disclaimer_text": "NMLS #123456, licensed in CA/TX. Not an offer to lend...",
|
||||
"tone_preference": "professional",
|
||||
"enabled_platforms": ["linkedin", "facebook", "instagram", "email"],
|
||||
"brand_voice_examples": "...",
|
||||
"email_recipients": ["alex@lodge.com"],
|
||||
"created_at": "2026-06-15T00:00:00Z",
|
||||
"updated_at": "2026-06-15T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
**404:** `{ "error": "No business profile found" }` — first-time user before onboarding
|
||||
|
||||
---
|
||||
|
||||
#### `PUT /api/communications/profile`
|
||||
|
||||
All fields optional on update. Required on first create: `business_type`, `enabled_platforms`.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"business_type": "mortgage_broker",
|
||||
"nmls_number": "123456",
|
||||
"states_licensed": ["CA", "TX"],
|
||||
"nmls_disclaimer_text": "NMLS #123456...",
|
||||
"tone_preference": "professional",
|
||||
"enabled_platforms": ["linkedin", "facebook", "instagram", "email"],
|
||||
"brand_voice_examples": "Here's a post I liked: ...",
|
||||
"email_recipients": ["alex@lodge.com", "team@lodge.com"]
|
||||
}
|
||||
```
|
||||
|
||||
**200:** Full profile object (same shape as GET)
|
||||
|
||||
**400 validation errors:**
|
||||
- `business_type` not in allowed enum
|
||||
- `enabled_platforms` contains a value not in `['linkedin','facebook','instagram','email']`
|
||||
- `enabled_platforms` includes `"email"` but `email_recipients` is null or empty
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/communications/examples`
|
||||
|
||||
**200:**
|
||||
```json
|
||||
{
|
||||
"examples": [
|
||||
{
|
||||
"id": "uuid",
|
||||
"platform": "linkedin",
|
||||
"original_prompt": "Rate update",
|
||||
"approved_text": "Big news for buyers...",
|
||||
"metadata": null,
|
||||
"created_at": "2026-06-14T10:00:00Z",
|
||||
"feedback_score": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
No filtering in Week 1 — return all examples for the authenticated user, newest first.
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/communications/profile/generate-onboarding`
|
||||
|
||||
**Request:** empty body (fetches profile from auth context)
|
||||
|
||||
**200:**
|
||||
```json
|
||||
{
|
||||
"chips": [
|
||||
"Rate update",
|
||||
"New listing",
|
||||
"Market commentary",
|
||||
"Client testimonial request",
|
||||
"Refinance education"
|
||||
],
|
||||
"vertical": "mortgage_broker"
|
||||
}
|
||||
```
|
||||
|
||||
Hardcode chip lists per vertical in Week 1. No Claude call needed here — chips are static per `business_type`.
|
||||
|
||||
---
|
||||
|
||||
### 3.2 Chat
|
||||
|
||||
#### `POST /api/communications/chat`
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"session_id": "uuid-or-null",
|
||||
"user_prompt": "Write me a rate update post about the Fed dropping rates",
|
||||
"enabled_platforms": ["linkedin", "facebook", "instagram", "email"]
|
||||
}
|
||||
```
|
||||
|
||||
- `session_id: null` → create new session, return new `session_id` in response
|
||||
- `enabled_platforms` defaults to `business_profiles.enabled_platforms` if omitted
|
||||
|
||||
**200:**
|
||||
```json
|
||||
{
|
||||
"session_id": "uuid",
|
||||
"generation_id": "uuid",
|
||||
"drafts": [
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"platform": "linkedin",
|
||||
"draft_text": "Big news for homebuyers...",
|
||||
"draft_metadata": null,
|
||||
"status": "pending",
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"platform": "instagram",
|
||||
"draft_text": "Rates just dropped!",
|
||||
"draft_metadata": { "hashtags": ["#mortgagerates", "#homebuying", "#NMLS123456"] },
|
||||
"status": "pending",
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"platform": "email",
|
||||
"draft_text": "The Fed just cut rates. Here's what that means for you...",
|
||||
"draft_metadata": { "subject": "Rate alert: what this week's Fed decision means for you" },
|
||||
"status": "pending",
|
||||
"error": null
|
||||
},
|
||||
{
|
||||
"draft_id": null,
|
||||
"platform": "facebook",
|
||||
"draft_text": null,
|
||||
"draft_metadata": null,
|
||||
"status": "failed",
|
||||
"error": "Claude API timeout"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
A failed platform returns `draft_id: null`, no row in `drafts`. The client renders an error state for that tab; user clicks "Regenerate this platform" to retry via `/regenerate`.
|
||||
|
||||
---
|
||||
|
||||
### 3.3 Draft Management
|
||||
|
||||
#### `GET /api/communications/drafts/:draft_id`
|
||||
|
||||
**200:**
|
||||
```json
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"generation_id": "uuid",
|
||||
"platform": "linkedin",
|
||||
"original_prompt": "Write me a rate update...",
|
||||
"draft_text": "Big news for homebuyers...",
|
||||
"draft_metadata": null,
|
||||
"status": "pending",
|
||||
"generated_at": "2026-06-15T19:00:00Z",
|
||||
"approved_at": null,
|
||||
"error_message": null,
|
||||
"regeneration_count": 0
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/communications/drafts/:draft_id/regenerate`
|
||||
|
||||
**Request (optional):**
|
||||
```json
|
||||
{ "feedback": "Make it shorter and punchier" }
|
||||
```
|
||||
|
||||
**200:** Same shape as `GET /drafts/:draft_id` with updated `draft_text`, incremented `regeneration_count`, `status: "pending"`.
|
||||
|
||||
Updates the existing `drafts` row in place — does not create a new row. `generation_id` is preserved.
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/communications/drafts/:draft_id/reject`
|
||||
|
||||
**Request:** empty body
|
||||
|
||||
**200:** `{ "draft_id": "uuid", "status": "rejected" }`
|
||||
|
||||
Side effect: `UPDATE drafts SET status = 'rejected'`.
|
||||
|
||||
---
|
||||
|
||||
### 3.4 Approval & Publish
|
||||
|
||||
#### `POST /api/communications/drafts/:draft_id/approve`
|
||||
|
||||
**Request:** empty body
|
||||
|
||||
**200 — success:**
|
||||
```json
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"platform": "linkedin",
|
||||
"post_id": "uuid",
|
||||
"platform_post_id": "urn:li:share:7309876543210",
|
||||
"published_at": "2026-06-15T19:05:00Z",
|
||||
"status": "published",
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
**200 — platform API failure** (not 4xx — the HTTP request succeeded; the platform call failed):
|
||||
```json
|
||||
{
|
||||
"draft_id": "uuid",
|
||||
"platform": "instagram",
|
||||
"post_id": null,
|
||||
"platform_post_id": null,
|
||||
"published_at": null,
|
||||
"status": "failed",
|
||||
"error": "Instagram: token expired — reconnect credentials"
|
||||
}
|
||||
```
|
||||
|
||||
Return 200 even on platform failure. The client handles per-platform error copy without treating the whole request as an HTTP error.
|
||||
|
||||
---
|
||||
|
||||
## 4. Generation Pipeline
|
||||
|
||||
### Architecture decision: per-platform parallel Claude calls
|
||||
|
||||
The spec (§4.5) implies a single Claude call returning a multi-platform JSON blob. The sprint plan (2.1) requires partial-failure isolation per platform. These conflict: if you send one multi-platform JSON call and the `instagram` key is malformed, you can recover the other keys via partial parsing — but you can't independently retry just Instagram without regenerating everything, and `regeneration_count` becomes ambiguous (did you regenerate the full batch or just one platform?).
|
||||
|
||||
**Decision: one Claude call per platform, all launched via `Promise.allSettled()`.**
|
||||
|
||||
Cost tradeoff: ~1.7× more tokens than a single multi-platform call because the system prompt is repeated per call. Acceptable for a pilot with <10 users; revisit at scale. Benefit: true per-platform isolation, clean `regeneration_count` per `drafts` row, natural fit for the schema.
|
||||
|
||||
```
|
||||
POST /api/communications/chat
|
||||
│
|
||||
├─ Resolve session (create new if session_id is null)
|
||||
├─ Fetch business_profile for req.user.id
|
||||
├─ Fetch last 3 user_content_examples per enabled platform
|
||||
│ SELECT approved_text FROM user_content_examples
|
||||
│ WHERE user_id = ? AND platform = ?
|
||||
│ ORDER BY created_at DESC LIMIT 3
|
||||
│
|
||||
├─ generation_id = uuid()
|
||||
│
|
||||
├─ Promise.allSettled([
|
||||
│ generateForPlatform('linkedin', prompt, profile, examples),
|
||||
│ generateForPlatform('facebook', prompt, profile, examples),
|
||||
│ generateForPlatform('instagram', prompt, profile, examples),
|
||||
│ generateForPlatform('email', prompt, profile, examples),
|
||||
│ ]) → settledResults[]
|
||||
│
|
||||
├─ For each settled result:
|
||||
│ fulfilled → INSERT INTO drafts (generation_id, platform, draft_text, ...)
|
||||
│ rejected → no row inserted; add error entry to response
|
||||
│
|
||||
├─ INSERT INTO chat_messages (role='user', content=user_prompt)
|
||||
├─ INSERT INTO chat_messages (role='assistant', content='Generated N platform drafts')
|
||||
├─ UPDATE chat_sessions SET last_message_at = NOW()
|
||||
│
|
||||
└─ Return { session_id, generation_id, drafts: [...] }
|
||||
```
|
||||
|
||||
### `generateForPlatform`
|
||||
|
||||
```typescript
|
||||
async function generateForPlatform(
|
||||
platform: 'linkedin' | 'facebook' | 'instagram' | 'email',
|
||||
userPrompt: string,
|
||||
profile: BusinessProfile,
|
||||
examples: string[] // last 3 approved_text values for this platform
|
||||
): Promise<{ draft_text: string; draft_metadata: object | null }> {
|
||||
const system = buildSystemPrompt(platform, profile, examples);
|
||||
const response = await anthropic.messages.create({
|
||||
model: 'claude-sonnet-4-6',
|
||||
max_tokens: 512, // per-platform; 512 is plenty for any single platform
|
||||
system,
|
||||
messages: [{ role: 'user', content: userPrompt }]
|
||||
});
|
||||
const raw = response.content[0].type === 'text' ? response.content[0].text : '';
|
||||
const { draft_text, draft_metadata } = parsePlatformResponse(platform, raw);
|
||||
return {
|
||||
draft_text: injectNmlsCompliance(draft_text, profile), // see §5
|
||||
draft_metadata
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### System prompt structure
|
||||
|
||||
```
|
||||
You are an AI communications operator for [business_type] professionals.
|
||||
|
||||
Platform: [PLATFORM]
|
||||
Character limit: [LIMIT]
|
||||
|
||||
[VERTICAL_CONSTRAINTS]
|
||||
|
||||
Previously approved posts by this user on [PLATFORM]:
|
||||
---
|
||||
[examples[0]]
|
||||
---
|
||||
[examples[1]]
|
||||
---
|
||||
[examples[2]]
|
||||
---
|
||||
|
||||
Generate ONLY the [PLATFORM] content. [PLATFORM-SPECIFIC OUTPUT INSTRUCTION]
|
||||
```
|
||||
|
||||
Platform-specific output instructions:
|
||||
|
||||
| Platform | max_tokens | Output instruction |
|
||||
|----------|-----------|-------------------|
|
||||
| `linkedin` | 512 | "Output the post text only. 800–1300 characters." |
|
||||
| `facebook` | 256 | "Output the post text only. 150–400 characters." |
|
||||
| `instagram` | 256 | "Line 1: caption (138–150 chars). Line 2: space-separated #hashtags (5–10 tags)." |
|
||||
| `email` | 512 | "Line 1: `Subject: [subject line]`. Blank line. Then email body (200–400 words)." |
|
||||
|
||||
### `parsePlatformResponse`
|
||||
|
||||
```typescript
|
||||
function parsePlatformResponse(
|
||||
platform: string,
|
||||
raw: string
|
||||
): { draft_text: string; draft_metadata: object | null } {
|
||||
switch (platform) {
|
||||
case 'instagram': {
|
||||
const [caption = '', hashtagLine = ''] = raw.trim().split('\n');
|
||||
const hashtags = hashtagLine.match(/#\w+/g) ?? [];
|
||||
return { draft_text: caption, draft_metadata: { hashtags } };
|
||||
}
|
||||
case 'email': {
|
||||
const match = raw.match(/^Subject:\s*(.+)\n\n?([\s\S]+)/);
|
||||
return match
|
||||
? { draft_text: match[2].trim(), draft_metadata: { subject: match[1].trim() } }
|
||||
: { draft_text: raw.trim(), draft_metadata: { subject: '' } };
|
||||
}
|
||||
default:
|
||||
return { draft_text: raw.trim(), draft_metadata: null };
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. NMLS Compliance Injection
|
||||
|
||||
Post-process every `mortgage_broker` draft after `parsePlatformResponse`, before inserting into `drafts`. This is a hard server-side append, not a prompt instruction — prompts can miss it; keyword detection cannot.
|
||||
|
||||
```typescript
|
||||
const NMLS_TRIGGER = /\b(rates?|loans?|APR|refinanc|financial advice|borrow|lend)\b/i;
|
||||
|
||||
function injectNmlsCompliance(draftText: string, profile: BusinessProfile): string {
|
||||
if (profile.business_type !== 'mortgage_broker') return draftText;
|
||||
if (!NMLS_TRIGGER.test(draftText)) return draftText;
|
||||
const disclaimer =
|
||||
profile.nmls_disclaimer_text ??
|
||||
`NMLS #${profile.nmls_number}. Not an offer to enter into an agreement. ` +
|
||||
`Not all customers will qualify. Information subject to TILA.`;
|
||||
return `${draftText}\n\n${disclaimer}`;
|
||||
}
|
||||
```
|
||||
|
||||
Sprint plan 2.2 acceptance criterion: "100% of generated mortgage-broker drafts mentioning rates/loans/APR include the disclaimer." This gate is enforceable only with server-side injection — verify via log inspection before marking 2.2 done.
|
||||
|
||||
**Open question (see §7 item #6):** Should `user_content_examples.approved_text` store the post WITH or WITHOUT the disclaimer? Recommendation: strip the disclaimer before inserting into `user_content_examples` so that style learning operates on the human-readable voice, not the legal boilerplate.
|
||||
|
||||
---
|
||||
|
||||
## 6. Approval / Publish Sequence
|
||||
|
||||
```
|
||||
POST /api/communications/drafts/:draft_id/approve
|
||||
│
|
||||
├─ Fetch draft WHERE id = :draft_id AND user_id = req.user.id
|
||||
│ → 404 if not found or wrong user
|
||||
│ → 409 if status != 'pending' (already approved / rejected / published)
|
||||
│
|
||||
├─ Fetch OAuth token from Redis
|
||||
│ key pattern: oauth:credentials:{user_id}:{platform}
|
||||
│ (same helper as existing src/tools.ts credential lookup — do not duplicate)
|
||||
│
|
||||
├─ Call platform API
|
||||
│ ├─ linkedin → POST /v2/ugcPosts (reuse src/tools.ts)
|
||||
│ ├─ facebook → POST /{page_id}/feed (reuse src/tools.ts)
|
||||
│ ├─ instagram → POST media → POST caption (reuse src/tools.ts)
|
||||
│ └─ email → smtp.ts sendMail()
|
||||
│ to: business_profiles.email_recipients ← the §1.2 new field
|
||||
│
|
||||
├─ On platform API SUCCESS:
|
||||
│ ├─ INSERT INTO posts (user_id, draft_id, platform, content_text, platform_post_id, published_at)
|
||||
│ ├─ UPDATE drafts SET status='published', approved_at=NOW()
|
||||
│ ├─ INSERT INTO user_content_examples
|
||||
│ │ (user_id, platform, original_prompt, approved_text=<draft_text without disclaimer>, metadata)
|
||||
│ └─ UPDATE users SET approved_posts_count = approved_posts_count + 1
|
||||
│ (autonomous mode toggle appears in UI once this hits 10)
|
||||
│
|
||||
├─ On platform API FAILURE:
|
||||
│ ├─ UPDATE drafts SET status='failed', error_message=<platform error>
|
||||
│ └─ Return 200 with status:'failed' + error string
|
||||
│ (do not throw HTTP 5xx — request succeeded; platform call failed)
|
||||
│
|
||||
└─ Return result object (see §3.4)
|
||||
```
|
||||
|
||||
### Platform API notes
|
||||
|
||||
| Platform | Endpoint | Token key in Redis | Notes |
|
||||
|----------|----------|--------------------|-------|
|
||||
| LinkedIn | `POST /v2/ugcPosts` | `oauth:credentials:{uid}:linkedin` | Existing connector in `src/tools.ts` |
|
||||
| Facebook | `POST /{page_id}/feed` | `oauth:credentials:{uid}:facebook` | Existing connector; `page_id` from profile or token |
|
||||
| Instagram | `POST /{ig_user_id}/media` + `/caption` | `oauth:credentials:{uid}:instagram` | Requires image URL from user; set `draft_metadata.image_required=true` if none provided |
|
||||
| Email | `smtp.ts.sendMail()` | SMTP creds in Redis (existing key format — confirm in §7 #5) | `to:` = `business_profiles.email_recipients` |
|
||||
|
||||
---
|
||||
|
||||
## 7. Open Items — Confirm Before Week 1
|
||||
|
||||
| # | Item | Impact if wrong | Action |
|
||||
|---|------|-----------------|--------|
|
||||
| 1 | MySQL version | CHECK constraints silently not enforced on <8.0.16 | `SELECT VERSION()` on staging |
|
||||
| 2 | `users.id` column type | FK `CHAR(36)` declarations break if `users.id` is `INT` | `SHOW COLUMNS FROM users LIKE 'id'` |
|
||||
| 3 | `DEFAULT (UUID())` support | Fails on MySQL <8.0.13; need app-level UUID gen | Follows from version check |
|
||||
| 4 | Redis key format for OAuth tokens | Approval flow fetches wrong/empty token | Read `src/tools.ts` credential lookup — confirm key pattern |
|
||||
| 5 | `smtp.ts` send signature | Week 2.4 email approval breaks if `to:` param shape differs | Read `smtp.ts`; note exact param name for recipient list |
|
||||
| 6 | NMLS style examples | Store post WITH or WITHOUT disclaimer in `user_content_examples`? | Decide before Week 2; recommend WITHOUT — see §5 |
|
||||
| 7 | Claude model string | `claude-sonnet-4-6` vs. spec's `claude-3-5-sonnet-20241022` | Confirm API key has access to `claude-sonnet-4-6` |
|
||||
| 8 | Instagram image URL | `status='pending'` rows with no image block the Approve button | Add `{image_required: true}` to `draft_metadata` when no URL provided; UI renders "Add image URL" callout before enabling Approve |
|
||||
|
||||
---
|
||||
|
||||
## Changelog
|
||||
|
||||
| Date | Author | Change |
|
||||
|------|--------|--------|
|
||||
| 2026-06-15 | Claude Code | Initial draft — DDL with FKs/indexes/CHECK constraints, API contracts, generation pipeline, compliance injection, approval sequence |
|
||||
@@ -0,0 +1,6 @@
|
||||
# Chat-First Communications Manager — Phase 1 MVP Sprint Plan\n\n**Date:** 2026-06-15\n**Source spec:** `2026-06-15-comprehensive-product-spec.md` (Sections IV, V, VI)\n**Status:** DRAFT — ready for engineering sprint kickoff\n**Target:** MVP launch by 2026-07-01 (3 weeks, 1 engineer full-time)\n**Repo:** `hermes-mcp`\n**Note:** This breaks Section VI \"Phase 1: MVP\" into a day-by-day backlog. ChatGPT/Claude store listing for this product does NOT happen at the end of this sprint — per spec Section VII.2, the Communications GPT ships only after pilot gates (Section VIII) are met. This sprint's exit criterion is \"ready for Alex Ferrari + publisher pilot,\" not \"deployed to ChatGPT.\"\n\n---\n\n## Pre-Sprint Checklist (Day 0)\n\n- [ ] Confirm `hermes-mcp` repo access and current branch state (check for uncommitted changes from the 2026-06-15 Living Brief docs work — those are unrelated and should not be touched)\n- [ ] Confirm Anthropic API key / Claude access is configured for server-side calls (Section V.4 — `claude-3-5-sonnet-20241022`)\n- [ ] Confirm existing platform credentials still valid: LinkedIn, Facebook, Instagram, SMTP (these were validated for Living Brief/v1-lite as of 2026-06-13)\n- [ ] Identify Alex Ferrari (mortgage broker) and the publisher pilot contact for Week 3 testing\n\n---\n\n## Week 1 — Data Model, Profiles, Onboarding, Chat Skeleton\n\n**Goal:** A user can complete onboarding and reach a working (even if unstyled) chat endpoint that echoes back a structured response.\n\n### 1.1 Database migrations (Section V.1)\n- [ ] Create `chat_sessions`, `chat_messages`, `drafts`, `posts`, `user_content_examples`, `business_profiles` tables\n- [ ] Add `autonomous_mode_enabled` and `approved_posts_count` columns to `users`\n- [ ] Write migration scripts + rollback scripts\n- **Files:** new migration file(s) in repo's migration directory\n- **Schema reference:** full table definitions are in the comprehensive spec, Section V.1 — copy column definitions directly from there rather than re-deriving\n- **Acceptance:** migrations run cleanly against staging DB; rollback verified\n\n### 1.2 Business profile API (Section IV.2, V.2)\n- [ ] `GET /api/communications/profile`\n- [ ] `PUT /api/communications/profile`\n- [ ] `GET /api/communications/examples` — list a user's `user_content_examples` (simple read, no filtering logic yet; useful for debugging the Week 3 learning loop)\n- [ ] Vertical-specific field validation: mortgage broker (NMLS number, states licensed, disclaimer text), publisher (book titles, audience, genres)\n- **Files:** `src/communications.ts` (new), route registration in `src/index.ts`\n- **Acceptance:** profile create/update round-trips correctly for both verticals; `GET /examples` returns `[]` for a new user and populated rows after Week 2 approvals\n\n### 1.3 Onboarding generation endpoint (Section IV.2 step 2-3)\n- [ ] `POST /api/communications/profile/generate-onboarding` — given a business profile, return vertical-aware prompt chips\n- **Acceptance:** mortgage broker profile returns the 5 chips listed in spec (rate update, new listing, market commentary, testimonial request, refi education); publisher returns its 5 chips\n\n### 1.4 Chat session skeleton (Section V.1, V.2)\n- [ ] `POST /api/communications/chat` — create/append to `chat_sessions` + `chat_messages`, but generation logic stubbed (Week 2)\n- **Files:** `src/chat.ts` (new)\n- **Acceptance:** session persists across calls; message history retrievable\n\n**Week 1 exit criteria:** profile + onboarding + chat session plumbing works end-to-end with stubbed generation responses.\n\n---\n\n## Week 2 — Multi-Platform Generation, Draft Management, Approval & Publishing\n\n**Goal:** User can generate real multi-platform drafts, edit/regenerate them, approve, and have them actually post.\n\n### 2.1 Claude generation integration (Section IV.5, V.4)\n- [ ] Implement system prompt assembly: business profile + vertical constraints + (empty) style examples\n- [ ] Call Claude (`claude-3-5-sonnet-20241022`), parse JSON response into `{linkedin, facebook, instagram: {caption, hashtags}, email: {subject, body}}`\n- [ ] Persist each platform variant as a row in `drafts` (status `pending`)\n- [ ] Generate all enabled platforms in parallel; partial failure on one platform doesn't block others\n- **Files:** `src/chat.ts`, `src/communications.ts`\n- **Acceptance:** a single prompt produces drafts for all enabled platforms; a forced failure on one platform doesn't prevent the others from completing\n\n### 2.2 NMLS / vertical compliance injection (Section IV.5)\n- [ ] Detect rate/loan/APR/financial-advice keywords in mortgage broker drafts; append NMLS disclaimer from `business_profiles.nmls_disclaimer_text`\n- [ ] Publisher: avoid spoilers unless requested, ensure CTA present (best-effort prompt instruction, not hard validation)\n- **Acceptance:** 100% of generated mortgage-broker drafts mentioning rates/loans/APR inclLine truncated
|
||||
|
||||
|
||||
## Related: Engineering Design Doc
|
||||
**→** `2026-06-15-phase1-engineering-design.md` — implementable schema (DDL with FKs/indexes), API request/response contracts, generation pipeline design (per-platform parallel Claude calls instead of one multi-platform JSON blob, to satisfy 2.1's partial-failure requirement), and the approve/publish sequence. Read this alongside the week-by-week tasks above; it also lists open items to confirm before Week 1 (e.g. `users` PK type, pgcrypto availability).
|
||||
|
||||
Reference in new issue
Block a user