How to Build an AI-Powered Email Sequence Generator Using Claude API and n8n
This article mentions a tool I use; the link at the end is an affiliate link.
Email sequences remain one of the most profitable digital products to sell in 2026. But creating personalized, high-converting sequences manually takes hours. In this tutorial, I'll show you how to build an automated email sequence generator that uses Claude AI to create customized sequences based on user input—no coding required beyond basic JSON.
What You'll Build
A workflow that:
- Accepts user input (niche, product type, audience)
- Generates a 5-email welcome sequence using Claude API
- Formats the output as a downloadable document
- Can be packaged as a paid tool or lead magnet
Prerequisites
- n8n account (self-hosted or cloud, free tier works)
- Anthropic API key (Claude)
- Basic understanding of workflow automation
- 2-3 hours to set up and test
Step 1: Set Up Your n8n Workflow
n8n is an open-source automation platform that connects APIs without writing full applications.
- Create a new workflow in n8n
- Add a Webhook node as your trigger
- Set it to POST method
- Copy the webhook URL—this becomes your tool's endpoint
Your webhook should accept JSON with these fields:
{
"niche": "fitness coaching",
"product": "online course",
"audience": "busy professionals",
"tone": "friendly and motivating"
}
Step 2: Configure Claude API Integration
Add an HTTP Request node after your webhook:
- Method: POST
- URL:
https://api.anthropic.com/v1/messages - Authentication: Add header
x-api-keywith your Anthropic API key - Add header
anthropic-version: 2023-06-01 - Add header
content-type: application/json
In the body, use this structure:
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 2500,
"messages": [{
"role": "user",
"content": "Create a 5-email welcome sequence for {{$json.niche}} selling {{$json.product}} to {{$json.audience}}. Use a {{$json.tone}} tone. Format each email with Subject:, Body:, and Purpose: labels. Make emails 150-200 words each."
}]
}
The double curly braces pull data from your webhook input.
Step 3: Parse and Format the Output
Claude returns text in a specific JSON structure. Add a Code node with this JavaScript:
const response = $input.first().json;
const emailContent = response.content[0].text;
// Split into individual emails
const emails = emailContent.split(/Email \d:/).filter(e => e.trim());
const formatted = emails.map((email, index) => {
const subjectMatch = email.match(/Subject:(.*?)(?=Body:|$)/s);
const bodyMatch = email.match(/Body:(.*?)(?=Purpose:|$)/s);
return {
number: index + 1,
subject: subjectMatch ? subjectMatch[1].trim() : '',
body: bodyMatch ? bodyMatch[1].trim() : '',
raw: email.trim()
};
});
return [{ json: { emails: formatted, fullText: emailContent } }];
This extracts each email into a structured format you can work with.
Step 4: Create a Downloadable Output
Add a Code node to format as markdown:
const data = $input.first().json;
let markdown = '# Your Custom Email Sequence\n\n';
data.emails.forEach(email => {
markdown += `## Email ${email.number}\n\n`;
markdown += `**Subject:** ${email.subject}\n\n`;
markdown += `${email.body}\n\n`;
markdown += '---\n\n';
});
return [{ json: { markdown }, binary: { data: Buffer.from(markdown) } }];
Add a final Respond to Webhook node that returns the markdown or saves it to Google Docs/Notion.
Step 5: Test Your Generator
Use a tool like Postman or curl to test:
curl -X POST your-webhook-url \
-H "Content-Type: application/json" \
-d '{
"niche": "productivity coaching",
"product": "membership site",
"audience": "entrepreneurs",
"tone": "authoritative but warm"
}'
You should receive a formatted email sequence in seconds.
Monetization Options
- Sell API access: Charge $9-29/month for unlimited generations
- One-time purchases: $47-97 for a Notion template + 50 generations
- White-label: Package for agencies at $297-497
- Lead magnet: Offer 1 free sequence, upsell to templates
Improving Your Tool
When I was building out the marketing funnel for a similar tool, I used Perpetual Income 365 to handle the email automation and upsell sequences, which saved me from building that entire system from scratch. It's particularly useful if you're not familiar with setting up complex email funnels.
Beyond that, consider:
- Adding industry-specific templates to your prompts
- Integrating with Stripe for payments
- Creating a simple frontend with Typeform or Fillout
- Offering A/B tested subject line variations
Cost Breakdown
- n8n: Free (self-hosted) or $20/month (cloud)
- Claude API: ~$0.50 per sequence generation (2500 tokens)
- Hosting (if needed): $5-10/month
At $19/month subscription with 20 customers, you're profitable after month one.
Next Steps
- Build the basic workflow this week
- Generate 10 test sequences in different niches
- Create a simple landing page
- Share in communities like Indie Hackers for feedback
- Iterate based on user requests
The key is starting with a working tool that solves a real problem. You can always add features later based on what users actually need, not what you think they want.
This approach works because it combines genuine AI capabilities with a proven need (email marketing) and packages it in a way that saves people time. No hype needed—just a tool that works.
The tool mentioned above is an affiliate link (disclosed at top): Perpetual Income 365
Top comments (0)