Automate WhatsApp Easily with n8n and AI Agents

A step-by-step guide to setting up n8n and Docker for limitless WhatsApp automation

By Kayhan Kaptan - Medical Physics, Quality Control, Data Science and Automation

Many believe that automating WhatsApp is reserved for experts, requiring expensive WhatsApp Business accounts, often leading to blocks after a limited number of automated messages. However, there’s a simple, free, and unlimited method to connect your WhatsApp to an AI agent using n8n and Docker. This guide provides a step-by-step procedure to set up this powerful automation.

Why Automate WhatsApp with n8n and AI?

This method offers several advantages:

  • Free and Unlimited: Unlike many other solutions, this setup allows for extensive automation without recurring costs or message limits.
  • AI Integration: Seamlessly connect an AI agent to handle responses, making your WhatsApp interactions intelligent and automated.
  • Accessibility: No need for complex coding or deep technical expertise. The process is streamlined for common users.
  • Versatile: Applicable for personal use, business operations, or offering automation solutions to clients.

Step-by-Step Setup Guide

This guide assumes you have access to a computer (Windows, macOS, or Linux) and an internet connection.

Step 1: Install Docker

Docker is a platform that uses containerization technology, allowing you to run applications in isolated environments. This is crucial for running n8n and the WhatsApp automation module seamlessly.

  1. Download Docker Desktop: Visit the official Docker website and download the appropriate version for your operating system.
  2. Install Docker: Follow the installation prompts. For Windows, ensure WSL 2 (Windows Subsystem for Linux 2) is enabled for optimal performance.
  3. Launch Docker Desktop: Once installed, open the Docker Desktop application. You should see the Docker engine running.

Step 2: Download the Docker Compose File

A Docker Compose file (docker-compose.yml) defines how Docker containers should be configured and run. This specific file will set up n8n and the WhatsApp automation environment.

  1. Access the file: The Docker Compose file is typically hosted on a platform like GitHub. Navigate to the provided link (usually found in the accompanying tutorial resources) to locate docker-compose.yml.
  2. Download the file: Click on the docker-compose.yml file and then select the option to download the raw file.

Step 3: Create a Dedicated Folder and Place the Docker Compose File

Organizing your files helps maintain a clean setup.

  1. Create a new folder: On your computer, create a new folder specifically for this project (e.g., n8n-WhatsApp).
  2. Move the downloaded file: Place the docker-compose.yml file you just downloaded into this new folder.

Step 4: Run Docker Compose from the Terminal

Now, you’ll use Docker to build and run the specified services.

  1. Open Docker Desktop Terminal: Within Docker Desktop, locate and click on the “Terminal” icon (usually at the bottom left).
  2. Navigate to your folder:
    • Type cd (note the space after cd).
    • Copy the full path to your n8n-WhatsApp folder.
    • Paste the path into the terminal and press Enter.
    • To verify you are in the correct directory, type ls (for Linux/macOS) or dir (for Windows) to list its contents. You should see docker-compose.yml.
  3. Execute Docker Compose: Copy the provided command (e.g., docker compose up -d) and paste it into the terminal. Press Enter. This command will download all necessary components (n8n, the WhatsApp Automation module, etc.) and start them as Docker containers. This process may take a few minutes depending on your internet connection.

Step 5: Verify Container Status in Docker Desktop

After the components are downloaded and started, you can verify their status.

  1. Check Containers: In Docker Desktop, click on “Containers” (usually in the top left).
  2. Locate n8n-WhatsApp: You should see a new entry named n8n-WhatsApp.
  3. Expand and Verify: Click on the n8n-WhatsApp entry to expand it. You should see multiple services running, including n8n and waa (WhatsApp Automation). Ensure all services are running and show a green status indicator. If not, click the “Play” button to start them.

Step 6: Configure the WhatsApp Automation Module (WAA)

The WAA module is the bridge between your WhatsApp and n8n.

  1. Access WAA Dashboard: In Docker Desktop, locate the waa service within your n8n-WhatsApp deployment. Look for the “Port” column (e.g., 3000:3000). Click on the first port number. This will open the WAA dashboard in your web browser.
  2. Start Default Session: On the WAA dashboard, click on “Dashboard” and then locate the “default” session. Click the button to start this session.
  3. Generate QR Code for WhatsApp Linking: Click on the “Login” button. A QR code will appear.

This step connects your physical WhatsApp number to the automated ecosystem.

  1. On your phone (WhatsApp app):
    • Go to “Settings” (or “Linked Devices” directly, depending on your WhatsApp version).
    • Select “Linked Devices.”
    • Tap “Link a Device.”
    • Your phone’s camera will activate.
  2. Scan the QR Code: Use your phone to scan the QR code displayed on your computer screen from the WAA dashboard.
  3. Connection Confirmation: Once scanned, the WAA dashboard will show “Working…” and then “Connected,” indicating your WhatsApp number is now linked.

Step 8: Access and Configure n8n

n8n is the workflow automation tool where you’ll build your AI-powered WhatsApp responses.

  1. Access n8n Dashboard: In Docker Desktop, locate the n8n service within your n8n-WhatsApp deployment. Look for the “Port” column (e.g., 5678:5678). Click on the first port number. This will open the n8n interface in your web browser.
  2. Initial Setup (First Time User): If this is your first time opening n8n, you’ll be prompted to create an account. Enter your name, email, and a password, then sign up.
  3. Install the Unofficial WAA Node: This is crucial for n8n to communicate with your WhatsApp automation.
    • In n8n, go to “Settings” (bottom left).
    • Click on “Community Nodes.”
    • Click “Install,” then paste n8n-nodes-waa into the package name field.
    • Check the “Install pre-release nodes” box and click “Install.” This will add the necessary WAA integration node to n8n.

Step 9: Create Your n8n WhatsApp Workflow

This involves setting up the logic for how n8n receives and responds to WhatsApp messages.

  1. Create a New Workflow: In n8n, click “New” to create a fresh workflow.
  2. Add a Webhook Node:
    • Search for “Webhook” and drag it onto your canvas.
    • Set the “HTTP Method” to “POST.”
    • Set the “Path” to something simple like webhook.
    • Copy the full webhook URL displayed by the node.
    • Click “Listen for test event” on the Webhook node.
  3. Configure WAA to Send to Webhook:
    • Return to the WAA dashboard in your browser.
    • Go to “Configuration” for your default session.
    • Under “Webhook,” click “Add Webhook Path.”
    • Paste the Webhook URL copied from n8n.
    • Uncheck “Session Status” to only receive message events.
    • Click “Update.”
  4. Test the Webhook Connection:
    • From a different WhatsApp number, send a test message to your linked WhatsApp number (e.g., “Hello n8n!”).
    • Return to n8n. The Webhook node should now show incoming data, confirming the connection.
  5. Import the Prepared Workflow: A pre-made workflow is available that streamlines the process significantly.
    • Download the provided n8n workflow file (often a .json file) from the tutorial resources.
    • In n8n, click the “Import” icon (top right, usually a cloud with an arrow pointing down).
    • Select “Import from file” and upload the downloaded workflow .json file. This will automatically set up the core logic, including data saving, message filtering, AI integration, and WhatsApp responses.

Step 10: Configure and Test the AI Agent and WhatsApp Response

The imported workflow will contain nodes for AI integration and WhatsApp messaging.

  1. Understand the Workflow:
    • “Save Important Data” node: This initial node filters and saves essential message details (sender ID, message content) from the incoming webhook.
    • “Switch” node: This node ensures that only actual messages trigger the AI response, ignoring other webhook events.
    • OpenAI Node (or similar AI provider): This node connects to your AI agent.
      • Credentials: You’ll need to set up your OpenAI API credentials.
      • Assistant/Agent Selection: Choose the pre-trained AI assistant (e.g., one trained on your business data).
      • Prompt Input: Ensure the message content from the WhatsApp webhook is passed as input to the AI.
    • WAA “Mark as Read” node: Marks the incoming WhatsApp message as read.
    • WAA “Send Message” node: Sends the AI’s response back to the user on WhatsApp.
  2. Final Test:
    • Activate the workflow in n8n (toggle the “Active” switch top right).
    • From a different WhatsApp number, send a detailed question to your linked WhatsApp number (e.g., “Tell me about Azuro’s team?”).
    • Observe the response: Your message should be marked as read, and the AI agent’s detailed answer should appear almost instantly on WhatsApp.

By following these steps, you will have successfully set up a powerful and automated WhatsApp communication system integrated with an AI agent—all without typical limitations or costs. This opens up endless possibilities for customer service, lead generation, or any conversational automation you can imagine.


Kaptan Data Solutions

🔍 Discover Kaptan Data Solutions — your partner for medical-physics data science & QA!

We're a French startup dedicated to building innovative web applications for medical physics, and quality assurance (QA).

Our mission: provide hospitals, cancer centers and dosimetry labs with powerful, intuitive and compliant tools that streamline beam-data acquisition, analysis and reporting.

🌐 Explore all our medical-physics services and tech updates
💻 Test our ready-to-use QA dashboards online

Our expertise covers:

📊 Interactive dashboards for linac performance & trend analysis
🔬 Patient-specific dosimetry and image QA (EPID, portal dosimetry)
📈 Statistical Process Control (SPC) & anomaly detection for beam data
🤖 Automated QA workflows with n8n + AI agents (predictive maintenance)
📑 DICOM-RT / HL7 compliant reporting and audit trails

Leveraging advanced Python analytics and n8n orchestration, we help physicists automate routine QA, detect drifts early and generate regulatory-ready PDFs in one click.

Ready to boost treatment quality and uptime? Let’s discuss your linac challenges and design a tailor-made solution!

#MedicalPhysics #Radiotherapy #LinacQA #DICOM #DataScience #Automation

Request a quote

Get in touch to discuss your specific requirements and discover how our tailor-made solutions can help you unlock the value of your data, make informed decisions, and boost operational performance!

#DataScience #Automation #Python #n8n #Streamlit #DataAnalysis #AI #Visualization

Submit your project brief and receive a proposal

Share: X (Twitter) Facebook LinkedIn

Comments