Sub topic 13
Using generative AI for content variants
This chapter assumes you know how segments and templates work from earlier chapters, can read basic Python, and understand A/B testing at a high level. Generative AI can write many versions of a message. It does not decide who gets which version, and it does not prove that a version works. Those jobs stay with your segments, decisioning and tests.
Where generation fits
Generate variants of the content modules you already have, such as subject lines, headlines and short body copy. Do not generate a whole message per customer in real time. Pre-generated variants can be reviewed, tested and reused. Live generation per customer is slower, costs more and is harder to audit.
Write a constrained brief
A good brief gives the model the facts and the limits. Describe the segment by its business name and behaviour, not by personal data. State the goal, tone, length, and what the copy must not claim.
- Segment: lapsed customers who last bought 60 or more days ago.
- Goal: bring them back to their saved basket.
- Tone: friendly, plain, no pressure.
- Limits: under 60 characters, no discount amounts, no urgency claims.
Keep names, emails and order details out of the prompt. Fill those in later through the template, as in the dynamic content chapter. This keeps personal data away from the model and keeps your consent rules simple.
Check variants before anyone sees them
Run cheap automated checks first, so reviewers see only candidates that pass. The example below checks length, banned phrases and template placeholders. It assumes the model returned a list of strings.
import re
BANNED = ["guaranteed", "last chance", "free money"]
ALLOWED_FIELDS = {"first_name"}
MAX_LEN = 60
def check_variant(text):
problems = []
if len(text) > MAX_LEN:
problems.append("too long")
lowered = text.lower()
for phrase in BANNED:
if phrase in lowered:
problems.append(f"banned phrase: {phrase}")
fields = set(re.findall(r"\{\{\s*(\w+)", text))
if not fields <= ALLOWED_FIELDS:
problems.append(f"unknown fields: {sorted(fields - ALLOWED_FIELDS)}")
return problems
candidates = [
"Hi {{ first_name }}, your basket is waiting",
"Last chance! Guaranteed savings on your basket today only",
"{{ home_address }}, come back and finish your order",
]
approved = [c for c in candidates if not check_variant(c)]
for c in candidates:
print(check_variant(c) or "ok", "-", c)
print(approved)Only the first candidate passes. The second breaks two content rules and is also too long. The third refers to a field your template does not supply.
Common errors
- Inventing facts. Models may state prices, dates or product features that are not true. Supply facts in the brief and have a person verify claims.
- Skipping fallbacks. Every generated variant that uses a field needs a default, just like a hand-written one.
- Many near-identical variants. Fifty rewordings of one idea give a bandit nothing to learn from. Vary the angle, such as price, novelty or reassurance.
- Brand and tone drift. Include approved example copy in the brief and review a sample from every batch.
- Treating output as proven. A fluent variant is not a good one. Send it through the same holdout and A/B process as any other.
Record what you generated
Store the brief, the model name and version, the date, the reviewer and the approval status with each variant. When a variant underperforms or causes a complaint, you can then trace where it came from. This record also supports the governance work covered in the final chapter.
Exercise
A team prompts a model with each customer's name, last purchase and email address to write a unique message for every send. Name two problems with this approach and describe a better design.
Show answer
First, personal data goes to the model, which complicates consent and privacy, and live output cannot be reviewed or tested before sending. Second, per-customer generation is costly and slow, and makes it hard to measure which message worked. A better design generates a small set of reviewed variants per segment from a brief that contains no personal data, stores them as content modules with fallbacks, fills in fields through the template, and lets decisioning and holdout tests choose and evaluate them.
Exercise
Your generated variants all say the same thing in different words. Why does this limit a bandit, and what should you change in the brief?
Show answer
The bandit can only learn which idea works if the variants differ in a meaningful way. Near-copies produce similar click rates, so it learns nothing useful. Ask for distinct angles, for example price, new arrivals and reassurance, and check that each candidate uses a different one.