DEV Community

Timothy Leung
Timothy Leung

Posted on

📱 WhatsApp x n8n: A First Look—A Guide to Integrating Without a Business Account

Hello, everyone! Today I’m here to show you how to easily integrate WhatsApp with n8n. The biggest advantage of this method is that you can get started without having to apply for a Meta WhatsApp Business Account!

⚠️ Strong Recommendation and Warning

Before we begin, I want to make one thing clear: this method (using an unofficial API) is not endorsed by Meta.You can experiment on your own or conduct internal testing, but under no circumstances should you use this for client projects or commercial purposes! Otherwise, your client’s phone number is highly likely to be blocked by Meta (account ban), and they won’t be able to use WhatsApp anymore.

Although you can’t use it for paid projects, it’s excellent for learning and validating automation workflows. Today, we’ll use the Evolution API and n8n to build a very simple project— the WhatsApp MessageType Identifier.

This is the first part of the series, where I’ll show you how to install and set up the Evolution API.


💡 What is the WhatsApp MessageType Identifier?

As the name suggests, its purpose is to identify the type of message sent by the other party. Currently, WhatsApp supports multiple message types, primarily including:

  • plain text
  • Image
  • Images
  • Videos
  • Location coordinates
  • Contact Information
  • Event Information
  • Voting

This Identifier is responsible for identifying the type of message received and then automatically replying with the results.


🛠️ Prerequisites

Before you begin, you’ll need an environment with Docker already installed. If you haven’t installed n8n or even Docker yet, we recommend reviewing our previous introductory tutorial first.

  • Verify that Docker is installed
  • Verify that n8n is installed (or install it later)
  • Prepare a folder to store the configuration files

📝 Deploy the Evolution API

1️⃣ Step 1: Prepare the docker-compose.xml file

Create a new docker-compose.xml file in your folder and paste the following content into it. This configuration will not only install the Evolution API but will also automatically install PostgreSQL and Redis:

docker-compose.xml

services:
 postgres:
    image: postgres:15-alpine
    container_name: postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: evolution_user
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-evolution_secret}
      POSTGRES_DB: evolution
    volumes:
      - ${MOUNT_PATH}/postgres:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    networks:
      - default

 redis:
    image: redis:alpine
    container_name: redis
    restart: unless-stopped
    command: redis-server --appendonly yes
    ports:
      - "6379:6379"
    volumes:
      - ${MOUNT_PATH}/redis:/data
    networks:
      - default

 evolution-api:
    image: evoapicloud/evolution-api:latest
    container_name: evolution-api
    restart: unless-stopped
    ports:
      - "8081:8080"
    environment:
      - SERVER_URL=http://localhost:8081
      - DOCKER_ENV=true
      - LOG_LEVEL=ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK,WEBHOOKS
      - AUTHENTICATION_TYPE=apikey
      - AUTHENTICATION_API_KEY=${EVOLUTION_API_KEY}
      # --- PostgreSQL 設定 ---
      - DATABASE_PROVIDER=postgresql
      - DATABASE_CONNECTION_URI=postgresql://evolution_user:${POSTGRES_PASSWORD:-evolution_secret}@postgres:5432/evolution?schema=public
      - DATABASE_CONNECTION_CLIENT_NAME=evolution_api
      # --- Redis 設定 ---
      - REDIS_ENABLED=true
      - REDIS_URI=redis://redis:6379
      - REDIS_PREFIX_KEY=evolution
      - CACHE_REDIS_ENABLED=true
      - CACHE_REDIS_URI=redis://redis:6379
      - CACHE_LOCAL_ENABLED=false
      - CONFIG_SESSION_PHONE_VERSION=${CONFIG_SESSION_PHONE_VERSION}
      # -------------------------
      - WEBHOOK_GLOBAL_URL=
      - WEBHOOK_GLOBAL_ENABLED=false
      - WEBHOOK_GLOBAL_EVENTS=APPLICATION_STARTUP,QRCODE_UPDATED,MESSAGES_UPSERT,MESSAGES_UPDATE,MESSAGES_DELETE,SEND_MESSAGE,CONNECTION_UPDATE,CALL_PROVIDED
      - DATABASE_SAVE_DATA_CONTACTS=false
      - DATABASE_SAVE_DATA_CHATS=false
      - DATABASE_SAVE_DATA_LABELS=false
      - DATABASE_SAVE_DATA_HISTORIC=false
      - DATABASE_SAVE_DATA_MESSAGES=false
      - DATABASE_SAVE_DATA_MESSAGE_UPDATE=false
      - WPP_LID_MODE=false
    volumes:
      - ${MOUNT_PATH}/evolution/instances:/evolution/instances
      - ${MOUNT_PATH}/evolution/store:/evolution/store
    depends_on:
      - postgres
      - redis
    networks:
      - default

networks:
  default:
    driver: bridge
Enter fullscreen mode Exit fullscreen mode

2️⃣ Step 2: Prepare the .env file and retrieve the WhatsApp version number

In the same folder, create a .env file to store passwords and settings:

.env file contents

POSTGRES_PASSWORD=<<Your preferred Postgres SQL Password>>
EVOLUTION_API_KEY=<<Your preferred Evolution API Password>>
MOUNT_PATH=<<The mounting point you preferred such as ./data>>
CONFIG_SESSION_PHONE_VERSION=2.2413.51
Enter fullscreen mode Exit fullscreen mode

🛑 Extremely Important: Regarding CONFIG_SESSION_PHONE_VERSION

You must not enter a random value here! This directly affects whether your Evolution API can use WhatsApp features. You need to find the latest version number on the WhatsApp Web version:

  1. Open your browser and enter the URL: https://web.whatsapp.com/check-update?version=1&platform=web
  2. The page will display a string of JSON data; look for the current value of currentVersion (for example, "currentVersion":"2.2413.51" ).
  3. Paste this value into the CONFIG_SESSION_PHONE_VERSION field in your .env file, and be sure to save it!
  4. Finally, make sure both files are placed in the same folder!

🚀 Starting and Configuring the Evolution API

3️⃣ Step 3: Start the Docker container

Once you’ve prepared all the files, go back to the folder where you saved the docker-compose.xml and .env files. Open Command Prompt or Terminal, navigate to that folder, and enter the following command:

bash

docker compose up -d
Enter fullscreen mode Exit fullscreen mode

4️⃣ Step 4: Log in to Evolution Manager

Once the system has started up, open your browser to test whether Port 8081 is working:

👉 URL: http://localhost:8081/manager/

If you see a screen asking for an API key, simply enter the EVOLUTION_API_KEY value you set earlier in the .env file to log in.

5️⃣ Step 5: Create a WhatsApp Instance

After successfully logging in, we need to create an instance:

  • Click the “+ Instance” button to add one

  • Name: Enter your WhatsApp Identifier
  • Channel: Select Baileys
  • Token: Leave blank / Do not change
  • Phone No: Optional
  • Click “Save” to confirm

!(attachment:3d6eb94e-9fbb-4a1c-979e-1d668fd3c9ad:image.png)

6️⃣ Step 6: Scan the QR code to link WhatsApp

After saving, you’ll see a new field called “WhatsApp Identifier.”

  • Click the circle in the top-right corner to access the settings. (Location indicated by the red square)

  • Look for "To connect, scan the QR code with your WhatsApp Web. " Next to it is a "Get QR Code" button—click it.

  • Wait a few seconds, and you should see a QR code appear. Use WhatsApp on your phone (the “Link Devices” feature) to scan it and link your account.

  • Once successful, “Connected” will appear to the right of the box—and you’re all set!

💡 Troubleshooting

If you’ve waited nearly a minute and still don’t see a QR code appear, it’s very likely that the CONFIG_SESSION_PHONE_VERSION value in the `.env ` file is incorrect or has expired.

Solution: Double-check the version number. Once you’ve confirmed it’s correct, enter `docker compose down in the Terminal to delete the container, then use docker compose up -d ` to recreate it, and repeat the setup process.

Once you’re done, you can try sending a message in the “Chat” section of the main screen. If everything works fine, continue to the next article. In the next article, I’ll explain how to set up your WhatsApp Message Identifier on n8n.

Top comments (0)