Systems Library / Marketing Automation / How to Build an AI Script Writer for Video Content
Marketing Automation content marketing

How to Build an AI Script Writer for Video Content

Generate video scripts optimized for engagement using AI frameworks.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

Most video scripts written by non-writers are structured like essays. They front-load context, bury the value, and lose the viewer in the first fifteen seconds. This ai video script writer generator system forces every script through a proper hook structure, re-hooks at regular intervals, and formats the output for teleprompter use. The result is a script that holds attention, not just covers a topic.

Video is the highest-reach content format for most audiences right now. If your scripts are not optimized for retention, you are burning production budget on videos nobody finishes.

What You Need Before Starting

Step 1: Define Your Script Formats

Different video types need different structures. Build your format library once:

# script_formats.py

SCRIPT_FORMATS = {
    "educational_short": {
        "name": "Educational Short (60-90 seconds)",
        "target_words": 180,
        "structure": [
            {"segment": "hook", "duration_sec": 5, "purpose": "Bold claim or pattern interrupt. Promise the payoff."},
            {"segment": "setup", "duration_sec": 10, "purpose": "Quick context. Why this matters."},
            {"segment": "core_value", "duration_sec": 50, "purpose": "The main teaching. One idea, done well."},
            {"segment": "cta", "duration_sec": 10, "purpose": "One clear next step. No more."}
        ]
    },
    "long_form_tutorial": {
        "name": "Tutorial (8-12 minutes)",
        "target_words": 1800,
        "structure": [
            {"segment": "hook", "duration_sec": 15, "purpose": "Show the end result first. Then promise to show how."},
            {"segment": "credibility", "duration_sec": 30, "purpose": "Why should they listen to you. Keep it short."},
            {"segment": "overview", "duration_sec": 30, "purpose": "What they will learn. Map the journey."},
            {"segment": "step_1", "duration_sec": 120, "purpose": "First major step with re-hook at the start."},
            {"segment": "step_2", "duration_sec": 120, "purpose": "Second step."},
            {"segment": "step_3", "duration_sec": 120, "purpose": "Third step."},
            {"segment": "step_4", "duration_sec": 120, "purpose": "Fourth step if needed."},
            {"segment": "recap", "duration_sec": 30, "purpose": "Summary of what they just learned."},
            {"segment": "cta", "duration_sec": 30, "purpose": "Next video or lead magnet. One CTA only."}
        ]
    },
    "ad_direct_response": {
        "name": "Ad Script (30-60 seconds)",
        "target_words": 130,
        "structure": [
            {"segment": "hook", "duration_sec": 5, "purpose": "Call out the target audience or their pain. No wasted time."},
            {"segment": "agitate", "duration_sec": 10, "purpose": "Make the pain feel real. One vivid example."},
            {"segment": "solution", "duration_sec": 20, "purpose": "Introduce the mechanism. Not the product, the principle."},
            {"segment": "proof", "duration_sec": 10, "purpose": "One concrete result. Number or name."},
            {"segment": "cta", "duration_sec": 5, "purpose": "One action. Urgent."}
        ]
    }
}

Step 2: Build the Script Generator

import os
import json
import anthropic
from dotenv import load_dotenv
from script_formats import SCRIPT_FORMATS

load_dotenv()
client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))

def generate_video_script(
    topic: str,
    audience: str,
    key_points: list,
    cta: str,
    format_key: str = "educational_short",
    speaker_voice: str = "Direct, confident, first person. Talks to the viewer like a peer.",
    examples: str = ""
) -> str:
    
    format_config = SCRIPT_FORMATS[format_key]
    structure_str = json.dumps(format_config["structure"], indent=2)
    points_str = "\n".join(f"- {p}" for p in key_points)
    
    prompt = f"""Write a complete video script following the structure below. Format for teleprompter reading.

TOPIC: {topic}
TARGET AUDIENCE: {audience}
KEY POINTS TO COVER:
{points_str}
CALL TO ACTION: {cta}
SPEAKER VOICE: {speaker_voice}
EXAMPLES OR STORIES TO INCLUDE: {examples or "None provided. Generate relevant examples."}

FORMAT: {format_config['name']}
TARGET LENGTH: {format_config['target_words']} words
STRUCTURE:
{structure_str}

FORMATTING RULES:
- Mark each segment clearly: [HOOK], [SETUP], [CORE VALUE], etc.
- Short sentences. 15 words max per sentence.
- Write how people TALK, not how they write.
- Contractions everywhere (you're, it's, don't, we've).
- No em dashes. Use periods or short pauses marked as [PAUSE].
- No jargon without immediate explanation.
- Grade 5-6 reading level.
- Re-hook before every major segment transition.
- Add [VISUAL CUE] notes where B-roll or graphics would help.

After the script, add:
HOOK ALTERNATIVES: (3 alternative opening lines)
THUMBNAIL TITLE: (5-7 word hook for the thumbnail text)"""

    message = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=3000,
        messages=[{"role": "user", "content": prompt}]
    )
    
    return message.content[0].text

Step 3: Generate Hook Variations

The first five seconds determine whether the video works. Generate more options:

def generate_hook_variations(topic: str, audience: str, count: int = 10) -> str:
    prompt = f"""Generate {count} video hook variations for this topic.

TOPIC: {topic}
AUDIENCE: {audience}

Use these hook types (one per variation):
1. Bold claim (counter-intuitive statement)
2. Question that creates immediate curiosity
3. Story opener ("Last month I...")
4. Pattern interrupt (unexpected statement)
5. Result first ("In 30 minutes you'll know how to...")
6. Contrarian ("Everyone says X. They're wrong.")
7. Problem agitation ("If you're doing X, you're wasting...")
8. Social proof ("10,000 people used this to...")
9. Specific number ("3 things nobody tells you about...")
10. Direct call-out ("If you're a [audience], this is for you.")

Rules:
- Max 15 words per hook
- No em dashes
- Conversational, not polished
- Number each one

Return as a numbered list."""

    message = client.messages.create(
        model="claude-opus-4-5",
        max_tokens=600,
        messages=[{"role": "user", "content": prompt}]
    )
    
    return message.content[0].text

Step 4: Format for Teleprompter

def format_for_teleprompter(script: str, words_per_line: int = 8) -> str:
    lines = script.split("\n")
    formatted = []
    
    for line in lines:
        if line.startswith("[") or not line.strip():
            formatted.append(line)
            continue
        
        words = line.split()
        chunks = [words[i:i+words_per_line] for i in range(0, len(words), words_per_line)]
        for chunk in chunks:
            formatted.append(" ".join(chunk))
    
    return "\n".join(formatted)

def save_script(script: str, topic: str, format_key: str):
    filename = topic.lower().replace(" ", "-")[:40] + f"-{format_key}-script.md"
    
    with open(filename, "w") as f:
        f.write(f"# Script: {topic}\n")
        f.write(f"Format: {SCRIPT_FORMATS[format_key]['name']}\n\n")
        f.write("---\n\n")
        f.write(script)
    
    teleprompter_file = filename.replace(".md", "-teleprompter.md")
    with open(teleprompter_file, "w") as f:
        f.write(format_for_teleprompter(script))
    
    print(f"Saved: {filename}")
    print(f"Teleprompter version: {teleprompter_file}")

if __name__ == "__main__":
    script = generate_video_script(
        topic="How to build an AI content brief generator in Python",
        audience="Marketing managers and developers who want to automate content work",
        key_points=[
            "Why briefs are the bottleneck in content operations",
            "The three data sources that make AI briefs better than manual ones",
            "The exact prompt structure that works",
            "How to batch process 50 briefs at once"
        ],
        cta="Download the starter code from the link in the description",
        format_key="long_form_tutorial"
    )
    
    save_script(script, "ai-content-brief-generator-python", "long_form_tutorial")
    
    hooks = generate_hook_variations(
        "How to build an AI content brief generator",
        "marketing managers and developers"
    )
    print("\nHOOK OPTIONS:\n" + hooks)

What to Build Next

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