YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- Technical Design Document β v2.0
- AI-Powered Influencer Campaign Automation Platform
- Changelog from v1.0
- Table of Contents
- 1. Executive Summary
- 2. Problem Statement
- 3. Architecture Overview
- 4. Module 1 β Outreach & Negotiation Agent
- 5. Module 2 β Instagram Engagement Dashboard
- 6. Module 3 β Influencer Discovery Engine
- 7. Data Architecture
- 8. Infrastructure & DevOps
- 9. Security & Compliance
- 10. Cost Estimation
- 11. Risk Register & Mitigations
- 12. Development Timeline
- 13. Team Structure
- 14. Assumptions, Dependencies & Out of Scope
- 15. Open-Source Tooling Map β Build vs. Reuse
- 16. Competitive Landscape & Market Intel
- 17. Appendix β Tech Lead Review
- 18. Appendix β API Rate Limits
- 19. Appendix β Glossary
- 20. Next Steps
- AI-Powered Influencer Campaign Automation Platform
Technical Design Document β v2.0
AI-Powered Influencer Campaign Automation Platform
Version: 2.0 (Revised β incorporates Grok market research, Claude architecture review, and open-source tooling audit)
Date: April 30, 2026
Author: Technical Architecture Team
Status: PROPOSAL β Pre-Scoping Phase
π View v1.0 (archived) | This is the current version.
Changelog from v1.0
| Area | v1.0 | v2.0 Change | Rationale |
|---|---|---|---|
| Orchestration | Custom cron on Railway | n8n (self-hosted) as orchestration engine | Eliminates ~2 weeks of custom scheduling/retry code; 400+ native integrations; visual workflow debugging |
| Sentiment | GPT-4o-mini only | Tiered: XLM-RoBERTa (bulk) β GPT-4o-mini (edge cases) | 10Γ cheaper at scale; open-source multilingual model handles 90% of comments; LLM for ambiguous/Hinglish/sarcasm |
| FAQ Handling | Direct LLM | pgvector RAG inside Supabase | Zero extra infra (pgvector built into Supabase); semantic FAQ search; avoids hallucinated answers |
| Voice Fallback | Pre-recorded + live transfer | AI Voice Agent: Twilio Voice + Deepgram STT + ElevenLabs TTS | Market research shows indie builders achieving this; competitive differentiator |
| Dashboard (v1 fast-track) | Next.js + Tremor custom build | Metabase (OSS, v1) β Next.js + Tremor (v2) | Ship dashboard in 2 days not 2 weeks; Metabase connects directly to PostgreSQL; upgrade to custom UI later |
| Budget Guardrails | In LLM prompt | Hard-coded rule engine OUTSIDE LLM | Claude research flagged prompt injection risk; guardrail layer never passes max budget to agent context |
| WhatsApp Channel | Only Cloud API | Cloud API (primary) + Evolution API/WAHA as dev/test sandbox | Open-source WhatsApp HTTP APIs for local development without burning Meta API quota |
| Conversation Logging | Custom implementation | Chatwoot (OSS) as conversation inbox layer | 21K+ GitHub stars; built-in WhatsApp integration, agent assignment, conversation history UI |
| Out of Scope β In Scope | Multi-language (English only) | Hinglish/Hindi support via multilingual models + LLM | Grok research: "If targeting India-heavy creators, factor local WhatsApp adoption and regional API nuances" |
| New Section | N/A | Β§15 β Open-Source Tooling Map with GitHub repos, stars, and "build vs reuse" recommendation | Direct request; avoids reinventing the wheel |
| New Section | N/A | Β§16 β Competitive Landscape & Market Intel | Synthesized from Grok research; informs positioning and pricing |
Table of Contents
- Executive Summary
- Problem Statement
- Architecture Overview
- Module 1 β Outreach & Negotiation Agent
- Module 2 β Instagram Engagement Dashboard
- Module 3 β Influencer Discovery Engine
- Data Architecture
- Infrastructure & DevOps
- Security & Compliance
- Cost Estimation
- Risk Register & Mitigations
- Development Timeline
- Team Structure
- Assumptions, Dependencies & Out of Scope
- Open-Source Tooling Map β Build vs. Reuse
- Competitive Landscape & Market Intel
- Appendix β Tech Lead Review
- Appendix β API Rate Limits
- Appendix β Glossary
- Next Steps
1. Executive Summary
This document defines the architecture for an end-to-end influencer campaign automation platform with three modules:
| Module | Function | Core Stack |
|---|---|---|
| M1 β Outreach Agent | Google Sheets β WhatsApp/Voice β AI negotiation β human handoff β deal close | WhatsApp Cloud API + LangGraph + GPT-4o + n8n |
| M2 β IG Dashboard | Post detection β engagement tracking β sentiment analysis β anomaly alerts β ROI | Instagram Graph API + Phyllo + Supabase + Metabase (v1) / Next.js (v2) |
| M3 β Discovery | Auto-discover influencers β deduplicate β enrich β add to pipeline | Modash API + n8n cron |
Key architectural philosophy: Use open-source where it saves >1 week of dev time; build custom only where differentiation matters (the negotiation agent FSM).
The platform maximizes open-source tooling to avoid reinventing the wheel:
- n8n (52K+ β) for workflow orchestration instead of custom schedulers
- Chatwoot (21K+ β) for conversation inbox instead of custom chat UI
- Metabase (40K+ β) for v1 dashboard instead of custom charts
- Evolution API (2K+ β) or WAHA for WhatsApp dev/test sandbox
- cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual for bulk sentiment (free, multilingual)
- pgvector (Supabase-native) for FAQ retrieval instead of Pinecone
Custom code is concentrated in the LangGraph negotiation state machine β the core IP of the platform.
2. Problem Statement
2.1 Current State
- Campaign managers maintain influencer lists in Google Sheets
- Each influencer contacted individually via phone/WhatsApp
- Pitching, FAQ handling, rate negotiation done person-to-person
- Zero post-campaign visibility into engagement, ROI, or influencer performance
- New influencer sourcing is ad hoc with no systematic discovery
2.2 Target State
- Automated outreach triggered from Google Sheets data
- AI agent handles pitch β FAQ β negotiation β close/escalate
- Humans only intervene for hot leads flagged by the agent
- Real-time IG engagement data per influencer and per campaign
- Systematic creator discovery refreshing the pipeline every 2-3 days
2.3 Market Context (from Grok Research)
What the market says about this category:
- Sentiment: "Cautiously optimistic with growing adoption" β brands see value in automating "80% of grunt work"
- Key pain point: Generic templates lead to low response rates; influencers spot templated pitches
- Critical success factor: Hyper-personalization referencing specific posts/content, not just "Hi {name}"
- Competitive edge of our approach: Most existing tools (Grin, AspireIQ, Modash) are discovery + tracking platforms, NOT automated negotiation agents. Janney AI is the closest competitor but doesn't support WhatsApp as primary channel
- India-specific: WhatsApp is dominant; Hinglish (Hindi+English mix) is common in influencer conversations; regional language support is a differentiator
3. Architecture Overview
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT INTERFACE LAYER β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Google Sheets β β Slack β β Metabase β β Chatwoot β β
β β (Influencer β β (Human β β Dashboard β β (Conv. β β
β β Master List)β β Handoff) β β (IG metrics)β β Inbox) β β
β ββββββββ¬ββββββββ ββββββββ²βββββββ ββββββββ²ββββββββ ββββββββ²ββββββββ β
βββββββββββΌββββββββββββββββββΌβββββββββββββββββΌβββββββββββββββββββΌβββββββββββ
β β β β
βββββββββββΌββββββββββββββββββΌβββββββββββββββββΌβββββββββββββββββββΌβββββββββββ
β βΌ β β β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β n8n ORCHESTRATION ENGINE β β
β β (self-hosted, 52K+ β) β β
β β β β
β β Workflows: β β
β β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββ β β
β β β Sheet Sync β β Outreach β β IG Polling β β β
β β β (every 60s or β β Trigger β β (every 4h metrics β β β
β β β webhook) β β (new rows β β β every 2h posts) β β β
β β β β β queue β agent) β β β β β
β β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββ β β
β β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββ β β
β β β Discovery β β Sentiment β β Anomaly Detection β β β
β β β (every 3 days) β β Batch β β (daily 2 AM) β β β
β β β β β (every 4h) β β β β β
β β βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββ β
β β AI AGENT SERVICE β β DATA SERVICES β β
β β (Python / FastAPI) β β β β
β β β β ββββββββββββββββββββββββββββββββββ β β
β β βββββββββββββββββββ β β β Supabase β β β
β β β LangGraph FSM β β β β (PostgreSQL + pgvector + β β β
β β β (negotiation β β β β Realtime + Auth + RLS) β β β
β β β state machine) β β β ββββββββββββββββββββββββββββββββββ β β
β β βββββββββββββββββββ€ β β ββββββββββββββββββββββββββββββββββ β β
β β β Budget β β β β Redis β β β
β β β Guardrail Layer β β β β (message queue, session cache) β β β
β β β (hard-coded, β β β ββββββββββββββββββββββββββββββββββ β β
β β β outside LLM) β β β β β
β β βββββββββββββββββββ β ββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β EXTERNAL APIs β β
β β β β
β β WhatsApp Cloud API (Meta) βββ primary messaging channel β β
β β Twilio Voice + Deepgram + ElevenLabs βββ voice fallback β β
β β OpenAI GPT-4o / GPT-4o-mini βββ LLM backbone β β
β β Instagram Graph API βββ engagement data (free, permissioned) β β
β β Phyllo API βββ engagement fallback (paid, no permissions needed) β β
β β Modash API βββ influencer discovery β β
β β Slack API βββ human handoff notifications β β
β β HuggingFace Inference API βββ XLM-RoBERTa sentiment (free tier) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Hosting: n8n + AI Agent Service on Railway (or Render) | Supabase (managed) | Metabase on Railway (Docker) | Vercel (if/when custom Next.js dashboard in v2)
4. Module 1 β Outreach & Negotiation Agent
4.1 Messaging Channel: WhatsApp Cloud API (Direct)
Decision unchanged from v1: WhatsApp Cloud API (Meta-hosted) β NOT Twilio-mediated.
| Factor | WhatsApp Cloud API (Direct) | Twilio WhatsApp | WATI | 360dialog |
|---|---|---|---|---|
| Cost | Meta per-convo fee only (~$0.03-0.08) | Meta fee + $0.005/msg | $49-99/mo + Meta | $49-299/mo + Meta (zero markup) |
| Template Control | Direct via Meta BM | Via Twilio console | Via WATI dashboard | Via 360dialog |
| Dev Complexity | Moderate | Lower | Lowest (no-code) | Moderate |
| Best For | Custom AI agents (our case) | Multi-channel enterprises | SMBs wanting ease | High-volume broadcasts |
Why Cloud API still wins: We need raw webhook control for our LangGraph agent. WATI/360dialog abstract too much. Twilio adds unnecessary cost and latency.
NEW in v2 β Dev/Test Sandbox: Use Evolution API (open-source, 2K+ β) or WAHA for local development. These self-hosted WhatsApp HTTP APIs let engineers test message flows without burning Meta API quota or waiting for template approvals.
Critical constraints (unchanged):
- 24-hour conversation window rule
- Template categories: marketing (outreach) = most expensive
- Quality rating system β pace at 50 new outreach/hr max
- Business verification required Day 1 (1-2 weeks lead time)
4.2 Voice Fallback: AI Voice Agent (Upgraded from v1)
v1: Pre-recorded pitch + live transfer.
v2: Full AI voice agent using Twilio Voice + Deepgram STT + ElevenLabs TTS.
Influencer picks up phone
β
βΌ
βββββββββββββββββββββββββββ
β Twilio Voice streams β
β audio to Deepgram STT ββββ Text transcription
βββββββββββββββββββββββββββ β
βΌ
ββββββββββββββββ
β LangGraph ββββ Response text
β Agent β
β (same FSM as β
β WhatsApp) β
ββββββββββββββββ
β
βΌ
ββββββββββββββββ
β ElevenLabs ββββ Audio stream
β TTS β back to Twilio
ββββββββββββββββ
Why upgrade: Grok research shows indie builders achieving this stack. It's a differentiator vs. Janney AI (email-only outreach). Same LangGraph FSM handles both WhatsApp text and voice β one codebase, two channels.
Guardrail: If voice agent detects confusion or negative sentiment for >2 turns β warm transfer to human. Agent says: "Let me connect you with our team directly."
4.3 AI Negotiation Agent: LangGraph State Machine
Architecture unchanged from v1 but with two critical additions from Claude research:
Addition 1: Budget Guardrail Layer OUTSIDE the LLM
# Guardrail layer β runs BEFORE LLM response is sent
class BudgetGuardrail:
"""Hard-coded rules. LLM never sees max budget."""
def validate_offer(self, agent_response, campaign_config):
proposed_rate = extract_rate(agent_response)
if proposed_rate is None:
return agent_response # Not a rate offer, pass through
if proposed_rate > campaign_config.budget_max:
# BLOCK β never send this. Escalate instead.
return ESCALATE_TO_HUMAN
if proposed_rate < campaign_config.budget_min:
# Agent tried to undercut β fix to min
return replace_rate(agent_response, campaign_config.budget_min)
return agent_response # Within band, safe to send
Why this matters: Claude research flagged prompt injection risk β a sophisticated influencer could theoretically manipulate the LLM into revealing budget ceilings or agreeing above max. The guardrail layer makes this impossible because the max budget value never enters the LLM context.
Addition 2: FAQ Knowledge Base via pgvector RAG
ββββββββββββββββββββββββββββββ
β Campaign Setup β
β Admin uploads FAQ doc β
β β Chunked + embedded β
β β Stored in Supabase β
β pgvector table β
ββββββββββββββ¬ββββββββββββββββ
β
ββββββββββββββΌββββββββββββββββ
β Influencer asks question β
β β Embedded via OpenAI β
β β Similarity search pgvectorβ
β β Top 3 chunks as context β
β β GPT-4o-mini generates β
β answer from chunks ONLY β
β β If confidence < 0.7: β
β "Let me check on that" β
β β queued for human β
ββββββββββββββββββββββββββββββ
Why pgvector over Pinecone: Supabase has native pgvector support. Zero extra infrastructure, zero extra cost, zero extra vendor. FAQ corpus for a campaign is tiny (~50-200 chunks) β pgvector handles this trivially.
4.4 Conversation Inbox: Chatwoot (Open-Source)
NEW in v2. Instead of building a custom conversation log viewer, we use Chatwoot (21K+ β):
| What Chatwoot gives us for free | What we'd have to build otherwise |
|---|---|
| Multi-channel inbox (WhatsApp, email, web) | Custom chat UI |
| Agent assignment + conversation routing | Custom routing logic |
| Conversation history with search | Custom transcript viewer |
| Canned responses + macros | N/A |
| Contact management | Basic influencer CRM |
| API for programmatic message sending | Custom API layer |
| WhatsApp Business API integration | Custom webhook handling |
| Team collaboration features | N/A |
Integration pattern:
- WhatsApp webhooks β Chatwoot (handles message display + history)
- Chatwoot webhook β our LangGraph agent (handles AI response generation)
- LangGraph response β Chatwoot API (sends response back through WhatsApp)
- Human handoff: agent marks conversation in Chatwoot, human picks up in same inbox
Trade-off: Adds a dependency (Chatwoot self-hosted). But saves ~3 weeks of custom UI development and gives the operations team a professional inbox from Day 1.
4.5 Google Sheets Integration
Unchanged from v1 β bidirectional sync via Sheets API v4. n8n has a native Google Sheets node that handles this with zero custom code.
4.6 Human Handoff Flow
Unchanged from v1 β Slack notification with interactive buttons. n8n handles the Slack notification trigger.
4.7 LLM Selection
Revised based on both research reports:
| Role | Model | Cost | Rationale |
|---|---|---|---|
| Negotiation turns | GPT-4o | $2.50/$10.00 per 1M tokens | Best structured output + multilingual (Hinglish) |
| FAQ from RAG chunks | GPT-4o-mini | $0.15/$0.60 per 1M tokens | 70% cheaper; FAQ is straightforward Q&A |
| Bulk sentiment (English) | XLM-RoBERTa (self-hosted or HF Inference) | FREE | Open-source, handles 90% of comments |
| Sentiment edge cases | GPT-4o-mini | $0.15/$0.60 per 1M tokens | Hinglish sarcasm, emoji-heavy, ambiguous |
| Voice STT | Deepgram Nova-2 | $0.0043/min | Fastest, most accurate for conversational audio |
| Voice TTS | ElevenLabs | $0.18/1K chars (Pro) | Most natural-sounding for Indian English |
5. Module 2 β Instagram Engagement Dashboard
5.1 Data Collection: Dual-Layer (Unchanged)
Graph API (primary, free) + Phyllo (fallback, paid). See v1 for decision logic.
5.2 Sentiment Analysis: Tiered Approach (NEW in v2)
Claude research recommended cardiffnlp/twitter-roberta-base-sentiment. We adopt a tiered version:
βββββββββββββββββββββββ
β Instagram Comments β
β (batch every 4h) β
ββββββββββββ¬βββββββββββ
β
ββββββββββββΌβββββββββββ
ββββββ β Language Detection β ββββββ
β ββββββββββββββββββββββββ β
β β
English/European Hindi/Hinglish/
languages Regional/Emoji-heavy
β β
βΌ βΌ
ββββββββββββββββββββββββ βββββββββββββββββββββββββ
β TIER 1: XLM-RoBERTa β β TIER 2: GPT-4o-mini β
β (HF Inference API β β (with structured β
β or self-hosted) β β output JSON mode) β
β β β β
β cardiffnlp/twitter- β β Handles: β
β xlm-roberta-base- β β - Code-mixed text β
β sentiment-multilingualβ β - Sarcasm β
β β β - Heavy emoji usage β
β 10.8M downloads β β - Slang/abbreviations β
β Multilingual trained β β β
β FREE on HF Inference β β ~$0.15/1M tokens β
β ~50ms per comment β β ~500ms per comment β
β β β β
β Output: pos/neg/neu β β Output: pos/neg/neu/ β
β + confidence score β β spam + topics + β
β β β purchase_intent β
ββββββββββββ¬βββββββββββββ ββββββββββββ¬βββββββββββββ
β β
β βββββββββββββββββββββββ β
ββββββ IF confidence < 0.6 ββββββββββββ
β β route to Tier 2 β (fallback)
βββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Store in Supabase β
β [comments] table β
βββββββββββββββββββββββ
Why tiered:
- XLM-RoBERTa handles ~80-90% of comments (English, Spanish, Portuguese, French, etc.) at zero marginal cost
- Only truly ambiguous comments (low confidence) or code-mixed Hinglish route to GPT-4o-mini
- At 10K comments/campaign: ~9K free (Tier 1) + ~1K at $0.15/1M tokens (Tier 2) = ~$0.002 total. vs. $1.50 if all via GPT-4o-mini
5.3 Dashboard: Metabase (v1) β Next.js + Tremor (v2)
NEW in v2. Instead of building a custom dashboard from Day 1:
Phase 1 (v1): Metabase (open-source, 40K+ β)
- Docker deploy on Railway (~5 min setup)
- Connect directly to Supabase PostgreSQL
- Built-in: chart builder, dashboard creator, filters, drill-downs, scheduled reports, embedding
- The ops team can build their own views without engineering help
- Time to ship: 2 days (vs. 2 weeks for custom)
Phase 2 (v2, Week 12+): Custom Next.js + Tremor
- Only if/when Metabase's limitations become clear (specific UX needs, real-time, custom anomaly views)
- By then, we know exactly what views the client uses most β build those specifically
5.4 Anomaly Detection
Unchanged from v1 β Modified Z-Score with rolling baseline. Integrated as an n8n workflow running daily at 2 AM.
5.5 Polling Architecture
Unchanged from v1 but now managed by n8n workflows instead of custom cron:
| n8n Workflow | Schedule | Action |
|---|---|---|
poll_new_posts |
Every 2 hours | Detect campaign posts (hashtag + mention + content match) |
poll_ig_metrics |
Every 4 hours | Pull engagement snapshots for tracked posts |
deep_pull_metrics |
Daily 2 AM | Full historical pull + anomaly detection + engagement rate recalc |
sentiment_batch |
Every 4 hours | Batch comments β tiered sentiment analysis |
6. Module 3 β Influencer Discovery Engine
Unchanged from v1. Modash API, every 3 days, deduplicate on IG handle. Now orchestrated by n8n workflow.
7. Data Architecture
7.1 Database Schema
Unchanged from v1 (campaigns, influencers, conversations, campaign_posts, engagement_snapshots, comments, anomalies) with one addition:
-- NEW: FAQ knowledge base for RAG
CREATE TABLE faq_chunks (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
campaign_id UUID REFERENCES campaigns(id),
content TEXT NOT NULL,
embedding VECTOR(1536), -- OpenAI text-embedding-3-small
source_document TEXT,
chunk_index INTEGER,
created_at TIMESTAMPTZ DEFAULT now()
);
-- pgvector index for similarity search
CREATE INDEX ON faq_chunks USING ivfflat (embedding vector_cosine_ops) WITH (lists = 10);
7.2 Message Bus: Redis
NEW in v2 (from Claude architecture). Redis Pub/Sub for decoupling:
- n8n publishes outreach trigger β Redis β Agent service consumes
- Agent publishes state change β Redis β n8n consumes β updates Sheet + Slack
- Prevents tight coupling between orchestration and agent service
8. Infrastructure & DevOps
8.1 Revised Tech Stack
| Layer | Technology | Open-Source? | Justification |
|---|---|---|---|
| Orchestration | n8n (self-hosted) | β 52K+ β | Replaces custom cron/schedulers; visual workflow builder; native Google Sheets, Slack, WhatsApp nodes |
| AI Agent | Python FastAPI + LangGraph | β LangGraph OSS | Core IP β custom state machine for negotiation |
| LLM | OpenAI GPT-4o / GPT-4o-mini | β (API) | Best structured output + multilingual |
| Conversation Inbox | Chatwoot (self-hosted) | β 21K+ β | Professional inbox for ops team; WhatsApp native |
| Database | Supabase (PostgreSQL + pgvector + Realtime) | β (managed OSS) | Unified: relational + vector + realtime + auth |
| Message Queue | Redis | β | Decouple orchestration β agent |
| Dashboard (v1) | Metabase (self-hosted) | β 40K+ β | Ship in 2 days; connects to PostgreSQL directly |
| Dashboard (v2) | Next.js + Tremor + Tailwind | β | Custom UX when Metabase limits are reached |
| Sentiment (bulk) | XLM-RoBERTa via HF Inference | β | Free, multilingual, 10.8M downloads |
| WhatsApp Cloud API (Meta) | β (API) | Production messaging channel | |
| WhatsApp (dev/test) | Evolution API or WAHA | β 2K+ β | Local testing without Meta API quota |
| Voice | Twilio + Deepgram + ElevenLabs | β (APIs) | AI voice agent pipeline |
| IG Data | Instagram Graph API + Phyllo | β (APIs) | Free primary + paid fallback |
| Discovery | Modash API | β (API) | Best DB + API for the price |
| Monitoring | Sentry + Posthog | β (free tiers) | Errors + product analytics |
| CI/CD | GitHub Actions | β | Standard |
| Hosting | Railway (all backend services) | β (PaaS) | Simple Docker deploys; cheaper than AWS at this scale |
8.2 Service Map on Railway
Railway Project
βββ Service: n8n (Docker) β 1 GB RAM β $10/mo
βββ Service: agent-service (Python) β 512 MB RAM β $5/mo
βββ Service: chatwoot (Docker) β 2 GB RAM β $15/mo
βββ Service: metabase (Docker) β 1 GB RAM β $10/mo
βββ Service: redis β 256 MB RAM β $3/mo
βββ Total Railway: ~$43/mo
External Managed:
βββ Supabase Pro: $25/mo
βββ Domain + DNS: $15/mo
9. Security & Compliance
Unchanged from v1 with one addition:
9.4 Prompt Injection Prevention (NEW)
WhatsApp messages from influencers are untrusted input flowing into an LLM:
- Input sanitization: Strip any system-prompt-like patterns ("ignore previous instructions", "you are now", etc.)
- Budget isolation: Max budget value NEVER enters LLM context. Guardrail layer validates outputs.
- Output validation: Every agent response checked for: PII leakage, profanity, off-brand content, rates outside band
- Conversation length limit: Max 15 turns before auto-escalate to human (prevents adversarial probing)
10. Cost Estimation
10.1 Monthly Cost β 100 Influencers
| Item | v1 Cost | v2 Cost | Savings | Notes |
|---|---|---|---|---|
| WhatsApp Cloud API | $15 | $15 | β | Unchanged |
| OpenAI GPT-4o (negotiation) | $5 | $5 | β | Unchanged |
| OpenAI GPT-4o-mini (FAQ + sentiment edge) | $0.30 | $0.30 | β | Reduced role β only edge cases |
| XLM-RoBERTa sentiment | N/A | $0 | $0.30 saved | HF Inference free tier or self-hosted |
| Phyllo API | $90 | $90 | β | Unchanged |
| Modash API | $120 | $120 | β | Unchanged |
| Supabase Pro | $25 | $25 | β | Now includes pgvector (no Pinecone needed) |
| Vercel | $20 | $0 | $20 saved | No custom frontend in v1; Metabase instead |
| Railway (all services) | $15 | $43 | +$28 | More services (n8n, Chatwoot, Metabase, Redis) |
| Slack | $0 | $0 | β | Free tier |
| Twilio Voice | $1 | $8 | +$7 | AI voice agent uses more minutes |
| Deepgram STT | N/A | $3 | +$3 | ~700 min at $0.0043/min |
| ElevenLabs TTS | N/A | $5 | +$5 | Pro plan allocation |
| Sentry + Posthog | $0 | $0 | β | Free tiers |
| Domain | $15 | $15 | β | Unchanged |
| TOTAL | ~$306 | ~$329 | +$23 | +8% cost for significantly more capability |
10.2 Monthly Cost β 500 Influencers
| Item | Monthly Cost |
|---|---|
| WhatsApp Cloud API | ~$75 |
| OpenAI (all models) | ~$25 |
| XLM-RoBERTa | $0 |
| Phyllo API | ~$450 |
| Modash API | $299 |
| Supabase | $25 |
| Railway | $60 |
| Twilio + Deepgram + ElevenLabs | ~$30 |
| TOTAL | ~$964 |
Key insight unchanged: Phyllo is the biggest cost driver. Push Graph API OAuth adoption aggressively.
11. Risk Register & Mitigations
All 10 risks from v1 unchanged, plus:
| # | Risk | Probability | Impact | Mitigation |
|---|---|---|---|---|
| R11 | Prompt injection via WhatsApp messages | Low | High | Input sanitization + budget isolation + output validation (see Β§9.4) |
| R12 | n8n single point of failure | Low | High | n8n persists workflows to PostgreSQL; auto-restart on Railway; daily backup |
| R13 | Chatwoot self-hosted maintenance burden | Medium | Low | Use Chatwoot Docker image with auto-updates; community edition is stable (21K+ β) |
| R14 | Influencers detect AI and refuse to engage | Medium | Medium | Transparent disclosure + hyper-personalization (reference specific recent posts, not just "Hi {name}"); immediate human handoff option |
| R15 | Competitor (Janney AI) launches WhatsApp feature | Low | Medium | Speed to market; our WhatsApp + voice combo is harder to replicate; focus on India market |
12. Development Timeline
Revised Timeline (incorporates open-source tooling β net schedule unchanged at 10 weeks but with more capability delivered)
PHASE 0 β Foundation (Week 1-2)
βββ Week 1
β βββ Day 1-2: Infrastructure setup
β β βββ Railway: deploy n8n, Redis, Chatwoot (Docker)
β β βββ Supabase: project + full schema migration (incl. pgvector)
β β βββ GitHub repo (monorepo: services/agent, services/monitor)
β β βββ CI/CD: GitHub Actions β Railway
β β βββ β οΈ START Meta Business Verification
β β
β βββ Day 3-4: Google Sheets + Slack
β β βββ n8n: Google Sheets sync workflow (bidirectional)
β β βββ n8n: Slack notification workflow (templated alerts)
β β βββ Test: add row in Sheet β appears in Supabase β Slack ping
β β
β βββ Day 5: WhatsApp Cloud API
β βββ Meta Business Manager app setup
β βββ Webhook endpoint (FastAPI)
β βββ Template messages submitted for approval
β βββ Evolution API / WAHA sandbox for dev testing
β βββ Chatwoot β WhatsApp connection configured
β
βββ Week 2
β βββ Day 6-7: Auth + Chatwoot config
β β βββ Supabase Auth (Google OAuth)
β β βββ Chatwoot: team setup, canned responses, WhatsApp channel
β β βββ Chatwoot webhook β FastAPI agent endpoint
β β
β βββ Day 8-9: Metabase dashboard (v1)
β β βββ Deploy Metabase Docker on Railway
β β βββ Connect to Supabase PostgreSQL
β β βββ Build: campaign overview, influencer table, engagement charts
β β βββ Build: anomaly log view, conversation status board
β β
β βββ Day 10: Integration testing
β βββ Sheet β Supabase β WhatsApp β Chatwoot flow
β βββ Slack notification delivery
β βββ Metabase reads from live Supabase data
β
β β
DELIVERABLE: Full infra live. WhatsApp send/receive working.
β Chatwoot inbox operational. Metabase dashboard connected.
PHASE 1 β Negotiation Agent (Week 3-5)
βββ Week 3
β βββ Day 11-13: LangGraph agent core
β β βββ State machine: INTRO β QUALIFY β FAQ β NEGOTIATE β CONFIRM β CLOSE/ESCALATE
β β βββ State persistence to Supabase (checkpoint after every transition)
β β βββ GPT-4o structured output integration
β β βββ Budget guardrail layer (hard-coded, outside LLM)
β β βββ System prompts: campaign brief injection, tone, Hinglish support
β β βββ Unit tests for every state transition
β β
β βββ Day 14-15: FAQ RAG pipeline
β βββ pgvector table + embedding pipeline
β βββ FAQ document chunker + uploader
β βββ Semantic search endpoint
β βββ GPT-4o-mini generates answer from retrieved chunks
β βββ Confidence threshold: < 0.7 β "Let me check" β human queue
β
βββ Week 4
β βββ Day 16-17: Negotiation logic + guardrails
β β βββ Counter-offer algorithm (midpoint, max 3 rounds, escalate)
β β βββ Output validation (rate extraction, profanity check, PII check)
β β βββ Input sanitization (prompt injection prevention)
β β βββ Lead scoring: Cold / Warm / Hot / Rejected
β β
β βββ Day 18-19: Human handoff + Slack integration
β β βββ n8n workflow: agent β Slack interactive message
β β βββ Chatwoot: agent β human assignment
β β βββ Human takeover in Chatwoot inbox
β β βββ Google Sheet status sync on every state change
β β
β βββ Day 20: Voice fallback agent
β βββ Twilio Voice + Deepgram STT + ElevenLabs TTS pipeline
β βββ Same LangGraph FSM, voice-adapted (shorter responses)
β βββ n8n trigger: 48h no WA response β schedule voice call
β βββ Warm transfer to human if needed
β
βββ Week 5
β βββ Day 21-23: End-to-end testing
β β βββ Full flow: Sheet β WA β Negotiate β Handoff β Close β Sheet update
β β βββ Edge cases: non-responsive, reject, > max budget, Hinglish, sarcasm
β β βββ Voice flow testing
β β βββ Load test: 50 concurrent conversations
β β βββ Quality audit: review 20 AI conversations for tone + accuracy
β β
β βββ Day 24-25: Polish
β βββ Error handling, retries, exponential backoff
β βββ Conversation timeout (auto-follow-up at 24h, 48h, then dormant)
β βββ Metabase: conversation management views
β
β β
DELIVERABLE: Full outreach β negotiate β handoff β close pipeline.
PHASE 2 β IG Monitoring (Week 6-8)
βββ Week 6: Instagram Graph API + Phyllo integration + polling n8n workflows
βββ Week 7: Tiered sentiment pipeline + anomaly detection + ROI engine
βββ Week 8: Metabase dashboard enhancements + testing with real data
β
β β
DELIVERABLE: Live engagement dashboard with sentiment + anomalies.
PHASE 3 β Discovery + Hardening (Week 9-10)
βββ Week 9: Modash discovery + dedup + enrichment (n8n workflow)
βββ Week 10: Security hardening + documentation + UAT + go-live
β
β β
DELIVERABLE: Production platform, hardened, documented.
Timeline Summary
WEEK: 1 2 3 4 5 6 7 8 9 10
ββββββ€ββββββββββ€βββββ€ββββββββββ€βββββ€ββββββββββ€βββββ€
Phase 0 ββββββββ
Phase 1 ββββββββββββββββ
Phase 2 ββββββββββββββββ
Phase 3 ββββββββ
META VERIFICATION ββββββββββββββββ (parallel)
TOTAL: 10 weeks to production MVP
13. Team Structure
Revised for open-source leverage β smaller team needed:
| Role | Count | Responsibilities |
|---|---|---|
| Tech Lead / Architect | 1 | System design, code reviews, n8n workflow design, integration decisions |
| Backend/AI Engineer (Python) | 1 | LangGraph agent, FastAPI, guardrails, voice pipeline, sentiment pipeline |
| Integrations Engineer (Node.js/Python) | 1 | n8n workflows, Chatwoot config, Sheets sync, IG polling, Modash integration |
| QA + DevOps | 0.5 (shared) | E2E testing, Railway deployment, monitoring |
Total: 3.5 FTE for 10 weeks (down from 4.25 in v1 β open-source tooling saves ~0.75 FTE)
14. Assumptions, Dependencies & Out of Scope
14.1 Client Responsibilities
- Provide Google Sheet with influencer data (name, WhatsApp, category, followers, IG handle) β Week 1
- Initiate Meta Business verification + WhatsApp Business API access β Week 1
- Provide campaign briefs, FAQ docs, product details, budget bands β before Phase 1
- Coordinate influencer consent for IG Graph API permissions
- Designate Slack channel + assign lead follow-up team
14.2 Assumptions
- β₯60% of influencers have WhatsApp numbers
- IG Graph API accessible for meaningful subset (Business/Creator accounts)
- Phyllo/Modash subscriptions approved ($200-500/mo)
- LLM API costs budgeted separately
- Cloud hosting approved (~$100-300/mo)
14.3 Out of Scope (v1)
- CRM integration (Salesforce, HubSpot) β Chatwoot + Sheets serves as v1 CRM
- YouTube, TikTok, Twitter monitoring β IG only
- Contract generation / e-signature
- Payment processing / invoicing
- Custom mobile app β web only
- Multi-language beyond English + Hindi/Hinglish
15. Open-Source Tooling Map β Build vs. Reuse
This is the key section. For every component, we evaluate: should we build it, or use an existing open-source project?
15.1 Recommended Open-Source Repos
| Component | Repo | Stars | License | What It Does | Our Usage | Build vs. Reuse |
|---|---|---|---|---|---|---|
| Workflow Orchestration | n8n-io/n8n | 52K+ | Sustainable Use | Visual workflow automation with 400+ integrations | All scheduling, triggers, retries, Sheet sync, Slack alerts | β REUSE β saves ~2 weeks of custom scheduler code |
| Conversation Inbox | chatwoot/chatwoot | 21K+ | MIT | Omnichannel customer messaging platform | WhatsApp conversation UI, agent assignment, conversation history | β REUSE β saves ~3 weeks of custom chat UI |
| Analytics Dashboard | metabase/metabase | 40K+ | AGPL-3.0 | Business intelligence / dashboard builder | v1 IG engagement dashboard, campaign reports | β REUSE for v1 β ship in 2 days; build custom v2 later if needed |
| Sentiment Analysis | cardiffnlp/twitter-xlm-roberta-base-sentiment-multilingual | 10.8M DL | CC-BY-4.0 | Multilingual social media sentiment classification | Tier 1 bulk sentiment on comments | β REUSE β free, accurate, multilingual |
| WhatsApp Dev Sandbox | EvolutionAPI/evolution-api | 2K+ | Apache 2.0 | Self-hosted WhatsApp HTTP API | Local dev/testing without Meta API quota | β REUSE for dev β don't use in production |
| WhatsApp Dev Sandbox (alt) | devlikeapro/waha | 3K+ | Custom | Self-hosted WhatsApp REST API | Alternative to Evolution API | β REUSE for dev β choose based on team preference |
| Vector Store for FAQ | pgvector (Supabase-native) | Built into Supabase | PostgreSQL License | Vector similarity search in PostgreSQL | FAQ RAG retrieval | β REUSE β zero extra infra; already in our DB |
| Chatbot Builder (alternative) | baptisteArno/typebot.io | 8K+ | AGPL-3.0 | No-code visual chatbot builder with WhatsApp | Could replace LangGraph for simpler flows | β SKIP β too limited for our negotiation FSM |
| Agent Framework | langchain-ai/langgraph | 10K+ | MIT | Graph-based LLM agent framework with state machines | Negotiation state machine β our core IP | β REUSE (it's our agent framework) |
| WA+LangGraph Reference | lucasboscatti/Whatsapp-Langgraph-Agent-Integration | ~87 | MIT | WhatsApp AI agent powered by LangGraph | Reference implementation β study their WA webhook + LangGraph integration pattern | π REFERENCE β don't use directly, but copy patterns |
| Influencer Platform (reference) | ManojSravan/influencer-marketing-platform | Small | β | Product engineering for influencer brand network | Reference for data model and workflow design | π REFERENCE β study schema, don't fork |
| Instagram Scraping (caution) | instaloader/instaloader | 8K+ | MIT | Download Instagram photos and metadata | Supplementary data collection for public profiles | β οΈ USE WITH CAUTION β violates IG ToS; only for research/enrichment, not production polling |
15.2 What We Build Custom (Core IP)
| Component | Why Custom |
|---|---|
| LangGraph Negotiation FSM | This is the product's core value. No off-the-shelf tool does multi-turn rate negotiation with budget guardrails, human handoff, and WhatsApp integration. |
| Budget Guardrail Layer | Security-critical; must be tailored to our specific rate validation + prompt injection prevention logic. |
| Campaign-specific prompt engineering | System prompts for each negotiation phase, campaign brief injection, tone calibration for Indian market. |
| Content-matching post detection | Image similarity matching for detecting campaign posts without hashtags β novel approach, no OSS tool for this specific use case. |
| ROI calculation engine | CPE, CPR, EMV formulas tuned to influencer marketing; lightweight custom code. |
15.3 Decision Framework
For any new feature, ask:
1. Is there an OSS repo with >1K β that does 80%+ of what we need?
YES β REUSE (fork if needed, contribute back)
NO β Continue
2. Is there a reference implementation we can study?
YES β REFERENCE (copy patterns, adapt to our stack)
NO β Continue
3. Does this component constitute core IP / competitive advantage?
YES β BUILD CUSTOM
NO β Use simplest possible glue code
16. Competitive Landscape & Market Intel
(Synthesized from Grok research β X posts, Reddit, reviews, late 2025-early 2026)
16.1 Direct Competitors
| Competitor | What They Do | Strengths | Weaknesses vs. Our Platform |
|---|---|---|---|
| Janney AI | AI agent for discovery + inbox outreach + rate negotiation | End-to-end; claims 30-45% savings on partnerships | Email/inbox only β no WhatsApp; no voice; no IG monitoring dashboard |
| Influencer Hero | AI-powered discovery + auto-messages + campaign prediction | Affordable; good CRM; automations | Not a conversational agent β templates only; no real-time negotiation |
| Grin | Full platform β discovery + outreach + tracking + payments | Enterprise-grade; Shopify integration | Expensive; complex; creators must authenticate; billing surprises |
| AspireIQ (now Aspire) | Similar to Grin | Strong marketplace | Steep learning curve; overkill for smaller teams |
| ManyChat | IG DM + comment-to-DM automation | Great for IG DMs; easy setup | No WhatsApp negotiation; no campaign monitoring; rule-based, not AI |
16.2 Our Differentiation
| Capability | Janney AI | Grin/Aspire | ManyChat | Our Platform |
|---|---|---|---|---|
| WhatsApp as primary channel | β | β | β | β |
| AI voice agent fallback | β | β | β | β |
| Real-time rate negotiation | β (email) | β | β | β (WhatsApp + voice) |
| Hard budget guardrails in code | Unknown | β | β | β |
| IG engagement dashboard | β | β | β | β |
| Sentiment analysis on comments | β | Basic | β | β (tiered, multilingual) |
| Anomaly detection | β | β | β | β |
| Hindi/Hinglish support | β | β | β | β |
| Google Sheets as CRM | β | β | β | β (client's existing workflow) |
| Open-source components | β | β | β | β (lower lock-in, lower cost) |
16.3 Market Sentiment Summary
- "Future is agents, not more tools" β brands want AI that acts, not just dashboards to look at
- Human-in-the-loop is non-negotiable β pure automation without human oversight erodes relationships
- Personalization is king β reference specific posts/content in outreach, not just "Hi {name}"
- India market opportunity β WhatsApp dominant, regional language support is a gap in existing tools
- Price sensitivity β smaller teams reject annual contracts and enterprise pricing; our ~$329/mo at 100 influencers is highly competitive vs. Grin ($$$) or CreatorIQ ($$$$)
17. Appendix β Tech Lead Review
β Agreements (unchanged from v1)
| Proposal | Status |
|---|---|
| Graph API as primary IG data source | β Agreed |
| Permission dependency is a real blocker | β Agreed β solved with dual-layer |
| Slack for human handoff + Sheet status updates | β Agreed |
| Google Sheets as CRM in v1 | β Agreed |
| Discovery workflow every 2-3 days | β Agreed |
| Deduplicate on IG handle | β Agreed |
π Divergences (expanded from v1)
| Tech Lead Said | Our Position | Why |
|---|---|---|
| Phyllo OR Graph API | Both β dual-layer | Graph API free + Phyllo fills gaps |
| Twilio for WhatsApp | Cloud API direct; Twilio only for voice | 10-15% savings; direct template control |
| No AI framework specified | LangGraph + hard-coded guardrails | Deterministic FSM; budget caps enforced in code |
| No anomaly detection | Modified Z-Score | Proactive campaign management |
| No post detection strategy | Triple detection (hashtag + mention + image similarity) | Catches lazy influencers |
| No mention of orchestration engine | n8n (self-hosted) | Saves 2 weeks of scheduler code |
| No mention of conversation inbox | Chatwoot (self-hosted) | Saves 3 weeks of chat UI code |
| No mention of FAQ system | pgvector RAG in Supabase | Accurate FAQ answers; prevents hallucination |
18. Appendix β API Rate Limits
| API | Limit | Our Usage | Headroom |
|---|---|---|---|
| WhatsApp Cloud API | 250β1Kβ10K/day (tier-based) | Pace at 50/hr | 5Γ at tier 2 |
| Instagram Graph API | 200 calls/user/hour | 6 polls/day Γ 100 influencers | 95% under limit |
| OpenAI GPT-4o | 10K RPM (Tier 3) | Peak: ~100 RPM | 100Γ headroom |
| Google Sheets API | 300 req/min | ~10/min batched | 30Γ headroom |
| Slack API | 20 msg/min/channel | Peak: 5/min | 4Γ headroom |
| HuggingFace Inference API | 30K char/min (free) | ~10K char/batch | 3Γ headroom |
| Phyllo API | ~100/min | ~0.13/min | Massive |
19. Appendix β Glossary
| Term | Definition |
|---|---|
| BSP | Business Solution Provider β third-party WhatsApp API mediator (Twilio, WATI, 360dialog) |
| CPE | Cost per Engagement |
| CPR | Cost per Reach |
| EMV | Estimated Media Value |
| FSM | Finite State Machine |
| RAG | Retrieval-Augmented Generation β LLM answers grounded in retrieved documents |
| RLS | Row-Level Security (Supabase/PostgreSQL) |
| STT | Speech-to-Text |
| TTS | Text-to-Speech |
| Template Message | Pre-approved WhatsApp format for business-initiated conversations |
| Conversation Window | 24-hour period after user replies allowing free-form messages |
20. Next Steps
| # | Action | Owner | Timeline |
|---|---|---|---|
| 1 | Product team reviews this TDD and approves scope | Product | Week 0 |
| 2 | Commercial proposal finalized based on TDD | Tech Lead + Sales | Week 0 |
| 3 | Client initiates Meta Business verification | Client | Day 1 (critical path) |
| 4 | Client provides Google Sheet with sample influencer data | Client | Week 1 |
| 5 | Client provides campaign brief + FAQ docs + budget bands | Client | Before Phase 1 |
| 6 | Engineering kickoff upon contract signature | Eng Team | Week 1 |
This document is intended for internal review and scoping. Estimates subject to revision based on client requirements, API access timelines, and agreed scope.
End of Technical Design Document v2.0