Back to Alchemy
Alchemy RecipeIntermediateautomation

Automate blog post repurposing into email campaigns with auto-segmentation and A/B testing

Your blog post gets published on Monday morning. By Wednesday, you've written a follow-up email to send to subscribers. By Friday, you're manually tweaking it for a second segment because you noticed the first group engages differently. By Monday again, you're copying, pasting, and testing variants in your email platform because you want to know which subject line actually converts. This is the tax you pay for not automating content repurposing. The real friction isn't writing the email once. It's writing it five times: once for each audience segment, then again for the A/B test variants, then managing which version goes to whom, then waiting for results. What if your email platform and copywriting AI could talk to each other automatically, generate segment-specific variants without you touching a thing, and schedule A/B tests that feed results back into your next campaign? That workflow exists. You just need to wire it together.

The Automated Workflow

We'll use n8n as the orchestration layer because it handles both webhook triggers and scheduled tasks well, costs nothing to self-host, and integrates cleanly with Copy.ai, ChatGPT Writer, and Postwise. If you prefer a no-code visual builder, Zapier or Make work too, though n8n gives you more control over conditional logic and data transformation. Here's how the pieces connect: 1. A new blog post publishes to your CMS (WordPress, Medium, Ghost, or wherever).

  1. n8n detects the publish event via webhook or API polling.

  2. An API call to ChatGPT Writer or Copy.ai generates initial email copy from the blog post content.

  3. n8n branches the workflow: it creates three variants using Claude Opus 4.6 (available via API), each tailored to a different audience segment.

  4. n8n splits your subscriber list by segment (stored in your CRM or email platform) and assigns variants.

  5. Variant A, B, and C are sent at staggered times with unique tracking parameters.

  6. Results flow back to n8n, which stores metrics for your next campaign.

Setting up the trigger:

Most blogging platforms offer webhooks. If yours doesn't, n8n can poll your RSS feed or CMS API at regular intervals. Here's a typical webhook shape from WordPress (using the WP Engine or Jetpack integration):

json
{ "post_id": 12345, "post_title": "How to Build an Email Marketing Stack in 2026", "post_content": "Lorem ipsum...", "post_date": "2026-03-15T10:30:00Z", "post_url": "https://yourblog.com/posts/12345"
}

Configure your CMS to POST this to an n8n webhook endpoint. You'll get a unique URL when you create a Webhook node in n8n.

Calling the AI APIs:

Once n8n receives the webhook, it extracts the post_content and passes it to Copy.ai or ChatGPT Writer. Here's how you'd structure the ChatGPT Writer call using the OpenAI API (ChatGPT Writer uses this backend):

bash
curl https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "GPT-4.1", "messages": [ { "role": "system", "content": "You are an email copywriter. Transform the given blog post into a compelling email for SaaS founders. Tone: direct and practical. Length: 150 words. Include a single clear CTA." }, { "role": "user", "content": "Blog post:\n\n' + blogContent + '" } ], "temperature": 0.7, "max_tokens": 300 }'

In n8n, you'd configure this as an HTTP Request node:

Method: POST
URL: https://api.openai.com/v1/chat/completions
Headers: Authorization: Bearer {{ $secret.OPENAI_API_KEY }} Content-Type: application/json
Body (raw JSON):
{ "model": "GPT-4.1", "messages": [ { "role": "system", "content": "You are an email copywriter. Transform the given blog post into a compelling email for SaaS founders. Tone: direct and practical. Length: 150 words." }, { "role": "user", "content": "Blog post:\n\n{{ $node.CMS_Trigger.json.post_content }}" } ], "temperature": 0.7, "max_tokens": 300
}

Creating audience-specific variants:

After the initial email is generated, n8n branches the workflow using a Merge node set to "Round-robin" mode. Each branch calls Claude Opus 4.6 (via Anthropic's API) with different instructions: Branch 1: "Rewrite this email for product managers. Focus on time savings and team collaboration." Branch 2: "Rewrite this email for marketing directors. Focus on lead generation metrics and ROI." Branch 3: "Rewrite this email for engineers. Focus on technical depth and implementation details." Each Claude call uses the same core email from the first step but with segment-specific prompts:

bash
curl https://api.anthropic.com/v1/messages \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-4.6", "max_tokens": 300, "messages": [ { "role": "user", "content": "Adapt this email for product managers. Emphasise time savings and team workflows:\n\n{{ emailCopy }}" } ] }'

Assigning variants to segments:

Next, n8n queries your email platform (Mailchimp, ConvertKit, ActiveCampaign, or your custom database) to fetch subscriber segments. Then it uses a Loop node to create send tasks:

For each subscriber in segment_product_managers: - Assign variant 1 - Set tracking parameter: variant=A&segment=product_managers - Schedule send time: {{ now + 2 hours }} For each subscriber in segment_marketing_directors: - Assign variant 2 - Set tracking parameter: variant=B&segment=marketing_directors - Schedule send time: {{ now + 4 hours }} For each subscriber in segment_engineers: - Assign variant 3 - Set tracking parameter: variant=C&segment=engineers - Schedule send time: {{ now + 6 hours }}

Most email APIs support custom tracking parameters in send requests. Here's an example for Mailchimp:

bash
curl https://us1.api.mailchimp.com/3.0/campaigns \ -H "Authorization: Bearer $MAILCHIMP_API_KEY" \ -d '{ "type": "regular", "recipients": { "segment_opts": { "saved_segment_id": 123456 } }, "settings": { "subject_line": "{{ emailSubject }}", "from_name": "Your Name", "reply_to": "you@example.com", "to_name": "*|FNAME|*" }, "tracking": { "clicks": true, "opens": true, "google_analytics": "variant=A&segment=product_managers" } }'

Capturing results:

Email platforms send open and click events back via webhooks. Configure these to POST back to n8n:

json
{ "event": "open", "email": "subscriber@example.com", "timestamp": "2026-03-15T11:45:00Z", "campaign_id": "camp_12345", "tracking_params": "variant=A&segment=product_managers"
}

n8n receives these, parses the tracking_params, and writes results to a database or Google Sheet:

INSERT INTO campaign_results (email, event, variant, segment, timestamp)
VALUES ( 'subscriber@example.com', 'open', 'A', 'product_managers', '2026-03-15T11:45:00Z'
)

After 72 hours, a scheduled n8n workflow queries these results, calculates open rates and click rates by variant and segment, and stores the winning variant for next month's campaign.

The Manual Alternative

If you prefer more hands-on control, use Copy.ai or ChatGPT Writer directly in your browser to generate the base email. Copy each variant into your email platform's template editor. Manually segment your list using your platform's built-in tools. Schedule three sends with different subject lines and review results in your platform's analytics dashboard. This takes about two hours per blog post. The automated approach takes twenty minutes of initial setup, then five minutes per post after that.

Pro Tips

Rate limiting:

OpenAI and Anthropic both enforce rate limits on API calls.

If you're generating multiple variants, space the API calls by one second using n8n's Delay node to avoid hitting limits.

Token costs:

GPT-4.1 costs more per token than GPT-4.1 mini or Claude Haiku 4.5. For initial copy generation, try GPT-4.1 mini first; if quality drops, upgrade to GPT-4.1. Testing often shows mini models perform adequately for straightforward copywriting.

Error handling:

Email platform APIs fail occasionally. Wrap all send requests in an n8n Try/Catch block. On failure, store the variant and segment in a retry queue and run a scheduled workflow every hour to clear it.

Webhook security:

Always validate incoming webhooks with HMAC signatures from your CMS. n8n provides built-in HMAC verification; enable it to prevent unauthorised requests.

Database over spreadsheets:

Store segment definitions, variant history, and results in a proper database (PostgreSQL, MySQL, or even Airtable). This makes analysis and reporting much faster than querying a Google Sheet.

Cost Breakdown

ToolPlan NeededMonthly CostNotes
n8nSelf-hosted (free tier) or Cloud Pro£0–£30Self-hosted is free; Cloud Pro needed for >1000 workflow executions. Budget 5–10 executions per campaign.
OpenAI API (ChatGPT Writer)Pay-as-you-go£2–£10Depends on variant volume. GPT-4.1 mini is cheaper than GPT-4.1. ~5000 tokens per email.
Anthropic API (Claude)Pay-as-you-go£1–£5Three Claude calls per campaign (one per variant). Claude Opus 4.6 is pricier but higher quality.
Copy.aiStarter£49Flat rate; unlimited generations.
Email platform (Mailchimp, ActiveCampaign, etc.)Standard or above£20–£100+Must support API access and webhooks.
CMS webhooksBuilt-in to most£0Usually included in your existing plan.
Total,£72–£155Most cost comes from email platform, not AI.