How to build a pipeline that learns a sender's writing style, categorizes leads by relationship history, and generates personalized Gmail drafts automatically.
A pipeline that ghostwrites personalized sales follow-up emails and saves them directly as Gmail drafts — ready to review and send. It learns the sender's writing style from their own sent mail, categorizes leads by relationship history, and generates emails that sound authentically human — properly threaded into existing conversations, with smart asset selection based on audience type.
The end result: a Gmail drafts inbox full of persona-consistent, ready-to-send emails that take minutes to review instead of hours to write.
Built entirely in Claude Code via Cursor with permissions skip enabled.
Lead spreadsheet → Style learning → Lead categorization →
Dry run (review + approve) → Full draft generation → Gmail Drafts
Everything is stateful and restartable. Each phase writes its outputs to disk before the next begins — the pipeline can be paused, inspected, or restarted at any point without losing work.
A CSV lead list with these columns: name, email, organization, LinkedIn URL, and conference/source. The pipeline handles any lead source — conferences, events, inbound lists, whatever you're working from.
| Service | Role |
|---|---|
| Gmail API | Read sent mail, search threads, create/delete drafts |
| Google OAuth2 | Secure authentication into Gmail |
| GPT-4o | Style analysis + email generation |
| Calendly | Meeting booking CTA link embedded in every email |
| YouTube / Asset library | Demo or resource links, mapped per use case |
What it answers: How does this person actually write?
The system fetches the sender's recent sent emails from Gmail — up to 100 messages filtered for outreach-style content — and sends them to GPT-4o for style analysis.
💡 Prompt suggestion for style analysis:"You are analyzing a person's email writing style. Here are [N] emails they have sent. Extract and describe: their tone and voice (formal vs casual, direct vs warm), how they open and close emails, how they present calls to action, their sentence length and punctuation habits, and their exact signature block. Output a detailed style profile I can use to ghostwrite future emails in their voice."