Building an Email Automation Assistant with OpenAI

April 3rd, 2023

Note: written in April 2023. The model names have moved on (GPT-4 class models and the newer tools/function-calling APIs make this far easier now), but the overall approach still applies.

Email is where a lot of routine work piles up: drafting the same kinds of replies, sorting, summarizing long threads, chasing follow-ups. A language model is well suited to most of that. Here is how I would approach building an email assistant on OpenAI's API.

1. Pick the Model

Use a current GPT-4 class model rather than the older GPT-3 generation I would have reached for in 2023. Newer models follow instructions more reliably and handle longer threads, which matters when you are summarizing a deep email chain.

2. Decide What It Should Do

Scope it tightly. Good first tasks: draft replies from a short prompt, summarize long threads, sort and prioritize incoming mail, set follow-up reminders, generate out-of-office replies. Resist building all of these at once.

3. Connect to the Mailbox

Integrate with Gmail, Outlook, or whatever the user runs, through their API, using OAuth 2.0 for secure, revocable access. Never store more of the mailbox than you need.

4. Wire It Together

At a high level: take the user's request, send the relevant email text to the model with a clear instruction, and act on the response (draft, label, summarize). Modern function-calling / tools APIs make the "act on the response" part much cleaner than hand-parsing text.

5. Fine-Tune Only If You Need To

For most use cases, a good prompt with a few examples beats fine-tuning. Reach for fine-tuning only when you have a consistent, domain-specific style the base model keeps missing.

6. Test, Then Keep a Human in the Loop

Auto-sending AI-written email is risky. Start with "draft for review," measure how often the drafts are usable, and only automate the low-stakes, high-confidence cases.

The Honest Take

An email assistant is one of the most practical, low-risk ways to put an LLM to work. The hard part is not the model, it is the integration and the guardrails. Keep the scope small, keep a person approving anything that gets sent, and it pays for itself quickly.