Block 10: AI Personalization Generator

LLM-Powered Outreach
Generation Service

Mini-service that generates personalized outreach text (email, LinkedIn, SMS) using lead + company context with strict guardrails, variant generation, and full audit trail.

3 Variants

Per Request

Safe Content

No Hallucinations

Multi-Channel

Email/LinkedIn/SMS

Scope Overview

Keep it focused: generate safe, personalized messages from minimal context

Must-Have Features

Input: lead + company context + goal (email/LinkedIn/opener)

Output: 1-3 variants + subject lines (for email)

Tone options: professional, friendly, direct

Guardrails: length limits, no hallucinated claims, safe wording

Store: request, prompt, model output, final selected version

Nice-to-Have (Later)

A/B templates for different industries

Personalization slots (opener only, CTA only)

Multi-step generation (opener → body → CTA)

Multilingual support for global outreach

Three-Tier Architecture

FastAPI orchestration + LLM provider + MongoDB for full audit trail

FastAPI Layer

AI orchestration endpoints

Request validation
LLM provider integration
Quality checks
Response formatting

LLM Provider

OpenAI / Anthropic / Any provider

Prompt engineering
Temperature control
Token management
Retry logic

MongoDB Store

Audit trail + prompt history

Request logging
Prompt versioning
Output storage
Selection tracking

Input/Output Contract

Structured request and response format with full context and metadata

PersonalizeRequest

{
  "channel": "EMAIL | LINKEDIN | SMS",
  "tone": "PROFESSIONAL | FRIENDLY | DIRECT",
  "goal": "book a 15-min call",
  "lead": {
    "first_name": "John",
    "last_name": "Doe",
    "title": "VP of Engineering",
    "company_name": "Acme Corp",
    "domain": "acme.com"
  },
  "company_context": {
    "summary": "Cloud-native platform for...",
    "keywords": ["SaaS", "cloud", "AI"],
    "tech_stack": ["React", "AWS"] // optional
  },
  "constraints": {
    "max_words": 120,
    "include_subjects": true,
    "no_claims_policy": true
  }
}

PersonalizeResponse

{
  "request_id": "req_abc123",
  "variants": [
    {
      "subject": "Quick question about Acme's cloud stack",
      "message": "Hi John,\n\nI noticed Acme is building...",
      "personalization_points": [
        "Used company summary keywords",
        "Referenced VP title",
        "Mentioned cloud + AWS tech"
      ],
      "risk_flags": []
    },
    // 2 more variants...
  ]
}

MongoDB Collections

Three collections for complete audit trail and prompt replay

personalization_requests

Full request audit trail

request_id: string

Unique request identifier

input: JSON

Full PersonalizeRequest payload

status: string

SUCCESS | FAILED

created_at: timestamp

Request timestamp

latency_ms: number

Generation latency

prompts

Prompt versioning and replay

request_id: string

Links to request

system_prompt: string

System instructions

user_prompt: string

Formatted user prompt

model: string

LLM model used

temperature: number

Generation temperature

outputs

Generated variants and selection

request_id: string

Links to request

raw_output: string

Raw LLM response

parsed_variants: array

Array of variants

selected_variant_index: number

User selection (optional)

created_at: timestamp

Output timestamp

Prompt Strategy

Simple template + strict rules = safe, personalized messages

Safety Rules

Context-Only Policy

Use ONLY provided context

No invented numbers, customers, funding, awards, or metrics

Thin Context Handling

Generic opener when context is minimal

Write relevant message without making claims

Word Count Limits

Enforce max_words constraint

Respect constraints.max_words from request

Spam Prevention

Avoid spammy language

No 'guaranteed', 'free', 'act now', or aggressive CTAs

Personalization Hierarchy

1

Website summary keywords

Primary personalization anchor

2

Role/title alignment

Secondary relevance signal

3

Tech stack (if provided)

Tactical mention when available

4

Never guess metrics

Avoid all numbers not in context

Quality Checks

Post-processing validation with automatic retry on failure

Word Count Enforcement

Verify message length against max_words

Truncate or regenerate if exceeded

Forbidden Phrase Detection

Scan for spammy language patterns

Flag or reject messages with banned terms

Hallucination Risk Detection

Check for numbers/claims not in input

Flag messages with unsourced data

Required Elements

Ensure greeting with name, CTA, relevance reason

Verify presence of all required components

Retry Logic

If quality checks fail, regenerate with stricter instructions (max 1 retry per request)

FastAPI Endpoints

Three core endpoints for generation and audit

POST/personalize

Generate personalized message variants

Request

PersonalizeRequest

Response

PersonalizeResponse (3 variants)

GET/personalize/{request_id}

Retrieve stored request and outputs

Request

request_id parameter

Response

Full request + prompt + outputs

POST/personalize/{request_id}/select

Store user's selected variant

Request

{ variant_index: 0 }

Response

Success confirmation

Optional React UI (for testing)

Minimal testing interface for experimenting with prompts and variants

Input Form

Lead fields + company summary + tone + channel selection

Generate Button

Trigger personalization with loading state

Variant Display

Show 3 variants with copy-to-clipboard button

Inline Editing

Edit box for each variant before using

Variant Selection

Select which variant to use (tracks in DB)

Risk Flags

Display any quality warnings per variant

Production Benefits

Safe, auditable, and reproducible AI personalization at scale

Generates 3 Usable Messages

Creates high-quality variants from minimal context without hallucinations

Never Invents Claims

Strict guardrails prevent unsourced metrics, customers, or fake data points

Full Audit Trail

Stores requests, prompts, and outputs in MongoDB for replay and analysis

Prompt Replay by ID

Retrieve and replay any generation using request_id for debugging and training

Done Criteria

Generates 3 usable message variants per request

Never invents claims, metrics, or unsourced data

Stores prompt + outputs in MongoDB with audit trail

Supports prompt replay by request_id

Build Your Next Product With AI Expertise

Experience the future of software development. Let our GenAI platform accelerate your next project.

Schedule a Free AI Blueprint Session