When 6sense decided to turn its massive intent data into actionable outbound emails, I was tasked with building the AI Email Writer from the ground up. This wasn’t just another GPT wrapper — it was a production system that needed to be accurate, safe, and scalable.

The Problem

Sales teams spend hours crafting personalized outbound emails. Even with intent data telling them who to contact and why, the actual email composition remained a manual bottleneck. We needed a system that could:

  • Ingest multiple data signals (CRM history, technographics, behavioral data, intent signals)
  • Generate personalized, context-aware emails
  • Guarantee safety — no hallucinations, no inappropriate content in customer-facing communications
  • Scale to thousands of emails daily across hundreds of organizations

Architecture

The system was built as a Django-based pipeline with OpenAI’s API at its core:

  1. Data Aggregation Layer: Pull together intent signals, technographic data, CRM interaction history, and behavioral signals for each target account
  2. Prompt Engineering: Dynamic prompt construction that weaves together all data signals into a coherent context window
  3. LLM Generation: OpenAI API calls with carefully tuned parameters for tone, length, and style
  4. Multi-Layer Guardrails: Three concurrent validation checks run on every generated email
  5. Feedback Loops: Failed validations trigger automatic retries with adjusted prompts

The Guardrails System

This was the most critical engineering challenge. AI-generated outbound emails carry significant brand risk. I engineered a three-layer validation system:

  • Safety Check: Screens for inappropriate content, competitor mentions, and policy violations
  • Hallucination Detection: Cross-references generated claims against actual account data — if the email mentions a metric or fact, it must exist in the source data
  • Framework Check: Validates email structure, call-to-action presence, and adherence to the selected email framework (AIDA, PAS, BAB, etc.)

All three checks run concurrently for performance. If any check fails, the system triggers a feedback-loop retry with the failure reason injected into the prompt.

Credit-Based Usage System

To manage costs and prevent abuse, I built an org-level quota system:

  • Organization Quotas: Each org gets allocated credits based on their subscription tier
  • Regeneration Limits: Users can regenerate emails, but each regeneration consumes credits
  • Real-Time Tracking: Live dashboards showing credit usage, remaining balance, and consumption trends
  • Graceful Degradation: When credits run low, the system alerts admins before hitting hard limits

Impact

The results exceeded expectations:

MetricResult
Daily Volume1,500+ emails generated
Reply Rate42% (vs. ~15% industry average)
Booked Meetings29% increase from outbound campaigns
Guardrail Pass Rate94% on first attempt

Tech Stack

Python · Django · OpenAI API · Celery · Redis · PostgreSQL


This project represents the intersection of AI engineering and product thinking — building systems that are not just technically impressive but deliver measurable business outcomes.