Categories: AI Projects
Tags:

(Step-by-Step Windows Tutorial)

Artificial Intelligence has completely changed how we create content. Instead of manually writing long-form articles, you can now build a system that generates 2000-word SEO-optimized blog posts automatically — and prepares them for WordPress publishing.

In this tutorial, I’ll walk you step-by-step through building your own AI blog generator using:

  • Python
  • Groq API
  • Llama 3 models
  • Windows virtual environment
  • Clean modular project structure

By the end of this guide, you will have a working system that:

  • Accepts a heading
  • Applies a defined author persona
  • Generates a 2000-word SEO article
  • Saves the article as HTML
  • Prepares it for WordPress automation

Let’s begin.


Step 1: Create a Clean Project Environment (Windows)

Before writing any AI logic, we need a clean development setup.

1. Create a Project Folder

Open Command Prompt and run:

mkdir ai_wp_publisher
cd ai_wp_publisher

This keeps your AI automation project isolated.


2. Create a Virtual Environment

Inside your project folder:

python -m venv venv

If python doesn’t work, use:

py -m venv venv

3. Activate the Environment

venv\Scripts\activate

You should now see:

(venv) D:\ai_wp_publisher>

This ensures all dependencies stay isolated from your global Python installation.


4. Upgrade pip

python -m pip install --upgrade pip

5. Install Required Packages

For Groq + environment handling:

pip install groq python-dotenv requests

We only install what we need. Clean projects scale better.


Step 2: Create Project Structure

Your folder should now look like this:

ai_wp_publisher/

├── venv/
├── main.py
├── content_generator.py
├── .env
└── output/

Create missing files if needed:

mkdir output
type nul > main.py
type nul > content_generator.py
type nul > .env

Step 3: Secure Your Groq API Key

Never hardcode API keys.

Inside .env file:

GROQ_API_KEY=your_actual_key_here

Important:

  • No quotes
  • No spaces
  • Ensure file name is .env (not .env.txt)

Step 4: Build the Content Generator Module

Open content_generator.py and add:

import os
from dotenv import load_dotenv
from groq import Groq
import reload_dotenv()client = Groq(api_key=os.getenv("GROQ_API_KEY"))def create_slug(title):
slug = re.sub(r'[^a-zA-Z0-9]+', '-', title.lower())
return slug.strip('-')def build_prompt(heading, persona, word_count=2000):
return f"""
Write a {word_count}-word SEO-optimized blog article in clean HTML format.Title: {heading}
Author Persona: {persona}Requirements:
- Engaging introduction
- Proper <h2> and <h3> structure
- SEO optimized
- Natural human tone
- Add conclusion
- Add meta description at the end in this format:META_DESCRIPTION: your meta description hereOnly return HTML content.
"""def generate_article(heading, persona):
prompt = build_prompt(heading, persona) response = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are an expert SEO blog writer."},
{"role": "user", "content": prompt}
],
model="llama-3.3-70b-versatile",
temperature=0.7,
) content = response.choices[0].message.content return {
"title": heading,
"slug": create_slug(heading),
"content": content
}

What this does:

  • Builds a structured prompt
  • Calls Groq’s Llama model
  • Generates SEO HTML article
  • Creates slug automatically

Step 5: Create the Entry Script

Open main.py:

from content_generator import generate_articleheading = "How to Unlock Locked Out Accounts in Windows 11"
persona = "Jessica, a tech-savvy working mom who explains things clearly and practically"article = generate_article(heading, persona)with open("output/article.html", "w", encoding="utf-8") as f:
f.write(article["content"])print("✅ Article generated successfully!")
print("Slug:", article["slug"])

This script:

  • Sends heading + persona
  • Generates 2000-word article
  • Saves it as HTML
  • Prints slug

Step 6: Run the Program

Inside activated environment:

python main.py

After a few seconds, you should see:

✅ Article generated successfully!
Slug: how-to-unlock-locked-out-accounts-in-windows-11

Inside /output/ folder, you will find:

article.html

Open it in browser to see your full AI-generated blog post.


What You Have Built So Far

You now have:

✔ AI-powered content engine
✔ Persona-based writing system
✔ SEO-structured HTML output
✔ Slug generator
✔ Secure API handling
✔ Modular architecture

And most importantly:

You have built the foundation of a fully automated AI WordPress publishing system.


What Comes Next

Now that article generation works, the next logical steps will be:

  • Extract meta description cleanly
  • Auto-generate featured image
  • Connect to WordPress REST API
  • Publish automatically
  • Add categories & tags
  • Add internal linking automation

But none of that matters until your content engine is stable.

And now it is.