AI Email Template Enhancer
Alongside AI automation, AI agents, voice agents, and RAG systems, we also work with SaaS platforms that need help building AI features on top of what they've already built. This case study is exactly that kind of project.
We built a one-click AI feature that takes an existing email template from Unlayer (a drag-and-drop email builder) and automatically upgrades its visual design, with no changes in the copy or image. It's just a better-looking version of the same email.
So how does it actually work? Who's using it, and why did this need to be built in the first place? Let's get into it.
The Client
Our client runs a school information system, a SaaS platform that schools use to manage day-to-day operations, including sending emails to parents and students. The platform has Unlayer built in, so schools can design their own emails from scratch.
But here's the catch: Unlayer already has some AI built in, but it only helps with image generation, and not "take this email and make it look polished." And school staff aren't designers; they're busy people who don't have time to make emails look good.
So the emails they sent out looked dull and unpolished, with no background color, unstyled tables, plain blue underlined links, and email addresses typed out as plain text instead of clickable links.
Goal
The client wanted a one-click "Enhance" button built directly into their platform. A user opens a template they've already built in Unlayer, clicks the button, and gets a better-looking version of the same template, ready to keep editing in Unlayer.
Challenges & Solutions
1. Unlayer stores templates as JSON, not HTML
Emails are ultimately HTML, and LLMs are well-trained on HTML and CSS. But during our planning phase, we discovered that Unlayer stores templates as JSON, which means the model can't just write CSS. It has to translate design intent into the correct fields of a schema it's never specifically seen before.
Solution: We did heavy prompt engineering around the schema, with tight restrictions on what the model can touch, and a deterministic post-processing step to catch anything the model got wrong.
2. Improving the design without touching the content
The client's rule was that copy and images could not change at all. School emails often contain dates, names, and information that staff had already checked, so nothing in them could be rewritten or regenerated. The entire enhancement had to happen only in the styling and layout layer.
Solution: We restricted the model to styling and structure only, which includes backgrounds, borders, font hierarchy, tables, buttons, and the color scheme from the colors already present in the template. The post-processing step then verifies the output against the original, so that anything outside those bounds never reaches the user, and the user gets their original template back.
3. Synchronous version felt broken
Processing time depends on template size, and there was no way to tell the user how long it would take. A 30-second silent wait makes users think the system has hung, and the user couldn't submit a second template while the first one was processing.
Solution: We rearchitected to an asynchronous, queue-based system. The user submits a template, gets an immediate acknowledgment and a time estimate, and can queue more templates while earlier ones are still processing.
4. Telling the user how long it will take
Once we knew a template was processing, a progress indicator with no ETA is still a poor experience.
Solution: We built a self-improving time estimator that predicts duration from similar past templates' real durations, growing more accurate with every completed job.
Tech stack
- FastAPI: Python API layer
- LLM: OpenAI GPT-4o (we tested a few different models and chose GPT-4o for layout quality, and because the client's ecosystem was already running on GPT)
- Celery: Background worker for asynchronous processing
- Redis: Message queue between the API and the workers
- Docker: The application and the Celery worker run in separate containers
Project Outcomes
The Enhance button is live and in use across all schools on the platform. A user opens a template they've already built, clicks once, and gets back a redesigned version of the same email, still fully editable in Unlayer.
Emails going out to parents and students now look significantly better than before, without school staff having to learn anything, change their workflow, or rewrite a single word. The Enhance button handles the styling, spacing, layout, and formatting details that make an email look designed rather than typed out.
There's a version of this for your business. The call to find it is thirty minutes.
or email nabeel@endloop.co