n8nClaude APIWhatsAppTutorial

How to Build a WhatsApp Chatbot with n8n and Claude API (Step-by-Step)

A hands-on tutorial showing exactly how to wire up n8n + Claude API + WhatsApp Business API to create an intelligent, multilingual chatbot.

Feb 22, 2026
18 min read
How to Build a WhatsApp Chatbot with n8n and Claude API (Step-by-Step)

Prerequisites

Before we start, you'll need:

  • n8n (self-hosted or cloud — cloud is easier to start)
  • Claude API key from Anthropic
  • WhatsApp Business API access (via Meta or a BSP like 360dialog)
  • Basic familiarity with webhooks and REST APIs

Step 1: Setting Up the WhatsApp Webhook in n8n

Create a new workflow in n8n and add a Webhook node as the trigger:

{
  "httpMethod": "POST",
  "path": "whatsapp-webhook",
  "responseMode": "onReceived"
}

This webhook URL is what you'll register with Meta's WhatsApp Business API as your callback URL.

Important: Meta sends a verification challenge (GET request) before activating the webhook. Add an IF node to handle both GET (verification) and POST (messages) requests.

Step 2: Connecting Claude API as the AI Brain

Add an HTTP Request node to call Claude's API:

{
  "method": "POST",
  "url": "https://api.anthropic.com/v1/messages",
  "headers": {
    "x-api-key": "{{ $credentials.claudeApiKey }}",
    "anthropic-version": "2023-06-01",
    "content-type": "application/json"
  },
  "body": {
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "system": "You are a helpful sales assistant...",
    "messages": [
      { "role": "user", "content": "{{ $json.message.text }}" }
    ]
  }
}

Step 3: Building Conversation Memory

The tricky part: WhatsApp is stateless. Each message arrives independently. You need to maintain conversation context.

In n8n, use a Redis or Postgres node to store conversation history keyed by phone number:

Key: whatsapp:{phone_number}
Value: [
  { role: "user", content: "..." },
  { role: "assistant", content: "..." }
]
TTL: 24 hours

Before each Claude API call, fetch the conversation history and append the new message.

Step 4: Adding Product Catalog Integration

Add a Function node that queries your product database based on Claude's analysis of the customer's intent:

const intent = $json.claude_response;
if (intent.includes('product_query')) {
  const products = await $getWorkflowStaticData('products');
  return { products: products.filter(p => p.category === intent.category) };
}

Step 5: Handling Multilingual Inputs

Claude handles multilingual conversation natively. The system prompt should include:

Respond in the same language the customer uses.
If they write in Darija (Moroccan Arabic), respond in Darija.
If they write in French, respond in French.
If they mix languages, respond in the dominant language.

Common Pitfalls

  1. WhatsApp 24-hour window: You can only send messages within 24h of the last customer message. After that, you need approved templates.
  2. Rate limits: Claude API has rate limits. Add a queue system for high-volume stores.
  3. Media messages: Customers send images and voice notes. Handle these gracefully (voice → Whisper API for transcription).

Full Workflow

The complete n8n workflow JSON is available on my GitHub. Import it directly into your n8n instance.


Too complex? I'll build it for you. Book a call.

Want more like this?

Get the free toolkit + occasional tips on React Native, Next.js, and AI.

No spam. Unsubscribe anytime.