AI Writer v1.0

Part of CloudWizard Email Suite

AI Writer drafts campaign copy from brand voice profiles and a reusable story bank, using your own Anthropic API key. Generated drafts can be edited before being loaded into a Mail Engine campaign. Every generation's real token usage and cost is recorded and shown to you — nothing is estimated after the fact.

Requirements

RequirementDetail
PHP8.1 or higher
MariaDB / MySQL5.7+ / 10.3+
Web serverNginx or Apache
Outbound HTTPSServer must reach api.anthropic.com to generate drafts, and cloudwizard.eu for license verification
Anthropic API keyYour own key from console.anthropic.com — billed directly to you, not through CloudWizard

Step 1 — Install the Controller

AI Writer runs inside the CloudWizard Controller. The controller handles authentication, shared database config, and module detection. Install it first.

Upload the controller

Unzip the download. It holds one folder, CW/, with the controller and AI Writer inside. Upload that whole folder to a directory on your server — typically public_html/CW/. The controller part looks like this:

public_html/CW/
  bootstrap.php
  config_path.php
  vendor/            ← bundled PHPMailer, shared across every module
  admin/
    index.php
    login.php
    logout.php
    settings.php
    setup.php
    style.css
    ...

Run the setup wizard

Visit https://yourdomain.com/CW/admin/setup.php to run the wizard. Fill in:

  • Database — host, name, username, password, table prefix (default: cw_)
  • SMTP — outgoing mail server credentials, used elsewhere in the suite
  • Admin password — minimum 8 characters
  • Site URL — your public domain

Click Complete setup. The config file is written outside your webroot where possible.

Add your Anthropic API key

In the controller go to Settings, add anthropic_api_key, and save. AI Writer reads this key from the shared controller config — there is no separate key field inside the module itself.

Controller ready. Continue to install AI Writer.

Step 2 — Install AI Writer

Upload the module

The module is already inside the zip you just uploaded, at CW/AIWriter/. Adding it to an existing CloudWizard install instead? Don't upload the whole CW/ folder again: copy just this module's AIWriter/ folder into your existing controller directory and reload the dashboard. Its file layout:

public_html/CW/AIWriter/
  module.php
  bootstrap.php
  lib/
    ai.php
  admin/
    _bootstrap.php
    index.php      ← Overview
    drafts.php     ← Draft Library
    generate.php
    edit.php
    profiles.php
    stories.php    ← Story Bank
    rates.php

Verify detection

Reload the controller dashboard. The AI Writer card should show Open →. If it still shows "Not installed", confirm AIWriter/module.php is on the server and readable by PHP.

All module directories must sit directly inside the controller root (CW/AIWriter/), not nested deeper.

Step 3 — Activate your license

Get your license key

Whether you purchase through cloudwizard.eu or via Gumroad, your license key is shown on the confirmation page and emailed to you. Format: XXXX-XXXX-XXXX.

Enter the key

In the controller go to Settings → License key, paste the key, click Save settings. The key is verified against the CloudWizard license server immediately.

Verification

Once active, your install domain is registered. The license is re-verified automatically in the background every few days — no manual action required.

License active. Go to AI Writer and create your first profile.

AI Profiles

A profile defines the voice a draft is generated in. From AI Writer → Profiles, click + New profile.

FieldPurpose
Profile nameInternal label only — not seen by recipients
Brand nameThe brand voice being written for
AudienceFree text describing who receives these emails
Voice / toneFree text — e.g. "warm, personal, story-driven, conversational"
Never doOne rule per line — hard constraints the model must not violate
Core beliefsOne belief per line — the underlying worldview drafts should reflect
ModelPulled live from Model Rates — see that section
StatusActive profiles appear in the Generate screen; paused ones don't

Use Duplicate on an existing profile to start a close variant (e.g. the same brand in a second language) without re-typing everything — it copies every field except the profile name, prefixed "Copy of…", and opens the new copy for editing.

Deleting a profile removes its story bank with it — there's no separate recovery for stories once the profile is gone.

Story Bank

Each profile has its own story bank — a set of concrete anecdotes the model can draw on instead of inventing one from scratch. Switch profiles from the selector at the top of AI Writer → Story Bank.

Add a story

Story — the specific, concrete anecdote: real details, names, numbers. Lessons — add one or more sentences, each stating a different thing this same story proves. Use + Add another lesson to add more rows. This matters more than it might seem: the same story often gets reused across several emails, and drawing a different lesson each time is what keeps those emails from reading the same way twice — a different lesson leads to a different pivot, a different call to action, a genuinely different email built on the same real anecdote.

Research a story idea

Instead of writing a story by hand, enter a topic and click Research & draft →. This searches the web for real, current context on that topic and drafts an original story around it, along with 2-3 different possible lessons. The underlying fact the story is built on is meant to be real and checkable — a source link is shown (and saved with the story) whenever one was found, so you can verify the claim before it goes out in an email. The story's narrative details (any name, any specific scene) are always an invented illustration of that real fact, not someone's actual identifiable story. Nothing is saved until you review it and click Add story — edit anything first if needed. Each search costs a small amount on top of normal AI tokens, shown right after generating.

Edit or delete

Every story in the list has its own Edit and Delete controls.

To use the same story under a second profile, use the Copy to: control next to each story — pick the target profile and click the arrow. It skips a story that's already present there (matched by exact story text) rather than duplicating it.

Generating a draft

From AI Writer → Generate:

FieldPurpose
AI ProfileWhich voice profile to write in — switching this reloads the page to show that profile's stories and details, with no generation triggered and no cost incurred
LanguageEnglish, Russian, or German
TopicWhat the email is about
OfferOptional — what the email is asking the reader to do
CTA linkDestination URL for the call to action
StoryNone, a random pick from the profile's story bank, or a specific story. When a story has more than one lesson, a random one is used each time — so generating from the same story twice won't necessarily produce the same angle

Click Generate →. The button disables itself and shows a spinner with "Generating… (5-10s)" — a real API call is in flight, this isn't a stuck page. On success you're taken straight to the draft in the editor, with the exact cost of that generation shown at the top. There's no separate review screen in between.

Generate is disabled if no API key is configured, or if there is no active profile to generate with.

Draft Library

AI Writer → Drafts lists every generated draft — subject, profile, language, date, cost, and status (draft / used). The Cost column shows the actual dollar amount for that generation; drafts made before cost tracking was added show "—" since no usage was recorded for them. From here you can Edit, Use in campaign, or Delete any draft.

Using a draft in Mail Engine

Click Use in campaign on any draft to open a dialog with two fields:

Clicking Create campaign → creates a new draft campaign in Mail Engine, marks the AI Writer draft as "used", and takes you straight to that campaign's Send screen in Mail Engine.

This step requires Mail Engine's tables to exist — install Mail Engine if you want to use this handoff. Generating and editing a draft itself does not require Mail Engine at all.

Model Rates & cost tracking

Every generation captures the real input and output token counts returned by the Anthropic API and computes an exact cost from them — nothing is guessed or averaged. That cost is stored with the draft and shown to you right after generation and in the Draft Library.

The per-million-token prices used for that calculation live in AI Writer → Rates, not in a config file. Anthropic doesn't publish pricing through an API, so these numbers need checking by hand against claude.com/pricing from time to time — but updating them is a form field and a click, not a server edit.

ActionWhat it does
Edit an existing rateChange the Input/Output $/MTok value for a model already in the table and click Save — takes effect on the very next generation
Add a modelEnter a new model ID (exactly as it will appear in the Model dropdown on Profiles) plus its input/output rate, then click Add rate
The Model dropdown on the Profile editor is pulled live from this table — a model only becomes selectable there once it has a rate row here. If a profile's model is somehow set to something not yet in this table (e.g. a new model added directly by editing the database), it's silently priced at Haiku's rate and a row for it is created automatically so you can correct it.

Security

Troubleshooting

ErrorCauseFix
"No API key configured" anthropic_api_key not set in controller config Add it under the controller's Settings page, then retry.
Generate button disabled No active AI profile exists, or its status is Paused Create a profile or set an existing one's status to Active.
Generation fails with an API error Invalid or rate-limited Anthropic API key Verify the key directly at console.anthropic.com.
Research fails: "API key is not scoped to a workspace" Your key is an identity-linked key (tied to your personal login) rather than a workspace-scoped one — those need an extra header to work Either create a workspace-scoped key instead at console.anthropic.com, or add its Workspace ID (Settings → Workspaces in the Console) to the Workspace ID field in the controller's Settings page.
Research fails: "does not support programmatic tool calling" The AI profile's model doesn't support the mode the web search tool defaults to This is handled automatically in the current version — if you still see it, you're on an older AI Writer build and should update.
Cost shows as "—" for a draft The draft was generated before cost tracking was added, so no token/cost data was recorded for it Expected for old drafts — every new generation records cost going forward.
Displayed cost looks wrong for a model The rate for that model on the Rates page is out of date or was never corrected from Haiku's fallback Check and update the rate on AI Writer → Rates against claude.com/pricing.
A model doesn't appear in the Profile editor's Model dropdown It has no row yet in the Rates table Add it on AI Writer → Rates with its correct input/output pricing — it becomes selectable immediately.
"Use in campaign" doesn't add recipients No list selected, or the selected list has no confirmed members Only confirmed-status list members are pulled in — check the list's member statuses in Audience Manager.
Story bank empty after deleting a profile Stories are stored inside the profile record itself, not a separate table Expected — recreate stories on a new profile; there's no separate recovery.
Module not detected on dashboard module.php missing or not readable Confirm CW/AIWriter/module.php exists. Restart PHP-FPM: systemctl restart php8.3-fpm
License key not accepted Wrong key format or server can't reach cloudwizard.eu Key format: XXXX-XXXX-XXXX. Check outbound HTTPS from the server: curl -s https://cloudwizard.eu/license/ping.php
500 error on admin pages DB error, missing table, or file permissions tail -20 /home/yourusername/logs/php_log

CloudWizard Email Suite — AI Writer v1.0
cloudwizard.eu — support@cloudwizard.eu