Systems Library / Marketing Automation / How to Build an AI-Powered Ad Copy Generator
Marketing Automation paid advertising

How to Build an AI-Powered Ad Copy Generator

Generate high-converting ad copy variations using AI with your brand voice.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

An ai ad copy generator for Facebook and Google Ads needs to do more than fill in templates. It needs to understand your brand voice, your audience's pain points, and the frameworks that actually convert. I use this system to produce 30+ copy variations in minutes instead of hours.

The secret is not the AI model. It is the system prompt and the structured inputs you feed it.

What You Need Before Starting

Step 1: Create Your Brand Voice Prompt

BRAND_VOICE = """
Voice: Direct, confident, conversational. Speak like a peer who has been there.
Reading level: Grade 5-6. Short sentences. Contractions always.
NEVER use: "leverage", "utilize", "game-changer", "revolutionary"
ALWAYS use: Specific numbers, real examples, plain language
Tone: Honest, no hype, proof over promises
"""

Step 2: Build the Copy Generator

import anthropic
import json
from dotenv import load_dotenv

load_dotenv()

def generate_ad_copy(product, audience, pain_point, offer, framework="PAS", variations=5):
    client = anthropic.Anthropic()
    
    frameworks = {
        "PAS": "Problem > Agitate > Solution",
        "AIDA": "Attention > Interest > Desire > Action",
        "BAB": "Before > After > Bridge",
        "PASTOR": "Problem > Amplify > Story > Transformation > Offer > Response",
    }
    
    prompt = f"""Generate {variations} ad copy variations for Meta Ads.

Product: {product}
Target audience: {audience}
Core pain point: {pain_point}
Offer: {offer}
Framework: {frameworks.get(framework, framework)}

{BRAND_VOICE}

For each variation, provide:
1. Primary text (125 words max, conversational)
2. Headline (40 characters max)
3. Description (30 characters max)
4. Hook type (question, bold claim, story, stat, or pattern interrupt)

Return as JSON array."""

    resp = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=2000,
        messages=[{"role": "user", "content": prompt}]
    )
    
    return resp.content[0].text

Step 3: Add Winning Ad Examples as Context

Feed your best performers so the AI learns your style:

def load_winning_ads(file_path="winning_ads.json"):
    with open(file_path, "r") as f:
        return json.load(f)

def generate_with_examples(product, audience, pain_point, offer, framework="PAS"):
    winners = load_winning_ads()
    examples_text = "\n\n".join([
        f"WINNING AD (CTR: {ad['ctr']}%, Conv: {ad['conversions']}):\n{ad['copy']}"
        for ad in winners[:5]
    ])
    
    client = anthropic.Anthropic()
    prompt = f"""Study these winning ads, then generate 5 new variations that match the same quality.

WINNING AD EXAMPLES:
{examples_text}

Now generate for:
Product: {product}
Audience: {audience}  
Pain point: {pain_point}
Offer: {offer}
Framework: {framework}

{BRAND_VOICE}

Return as JSON array with primary_text, headline, description, hook_type for each."""

    resp = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=2000,
        messages=[{"role": "user", "content": prompt}]
    )
    return resp.content[0].text

Step 4: Build a Variation Matrix

Generate across multiple frameworks and hook types:

def full_copy_matrix(product, audience, pain_point, offer):
    results = {}
    for framework in ["PAS", "AIDA", "BAB", "PASTOR"]:
        copies = generate_ad_copy(product, audience, pain_point, offer, framework, variations=3)
        results[framework] = copies
    return results

This gives you 12 variations across 4 frameworks. Pick the best 5-6 to test.

Step 5: Score Before You Spend

Run each variation through a quick quality check:

def score_copy(copy_text, audience):
    client = anthropic.Anthropic()
    resp = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=300,
        messages=[{"role": "user", "content": f"""Score this ad copy 1-10 on:
- Hook strength (does it stop the scroll?)
- Relevance to {audience}
- Clarity of offer
- Call to action strength

Copy: {copy_text}

Return JSON: {{"hook": N, "relevance": N, "clarity": N, "cta": N, "total": N, "feedback": "..."}}"""}]
    )
    return resp.content[0].text

Only test ads that score 7+ across all dimensions. Below that, regenerate.

What to Build Next

Connect this to your Meta Ads API so you can push winning copy directly into ad creation. Then add A/B test tracking so the system learns which frameworks work best for each audience.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems