How to Use Claude Code in n8n: Step-by-Step Guide

Development

Want to supercharge your workflows with AI? 🧠 Let’s take a fun and easy ride into using Claude code in n8n. Don’t worry if you’re new to this. We’ll break it down step by step. By the end of this guide, you’ll have your own smart workflow running like magic!

TLDR: 🧾

Claude is a powerful AI you can connect to n8n using HTTP Requests. With Claude’s code capabilities, you can analyze text, answer questions, or even write code inside your automations. By using an API key and a few settings, you’ll bring Claude’s smarts directly into your no-code workflows. It’s simpler than it sounds—promise!

🚀 What is Claude and Why Use It in n8n?

Claude is an AI assistant built by Anthropic. Think of it like ChatGPT, but with a strong focus on safety and helpfulness. Developers love it for its clear instructions and thoughtful code responses.

n8n (say “n-eight-n”) is a no-code automation tool. You use it to build workflows between apps, like “When I get an email, send me a Slack message.” Now imagine tossing in Claude’s AI brain to that. Cool, right?

🧰 What You’ll Need

  • A free Claude API key from Anthropic
  • An n8n account (hosted or self-hosted)
  • Some basic understanding of how n8n nodes and workflows work

🌟 Step-by-Step Guide: How to Add Claude to n8n

Step 1: Get Your Claude API Key

Head over to Anthropic’s Claude API page. You’ll need to create an account if you haven’t already. Then get your API key from your dashboard. Keep it safe—you’ll use it soon!

Step 2: Start a New n8n Workflow

Log into your n8n dashboard. Click on “New Workflow”. Give it a name like “Claude AI Bot” or “Ask Claude Anything”. Creativity is welcome 😊

Step 3: Add a Trigger Node

This is how the workflow starts. You can choose any trigger:

  • Webhook – best for external apps
  • Schedule – run every X minutes
  • Manual – good for testing

For this guide, choose Manual so we can test easily.

Step 4: Add an HTTP Request Node

This is where the magic happens! This node will talk to Claude’s API.

  1. Click the “+” to add a new node
  2. Select “HTTP Request”
  3. Set HTTP Method to POST
  4. URL: https://api.anthropic.com/v1/messages
  5. Choose JSON as the Response Format

Step 5: Enter Headers

In the HTTP node under Headers, click “Add Header” and add these:

  • Key: Authorization
    Value: Bearer YOUR_API_KEY
  • Key: Content-Type
    Value: application/json
  • Key: anthropic-version
    Value: 2023-06-01

Don’t forget to replace YOUR_API_KEY with your real key.

Step 6: Build the Request Body

This is what you’re telling Claude.

{
  "model": "claude-3-opus-20240229",
  "max_tokens": 500,
  "messages": [
    {
      "role": "user",
      "content": "Write me a Python function that reverses a string."
    }
  ]
}

Paste this into the HTTP Request’s Body field using Raw JSON.

You can edit the prompt to anything. Try: “Summarize this article” or “Generate 5 blog post ideas”.

json laptop

Step 7: Run the Workflow!

Hit Execute Workflow and watch the response roll in. 🎉 Claude will reply, and you’ll see its message in the output panel.

Step 8: Clean Up & Use the Results

Use the Set node to extract the AI reply, or pass it into a Slack, email, or Airtable node.

Like this:

  • Claude answers a customer question
  • The answer is posted to the support Slack channel

Smart automation FTW!

💡 Bonus Tips

Tip 1: Use Variables in Prompts

You can feed dynamic data into Claude. For example:

"content": "Summarize the following:\n {{$json[\"text\"]}}"

This way, you can analyze incoming emails, form data, or JSON files.

Tip 2: Adjust Max Tokens

max_tokens controls how long the reply can be. Higher = longer. But more tokens cost more API usage. Find a balance!

Tip 3: Don’t Forget Model Names

Claude has multiple models: claude-3-opus, claude-3-sonnet, etc. Use the one that fits your task. Opus is the most powerful, Sonnet is faster and cheaper.

✨ Example Use Case

Imagine this:

  • You receive customer feedback through a Typeform
  • n8n collects the response and sends it to Claude
  • Claude summarizes sentiment and suggests improvements
  • The summary goes to a Slack channel for your support team

BOOM! You’ve just built a smart, real-time feedback analyzer 💥

🔧 Troubleshooting Tips

  • Getting a 401 error? Check if your API key is correct and starts with sk-.
  • Empty response? Double-check your prompt and max_tokens. You might need to increase them.
  • Limit reached? You may have hit the free API quota. Check your Anthropic dashboard.

🙌 You Did It!

You just connected one of the smartest AIs into your n8n stack! Whether you’re using it to write emails, code functions, or automate answers—Claude is a powerful tool when used creatively.

And now, you know how to use it like a pro.

📚 What To Explore Next?

  • Combine Claude with GPT for cross-AI automation
  • Create a chatbot using n8n Webhook + Claude
  • Use Claude to label and tag incoming emails

😎 Final Words

AI + automation is the dream team! With this guide, you just leveled up your n8n skills big time. So go build something cool—and let Claude help you do it faster.

Happy automating! 🤖✨