4 min read whatsapp-api

How to Set Up WhatsApp Cloud API and Connect It to Your CRM with n8n

A step-by-step guide to going live on Meta's free WhatsApp Cloud API and wiring two-way messages into your CRM with n8n—webhooks, message templates, and contact sync included.

A diagram showing Meta's WhatsApp Cloud API connected through n8n to a CRM with two-way message arrows

TL;DR — Meta’s WhatsApp Cloud API lets you send and receive WhatsApp messages programmatically, hosted free by Meta (you pay only per-conversation messaging fees). To connect it to your CRM, you register a number in Meta’s developer console, generate an access token, then use n8n as the middleware: one workflow sends template messages out, and a second workflow catches Meta’s webhook to log incoming replies into your CRM. Here’s the exact setup.


What you’ll need before you start

  • A Meta Business account with business verification (required to scale beyond the test limits).
  • A phone number not currently registered on a personal WhatsApp or WhatsApp Business app.
  • A Meta for Developers app (we’ll create this below).
  • A running n8n instance—self-hosted works great; see our ₹500/month VPS guide.
  • Your CRM with API access (Zoho, GoHighLevel, or similar).

Cloud API vs a BSP: The Cloud API is Meta’s own free-hosted gateway—ideal if you have a developer to wire it up. A BSP like Atharva AI adds a team inbox, template management, and support on top. We compare the trade-offs in our WhatsApp BSP Comparison. This guide uses the raw Cloud API.


Step 1: Create the Meta app and add WhatsApp

  1. Go to Meta for Developers and create a new app of type Business.
  2. In the app dashboard, add the WhatsApp product.
  3. Meta provisions a free test number immediately so you can send messages before verification.
  4. Note your Phone Number ID and WhatsApp Business Account (WABA) ID—you’ll need both for API calls.

Step 2: Generate an access token

The temporary token Meta shows you expires in 24 hours—fine for testing, not for production.

  1. Create a System User in Meta Business Settings and assign it to your app.
  2. Generate a permanent access token for that system user with the whatsapp_business_messaging and whatsapp_business_management permissions.
  3. Store the token in n8n as a credential (never hard-code it into a node).

Step 3: Send your first message from n8n

WhatsApp requires that business-initiated conversations use a pre-approved template (free-form text is only allowed inside the 24-hour customer service window).

  1. Create and submit a template in the WhatsApp Manager (e.g. a “lead_welcome” template). Wait for Meta to approve it.
  2. In n8n, add an HTTP Request node:
    • Method: POST
    • URL: https://graph.facebook.com/v21.0/<PHONE_NUMBER_ID>/messages
    • Auth: your stored Bearer token credential
    • Body (JSON):
      {
        "messaging_product": "whatsapp",
        "to": "<RECIPIENT_PHONE>",
        "type": "template",
        "template": {
          "name": "lead_welcome",
          "language": { "code": "en" }
        }
      }
  3. Execute the node. The recipient should receive the template within seconds.

This is the same outbound pattern that powers the nurture sequence in our Lead-to-Revenue Playbook.


Step 4: Catch incoming replies with a webhook

To make it two-way, Meta needs to push incoming messages to n8n.

  1. In n8n, add a Webhook node and copy its production URL.
  2. In your Meta app’s WhatsApp Configuration, set the Callback URL to that n8n webhook and define a Verify Token (any string you choose).
  3. Meta sends a one-time GET verification request—your webhook must echo back the hub.challenge value. Handle this in n8n with a small Respond to Webhook branch.
  4. Subscribe to the messages field. Now every inbound WhatsApp message hits your n8n webhook as a JSON payload.

Step 5: Sync the conversation into your CRM

With the inbound payload in hand, the final workflow mirrors our Facebook Lead Ads to CRM pattern:

  1. Parse the sender’s phone number and message text from Meta’s webhook payload.
  2. Search your CRM for a contact with that phone number.
  3. Create or update the contact, and log the message body as an activity/note on their record.
  4. Notify your sales rep in Slack or WhatsApp so a human can jump in within the 24-hour window.

Result: outbound templates go out automatically, and every reply lands in your CRM with full history—no copy-pasting.


Troubleshooting

  • Template message fails with error 132000: Your template isn’t approved yet, or the name/language code doesn’t match exactly.
  • Webhook never fires: Re-check the Verify Token and confirm you subscribed to the messages field; the callback URL must be publicly reachable over HTTPS.
  • “Re-engagement” errors on free-form text: You’re outside the 24-hour window—send an approved template to reopen the conversation.

FAQ

Is the WhatsApp Cloud API really free?

Meta hosts the Cloud API for free—you don’t pay for the infrastructure. You pay Meta’s per-conversation messaging charges, which vary by country and conversation category. There’s also a monthly allowance of free service conversations. Check Meta’s current pricing as of 2026 for your market.

Do I need a BSP if I use the Cloud API?

No—the Cloud API works standalone. You’d choose a BSP (like Atharva AI) when you want a shared team inbox, easier template management, and support without building it all in n8n yourself. See our BSP comparison.

Can I use my existing WhatsApp number?

Only if it’s not currently active on the WhatsApp consumer or Business app. You must first delete it from those apps, or use a fresh number dedicated to the API.


Sources