HomeFeaturesPricingAboutContact
๐Ÿ’ฌ INTEGRATION GUIDE

WhatsApp Business API
Integration Guide

Complete step-by-step guide to connect your WhatsApp Business number with LeadSoras CRM through Meta Business Platform and start sending messages to your leads.

๐Ÿ“‹ Overview

LeadSoras CRM integrates with WhatsApp Business through the Evolution API โ€” an open-source gateway that connects to WhatsApp Web (via the Baileys library) or the official Meta WhatsApp Business API. This guide covers both approaches:

  • Option A โ€” QR Code (WhatsApp Web): Quick setup using QR code scanning. Best for small teams (up to ~1,000 messages/day). No Meta Business verification required.
  • Option B โ€” Meta Business API (Official): Full enterprise integration through Meta's Cloud API. Supports high-volume messaging, verified business profiles, and message templates. Requires Meta Business verification.
๐Ÿ’ก
Recommendation: If you need to send fewer than 1,000 messages/day and want the fastest setup, use Option A (QR Code). For high-volume, production-grade messaging with delivery receipts and verified sender profiles, use Option B (Meta Business API).

Architecture Diagram

System Architecture
LeadSoras CRMโ†’ API โ†’Evolution APIโ†’ WebSocket โ†’WhatsApp
Messages โ†’ Queue โ†’ Scheduler โ†’ Evolution API โ†’ WhatsApp Delivery

โœ… Prerequisites

Before starting, make sure you have the following:

1

Active LeadSoras CRM Account

You need an active CRM subscription with Admin privileges to configure WhatsApp settings.

2

Dedicated WhatsApp Phone Number

A phone number that is NOT currently registered on WhatsApp Personal or WhatsApp Business app. If the number is already on WhatsApp, you must deregister it first.

3

Server or VPS (for Evolution API)

A Linux server (Ubuntu 20.04+ recommended) with Docker installed, or a cloud service like Railway, Render, or DigitalOcean. Minimum: 1 vCPU, 1GB RAM, 10GB disk.

4

Meta Business Account (for Option B only)

A verified Meta Business Suite account at business.facebook.com.

๐Ÿข Step 1 โ€” Create a Meta Business Account

โ„น๏ธ
Skip this step if you are using Option A (QR Code) connection method. This section is only required for the official Meta WhatsApp Business API.

A Meta Business Account is required to access the WhatsApp Business API. Follow these steps:

1

Go to Meta Business Suite

Visit business.facebook.com and click "Create Account".

2

Enter Business Details

Fill in your business name, your name, and business email address. Click "Submit".

3

Verify Your Email

Check your email inbox for a verification message from Meta. Click the verification link to confirm.

4

Complete Business Information

Navigate to Settings โ†’ Business Info and fill in:

  • Legal business name
  • Business address
  • Business phone number
  • Website URL
  • Business category
5

Business Verification (Recommended)

For higher messaging limits and a verified badge, complete business verification:

  1. Go to Settings โ†’ Security Center โ†’ Start Verification
  2. Upload required documents (business registration, utility bill, etc.)
  3. Wait for Meta to review (usually 2-7 business days)
โš ๏ธ
Important: Without business verification, you are limited to 250 business-initiated conversations per 24 hours. After verification, this increases to 1,000 and then up to unlimited based on your quality rating.

๐Ÿ“ฑ Step 2 โ€” Create a Meta App

โ„น๏ธ
Skip this step if using Option A (QR Code).
1

Go to Meta for Developers

Visit developers.facebook.com and log in with your Facebook account linked to your Business Account.

2

Create a New App

Click "My Apps" โ†’ "Create App".

  • Select "Other" as the use case
  • Choose "Business" as the app type
  • Enter app name (e.g., "LeadSoras CRM WhatsApp")
  • Select your Meta Business Account
  • Click "Create App"
3

Note Your App Credentials

After creation, go to Settings โ†’ Basic and note down:

  • App ID โ€” You'll need this for API calls
  • App Secret โ€” Keep this secure, never expose in frontend code
๐Ÿšจ
Security: Never share or commit your App Secret to version control. Store it in environment variables only.

๐Ÿ’ฌ Step 3 โ€” Add WhatsApp Product

โ„น๏ธ
Skip this step if using Option A (QR Code).
1

Add WhatsApp to Your App

In your app dashboard, scroll down to "Add Products to Your App", find WhatsApp, and click "Set Up".

2

Select Your Business Account

Choose the Meta Business Account you created in Step 1. Click "Continue".

3

Review API Setup

You'll be taken to the WhatsApp โ†’ API Setup page. Here you'll see:

  • Temporary Access Token โ€” Valid for 24 hours (for testing only)
  • Phone Number ID โ€” Identifies your WhatsApp sender
  • WhatsApp Business Account ID โ€” Your WABA ID
๐Ÿ’ก
Testing: Meta provides a test phone number you can use immediately. To use your own number, proceed to the next step.

๐Ÿ“ž Step 4 โ€” Register Your Phone Number

For Option A (QR Code โ€” WhatsApp Web)

No registration needed. You'll simply scan a QR code with your WhatsApp phone. The number can be your existing personal or business WhatsApp number.

โš ๏ธ
Note: When using QR Code mode, your WhatsApp Web session on your phone will disconnect from any other WhatsApp Web instances. Only one Evolution API instance can be connected per phone number.

For Option B (Meta Business API)

1

Add a Phone Number

In the WhatsApp โ†’ API Setup page, click "Add Phone Number".

  • Enter a display name for your business
  • Select a category
  • Enter the phone number you want to use
2

Verify the Phone Number

Choose verification method:

  • SMS โ€” Receive a 6-digit code via SMS
  • Voice Call โ€” Receive a phone call with the code

Enter the verification code and click "Verify".

3

Configure Business Profile

After verification, set up your business profile:

  • Profile picture (logo)
  • Business description
  • Business address
  • Business email
  • Website URL
๐Ÿšจ
Critical: The phone number you register must NOT be active on WhatsApp Personal or WhatsApp Business App. If it is, you must delete your WhatsApp account first from the phone before registering it with the API. Once registered with the API, you cannot use the number on the mobile WhatsApp apps.

๐Ÿ”‘ Step 5 โ€” Generate Permanent Access Token

โ„น๏ธ
Skip this step if using Option A (QR Code).

The temporary token from the API Setup page expires in 24 hours. For production use, you need a permanent (System User) access token.

1

Create a System User

Go to Meta Business Settings โ†’ System Users.

  • Click "Add"
  • Name: e.g., "CRM WhatsApp Bot"
  • Role: Admin
  • Click "Create System User"
2

Assign Assets

Click "Add Assets" next to your system user:

  • Select "Apps" tab
  • Find your WhatsApp app โ†’ toggle "Full Control"
  • Select "WhatsApp Accounts" tab
  • Find your WABA โ†’ toggle "Full Control"
  • Click "Save Changes"
3

Generate Token

Click "Generate New Token" for your system user:

  • Select your WhatsApp app
  • Enable these permissions:
    • whatsapp_business_management
    • whatsapp_business_messaging
  • Click "Generate Token"
  • Copy and save the token immediately โ€” it won't be shown again!
๐Ÿšจ
Save this token securely! This is your permanent access token. Store it as an environment variable (META_PERMANENT_ACCESS_TOKEN) on your server. Never expose it in client-side code.
env
# Add to your backend .env file
META_PERMANENT_ACCESS_TOKEN=EAAxxxxxxxxxxxxxxxxxxxxxxx

๐Ÿš€ Step 6 โ€” Install Evolution API

Evolution API is the middleware that connects LeadSoras CRM to WhatsApp. It handles session management, message queuing, and webhook delivery.

Option 1 โ€” Docker (Recommended)

bash
# Pull the latest Evolution API image
docker pull atendai/evolution-api:latest

# Create and run the container
docker run -d \
  --name evolution-api \
  -p 8080:8080 \
  -e AUTHENTICATION_API_KEY=YOUR_EVOLUTION_API_KEY \
  -e SERVER_URL=https://your-domain.com \
  -v evolution_data:/evolution/instances \
  atendai/evolution-api:latest

Option 2 โ€” Docker Compose

Create a docker-compose.yml file:

yaml
version: '3.8'

services:
  evolution-api:
    image: atendai/evolution-api:latest
    container_name: evolution-api
    restart: always
    ports:
      - "8080:8080"
    environment:
      # Authentication
      - AUTHENTICATION_API_KEY=YOUR_SECURE_API_KEY_HERE
      # Server
      - SERVER_URL=https://your-domain.com
      - SERVER_PORT=8080
      # Database (optional - for persistence)
      - DATABASE_ENABLED=true
      - DATABASE_PROVIDER=postgresql
      - DATABASE_CONNECTION_URI=postgresql://user:pass@host:5432/evolution
      # Webhook (for CRM integration)
      - WEBHOOK_GLOBAL_ENABLED=true
      - WEBHOOK_GLOBAL_URL=https://your-crm-backend.com/api/webhooks/evolution
      - WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=true
      - WEBHOOK_EVENTS_MESSAGES_UPSERT=true
      - WEBHOOK_EVENTS_MESSAGES_UPDATE=true
      - WEBHOOK_EVENTS_CONNECTION_UPDATE=true
    volumes:
      - evolution_data:/evolution/instances

volumes:
  evolution_data:

Then run:

bash
docker compose up -d

Option 3 โ€” Railway / Cloud Deployment

1

Deploy on Railway

Click the button below or go to railway.app:

  1. Create a new project โ†’ "Deploy from Docker Image"
  2. Image: atendai/evolution-api:latest
  3. Set environment variables (same as Docker section above)
  4. Deploy and note the public URL provided by Railway
๐Ÿ’ก
Using ngrok for local development: If you're running Evolution API locally, you can expose it using ngrok:
bash
ngrok http 8080
Use the ngrok HTTPS URL as your Evolution API URL in the CRM settings.

โš™๏ธ Step 7 โ€” Configure Evolution API

Create a WhatsApp Instance

After deploying Evolution API, create an instance to connect your WhatsApp number:

bash
curl -X POST 'https://your-evolution-api.com/instance/create' \
  -H 'apikey: YOUR_EVOLUTION_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "instanceName": "LeadSoras",
    "integration": "WHATSAPP-BAILEYS",
    "qrcode": true,
    "webhook": {
      "url": "https://your-crm-backend.com/api/webhooks/evolution",
      "byEvents": true,
      "events": [
        "MESSAGES_UPSERT",
        "MESSAGES_UPDATE",
        "CONNECTION_UPDATE"
      ]
    }
  }'

Verify the Instance

bash
curl -X GET 'https://your-evolution-api.com/instance/connectionState/LeadSoras' \
  -H 'apikey: YOUR_EVOLUTION_API_KEY'

Expected response:

json
{
  "instance": {
    "instanceName": "LeadSoras",
    "state": "open"
  }
}

Environment Variables Reference

VariableDescriptionExample
AUTHENTICATION_API_KEYMaster API key for Evolution API authenticationmy_secure_key_2026
SERVER_URLPublic URL where Evolution API is hostedhttps://evo.example.com
WEBHOOK_GLOBAL_URLURL to receive WhatsApp events (your CRM backend)https://api.example.com/api/webhooks/evolution
DATABASE_CONNECTION_URIPostgreSQL connection string for persistencepostgresql://user:pass@host:5432/db

๐Ÿ”— Step 8 โ€” Connect Evolution API to LeadSoras CRM

Option A: Configure via CRM Dashboard (Recommended)

1

Navigate to WhatsApp Settings

In your CRM dashboard, go to WhatsApp โ†’ Settings (or click the โš™๏ธ icon from the WhatsApp page).

2

Enter Connection Details

Fill in the following fields:

  • Evolution API URL: The public URL of your Evolution API instance (e.g., https://your-evolution-api.com)
  • API Key: The AUTHENTICATION_API_KEY you set during Evolution API setup
  • Instance Name: The name you gave when creating the instance (e.g., LeadSoras)
3

Test the Connection

Click the "๐Ÿ”Œ Test Connection" button. If successful, you'll see a green "Connected" status indicator.

4

Save Settings

Click "๐Ÿ’พ Save Settings" to persist your configuration.

Option B: Configure via Environment Variables

You can also configure the connection through your backend .env file:

env
# WhatsApp (Evolution API) Configuration
EVOLUTION_API_URL=https://your-evolution-api.com
EVOLUTION_API_KEY=YOUR_EVOLUTION_API_KEY
EVOLUTION_INSTANCE_NAME=LeadSoras
๐Ÿ’ก
Priority Order: The CRM uses this priority for connection settings:
  1. Database settings (configured via Dashboard)
  2. Environment variables (.env file)
  3. Default fallbacks
Dashboard settings always override environment variables.

๐Ÿช Step 9 โ€” Configure Webhooks

Webhooks allow the CRM to receive real-time updates from WhatsApp โ€” including incoming messages, delivery receipts, and connection status changes.

CRM Webhook Endpoint

Your LeadSoras CRM backend exposes the following webhook endpoint:

text
POST https://your-crm-backend.com/api/webhooks/evolution

Configure in Evolution API

You can set the webhook URL either during instance creation (Step 7) or update it after:

bash
curl -X PUT 'https://your-evolution-api.com/webhook/set/LeadSoras' \
  -H 'apikey: YOUR_EVOLUTION_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://your-crm-backend.com/api/webhooks/evolution",
    "enabled": true,
    "webhookByEvents": true,
    "events": [
      "MESSAGES_UPSERT",
      "MESSAGES_UPDATE",
      "CONNECTION_UPDATE",
      "SEND_MESSAGE"
    ]
  }'

Webhook Events Handled by CRM

EventDescriptionCRM Action
MESSAGES_UPSERTNew message received from a contactSaves inbound message to lead's chat history
MESSAGES_UPDATEMessage status update (delivered, read)Updates message delivery/read status in CRM
CONNECTION_UPDATEWhatsApp connection state changedUpdates connection status indicator
SEND_MESSAGEConfirmation of sent messageUpdates outbound message status

For Meta Business API โ€” Facebook Webhook (Lead Ads)

If you're also using Facebook Lead Ads integration, configure the Facebook webhook separately:

1

Set Up Facebook Webhook

In your Meta App Dashboard โ†’ WhatsApp โ†’ Configuration:

  • Callback URL: https://your-crm-backend.com/api/webhooks/facebook
  • Verify Token: Your webhook secret (set in CRM Settings โ†’ General โ†’ Webhook Secret)
2

Subscribe to Events

Subscribe to the following webhook fields:

  • messages โ€” Incoming messages
  • message_deliveries โ€” Delivery status
  • message_reads โ€” Read receipts
  • leadgen โ€” Lead form submissions (for Facebook Lead Ads)
โ„น๏ธ
Webhook Secret: You can configure your webhook verification token in the CRM at Dashboard โ†’ Settings โ†’ General Settings โ†’ Webhook Secret. Default: prodiet_webhook_secret

๐Ÿ“ฑ Step 10 โ€” Connect via QR Code

โœ…
This is the fastest way to start! If you chose Option A (QR Code), this is your primary connection method.
1

Open WhatsApp Settings in CRM

Navigate to Dashboard โ†’ WhatsApp โ†’ Settings in your CRM.

2

Click 'Show QR Code'

Click the "๐Ÿ“ฑ Show QR Code" button. A QR code will appear on screen.

3

Scan with Your Phone

On your phone:

  1. Open WhatsApp on your mobile device
  2. Tap Settings โ†’ Linked Devices โ†’ Link a Device
  3. Point your camera at the QR code displayed in the CRM
  4. Wait for the connection to establish (usually 5-10 seconds)
4

Verify Connection

After scanning, click "๐Ÿ”Œ Test Connection" to confirm. The status should show Connected with a green indicator.

โš ๏ธ
Keep your phone online! The QR Code method requires your phone to maintain an internet connection. If your phone goes offline for extended periods, the session may disconnect and you'll need to re-scan.

โœ‰๏ธ Sending Messages

Once connected, you can send WhatsApp messages to your leads directly from the CRM.

From the Lead Chat

1

Open a Lead

Navigate to Dashboard โ†’ Leads and click on any lead to open their profile.

2

Send a Message

In the lead's chat section, type your message and click Send via WhatsApp. The message will be queued and sent through your connected WhatsApp number.

Via the WhatsApp Dashboard

Navigate to Dashboard โ†’ WhatsApp to access the dedicated messaging interface where you can:

  • Send individual messages to any phone number
  • View message history and delivery status
  • Monitor sending queue and statistics
  • Pause/resume message sending
  • Retry failed messages

Via API (Programmatic)

bash
curl -X POST 'https://your-crm-backend.com/api/whatsapp/send' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "phoneNumber": "201234567890",
    "messageText": "Hello! This is a test message from LeadSoras CRM.",
    "leadId": "optional-lead-uuid"
  }'

Message Queue System

Messages are not sent immediately โ€” they go through an intelligent queuing system:

SettingDefaultDescription
Delay Between Messages5 secondsWait time between each sent message
Batch Size50 messagesNumber of messages per batch before pausing
Pause Duration1 hourCooldown period after a batch completes
Max Retries3Retry count for failed messages
Processing Interval30 secondsHow often the scheduler checks for pending messages
๐Ÿ’ก
Configure these settings at Dashboard โ†’ WhatsApp โ†’ Settings โ†’ Sending Settings. Adjust the delay and batch size based on your messaging volume and WhatsApp's rate limits.

๐Ÿ“จ Bulk Messaging

1

Navigate to Bulk Messaging

Go to Dashboard โ†’ WhatsApp โ†’ Bulk Send.

2

Select Recipients

Choose your recipients:

  • From CRM leads: Select leads by status, source, or individually
  • Manual numbers: Enter phone numbers directly (one per line)
3

Compose Message

Write your message or select a pre-built template. You can use variables like{{ name }} and {{ phone }} for personalization.

4

Send

Click "Send Bulk Messages". Messages will be queued and sent according to your configured batch settings to avoid WhatsApp rate limiting and account bans.

โš ๏ธ
Anti-Spam Warning: Sending too many messages too quickly can result in your WhatsApp number being temporarily or permanently banned. Always use reasonable delays (5+ seconds) and avoid sending unsolicited messages.

๐Ÿ“ Message Templates

Templates allow you to create reusable message formats with dynamic variables. Manage templates at Dashboard โ†’ WhatsApp โ†’ Templates.

Creating a Template

1

Click 'Create Template'

Enter a template name and compose your message body. Use double curly braces for variables:

text
Hello {{ name }}! ๐Ÿ‘‹

Thank you for your interest in our services.
Your inquiry #{{ phone }} has been received.

Our team will contact you within 24 hours.

Best regards,
LeadSoras Team

Available Variables

VariableDescriptionExample Output
{{ name }}Lead's full nameAhmed Mohamed
{{ phone }}Lead's phone number+201234567890
Custom variablesAny key you pass in templateVarsDepends on your data
โ„น๏ธ
Meta Business API Templates: If you're using the official Meta API (Option B), you must also register your message templates through the Meta Business Manager for approval before they can be used for business-initiated conversations.

๐Ÿ”ง Troubleshooting

Connection Issues

ProblemCauseSolution
"Disconnected" statusQR session expired or phone offlineRe-scan the QR code; ensure phone has internet
QR code not loadingEvolution API is unreachableCheck if Evolution API is running; verify the URL and API key
"Instance not found"Instance wasn't created or name mismatchCreate a new instance or verify the instance name matches CRM settings
Connection test failsNetwork/firewall blocking requestsEnsure your CRM backend can reach the Evolution API URL; check CORS settings

Message Sending Issues

ProblemCauseSolution
Messages stuck in "pending"Scheduler paused or WhatsApp disconnectedCheck connection status; resume sending in WhatsApp dashboard
Messages failing repeatedlyInvalid phone number formatEnsure numbers include country code without + (e.g., 201234567890)
WhatsApp number bannedToo many messages or spam reportsIncrease delay between messages; reduce bulk volume; wait 24-72 hours
Webhooks not receivedWebhook URL misconfiguredVerify webhook URL in Evolution API; check server logs for incoming requests

Checking Logs

bash
# Check Evolution API logs
docker logs evolution-api --tail 100 -f

# Check CRM backend logs (Railway)
# Go to Railway dashboard โ†’ your service โ†’ Logs tab

# Check CRM backend logs (local)
# Look at terminal output or check console logs

โ“ Frequently Asked Questions

Can I use my personal WhatsApp number?

Option A (QR Code): Yes, you can use your personal WhatsApp number. Your phone acts as the sender.
Option B (Meta API): No, the number must be exclusively registered with the Business API and cannot have WhatsApp installed on the phone.

How many messages can I send per day?

Option A: WhatsApp doesn't publish official limits for personal accounts, but sending more than ~1,000 messages/day risks temporary bans. Use reasonable delays.
Option B: Depends on your tier โ€” starts at 250/day (unverified), then 1,000, 10,000, 100,000, and unlimited after Meta verification.

Is this integration free?

Evolution API is open-source and free. Meta's WhatsApp Business API charges per conversation (currently first 1,000 service conversations per month are free). Server hosting costs depend on your provider.

Can I send images, videos, and documents?

Yes! The CRM supports sending media messages including images, videos, and documents via WhatsApp. Use the media upload feature when composing messages, or pass mediaUrl and mediaType via the API.

Will incoming messages appear in the CRM?

Yes! When a lead replies to your WhatsApp message, the reply is automatically captured via webhooks and saved in the lead's chat history. The CRM matches incoming messages to leads based on phone number.

Can multiple team members use the same WhatsApp connection?

Yes. The WhatsApp connection is shared at the organization level. All CRM users with WhatsApp permissions can send and view messages through the same connected number.

What happens if my phone disconnects (QR Code mode)?

Pending messages will queue up and be sent once the connection is re-established. If the session fully expires, you'll need to re-scan the QR code from the WhatsApp Settings page.


Need help? Contact our support team.