# Introduction
In today's fast-paced business environment, automating repetitive tasks can save hours of manual work. Enter **n8n**, the open-source no-code workflow automation tool, and **Claude API** from Anthropic—the powerful, safe AI models known for their reasoning and context handling. By combining them, you can create sophisticated AI-orchestrated workflows like lead scoring from CRM data, personalized marketing content, or automated report generation—all without coding.
This tutorial walks you through practical setups using n8n's HTTP Request node to call the Claude API. We'll build three real-world examples tailored for business users, developers, and teams evaluating Claude for enterprise automation. Expect step-by-step instructions, JSON configs, and Claude-specific prompt tips for optimal results.
## Why Claude API + n8n?
- **Claude's Strengths**: Models like Claude 3.5 Sonnet excel at nuanced tasks (e.g., scoring leads with reasoning) thanks to their 200K token context and constitutional AI safeguards.
- **n8n's Flexibility**: 400+ nodes, self-hostable, and free for basics—beats Zapier on cost and customization.
- **No-Code Power**: Drag-and-drop Claude API calls into triggers (webhooks, schedules) and actions (Slack, Google Sheets, email).
- **Business Wins**: Reduce manual review by 80% on leads; personalize at scale; generate insights from raw data.
Keywords like *Claude API*, *n8n workflows*, and *no-code AI* make this a game-changer for *business automation* and *AI orchestration*.
## Prerequisites
- **n8n Instance**: Sign up at [n8n.io](https://n8n.io) (cloud free tier) or self-host via Docker.
- **Claude API Key**: Get one free at [console.anthropic.com](https://console.anthropic.com). Start with $5 credit.
- **Basics**: Familiarity with JSON; optional: webhook tools like ngrok for testing.
- **Models**: Use `claude-3-5-sonnet-20240620` for balance, `claude-3-opus-20240229` for complex reasoning, or `claude-3-haiku-20240307` for speed/cost.
## Setting Up the Claude API Node in n8n
n8n lacks a native Claude node (yet), but the **HTTP Request** node handles it perfectly.
1. Create a new workflow in n8n.
2. Add a **Manual Trigger** (or Webhook for production).
3. Add an **HTTP Request** node:
- Method: `POST`
- URL: `https://api.anthropic.com/v1/messages`
- Authentication: `Header Auth`
- Name: `x-api-key`
- Value: `{{ $env.CLAUDE_API_KEY }}` (set as credential or env var).
- Headers:
```json
{
"Content-Type": "application/json",
"anthropic-version": "2023-06-01"
}
```
- Body (JSON):
```json
{
"model": "claude-3-5-sonnet-20240620",
"max_tokens": 1024,
"temperature": 0.7,
"messages": [
{
"role": "user",
"content": "{{ $json.prompt }}"
}
]
}
```
Test with a simple prompt: `Explain lead scoring in one sentence.` Connect nodes, execute, and parse `{{ $json.content[0].text }}` in a downstream **Set** node.
Pro Tip: Store API key securely in n8n Credentials > Header Auth > Create new "Claude API".
## Example 1: Lead Scoring Automation
Score inbound leads (e.g., from Typeform/Google Forms) as Hot/Warm/Cold with reasons—perfect for sales teams.
**Workflow Steps**:
1. **Webhook Trigger**: Receives lead data: `name`, `company`, `budget`, `pain_points`.
2. **Set Node**: Builds prompt.
```json
{
"prompt": "Score this lead 1-10 (Hot:8-10, Warm:5-7, Cold:1-4). Provide category, score, and 2-3 action reasons.\
Lead: {{ $json.name }} at {{ $json.company }}, Budget: {{ $json.budget }}, Needs: {{ $json.pain_points }}"
}
```
3. **HTTP Request**: Claude API as above.
4. **Set Node** (Parse Response):
```json
{
"lead_id": "{{ $json.id }}",
"score": "{{ $json.content[0].text.split('Score: ')[1].split(',')[0] }}",
"category": "{{ $json.content[0].text.split('Category: ')[1].split('\
')[0] }}",
"actions": "{{ $json.content[0].text }}"
}
```
5. **IF Node**: Route Hot leads to Slack/CRM (HubSpot/Salesforce via n8n nodes), others to nurture email.
6. **Slack Node**: Notify: "Hot lead: {{ $json.name }} - Score {{ $json.score }}".
**Claude Prompt Tips**:
- Use structured output: "Respond in JSON: {\"score\": 8, \"category\": \"Hot\", \"reasons\": [...]}". Claude 3.5 parses reliably.
- Context: Feed historical leads for calibration.
**Sample Input/Output**:
Input: `{ "name": "Acme Corp CTO", "budget": "$100k+", "pain_points": "Scaling AI infra" }`
Output: `{ "score": 9, "category": "Hot", "reasons": ["High budget", "Strategic fit"] }`
Export this workflow JSON from n8n and import anywhere. Costs ~$0.01/lead.
## Example 2: Content Personalization at Scale
Generate personalized emails/newsletters from customer data—ideal for marketing.
**Workflow**:
1. **Schedule Trigger**: Daily, pull from Airtable/Google Sheets (customer segments).
2. **Google Sheets Node**: Read rows: `customer_name`, `recent_purchases`, `preferences`.
3. **Loop Over Items**: For each customer.
4. **Set Prompt**:
```json
{
"prompt": "Write a personalized email for {{ $json.customer_name }}. Recent buys: {{ $json.recent_purchases }}. Preferences: {{ $json.preferences }}. Keep under 200 words, friendly tone, include CTA for upsell. Subject: engaging. Output as JSON: {\"subject\": \"...\", \"body\": \"...\"}"
}
```
5. **Claude HTTP Request**.
6. **Code Node** (JS): Parse JSON response safely.
```javascript
const response = $input.first().json.content[0].text;
return JSON.parse(response);
```
7. **Gmail/SendGrid Node**: Send emails.
**Enhancements**:
- A/B Testing: Branch with different temperatures (0.3 conservative, 1.0 creative).
- Claude's Edge: Handles nuance like cultural prefs better than GPT.
Results: 2x open rates reported in similar setups.
## Example 3: Automated Report Generation
Turn raw data (sales CSV) into executive summaries—great for HR/Marketing/Sales playbooks.
**Workflow**:
1. **Google Drive Trigger**: New CSV upload.
2. **Spreadsheet File Node**: Read/parse CSV to JSON array.
3. **Aggregate Node**: Summarize data (totals, trends).
4. **Set Prompt**:
```json
{
"prompt": "Analyze this sales data: {{ JSON.stringify($json) }}. Generate a 500-word report with: executive summary, key metrics (table), insights, recommendations. Use bullet points and markdown."
}
```
5. **Claude API**: `max_tokens: 2000`, `model: claude-3-opus-20240229` for depth.
6. **Google Docs/Slack Node**: Post formatted report.
**Sample Prompt Output** (Markdown):
```
## Q3 Sales Report
**Summary**: Revenue up 15%...
| Metric | Value |
|--------|-------|
| Total | $1.2M |
Insights: ...
```
Handle large CSVs by chunking with n8n's Split In Batches.
## Best Practices & Advanced Tips
- **Prompt Engineering for Claude**:
- XML tags: `<lead_data>{{data}}</lead_data><instructions>Score...</instructions>`
- Chain-of-thought: "Think step-by-step before scoring."
- Tool Use: For API agents, add `tools` array (see Anthropic docs).
- **Error Handling**: Wrap HTTP in **IF** for 429s (retry with Wait node).
- **Streaming**: Set `stream: true`, parse SSE in Code node for real-time UIs.
- **Cost Optimization**: Haiku for simple tasks ($0.25/M input); monitor via Anthropic dashboard.
- **Security**: Self-host n8n; use env vars; Claude's safeguards block harmful prompts.
- **Scaling**: Deploy to n8n cloud; integrate MCP servers for extended tools.
- **Comparisons**: Claude > GPT-4o on reasoning (benchmarks); n8n > Zapier on privacy.
## Conclusion
Claude API + n8n unlocks *no-code AI orchestration* for real *business automation*. From lead scoring to reports, these workflows solve pain points scalably. Fork our examples, tweak prompts, and iterate—Claude's reliability shines in production.
Stay tuned for Claude Code integrations and agent tutorials. Questions? Comment below or hit the n8n forum.
*Word count: ~1450*