Developer Setup: Single Instance

This guide will walk you through how to set up a single instance of the WhatsApp Business API Client on a developer machine.

This document covers:

Prerequisites

  1. Install Docker on your system.
  2. If Docker Compose is not bundled with your Docker installation, install it.
  3. It's recommended you set up a test account locally for fast development and to test new releases.

For a production setup, follow the instructions in Production Setup: Single Instance.

Initial Setup

  1. Create a biz directory to store the setup scripts:
    mkdir ~/biz; cd ~/biz;
  2. Get the configuration files from the WhatsApp-Business-API-Setup-Scripts Github repo.
  3. Set the WA_API_VERSION environment variable to the current version using:
    export WA_API_VERSION=new-whatsapp-version
  4. To start the WhatsApp Business API Client with 1 database container, 1 Webapp container and 1 Coreapp container, run:
    docker-compose up -d
    Example output:
    Creating volume "biz_whatsappMedia" with local driver
    Creating volume "biz_mysqlData" with local driver
    Creating biz_db_1 ... done
    Creating biz_wacore_1 ... done
    Creating biz_waweb_1  ... done
    
  5. Check that all containers have an UP state by running:
    docker-compose ps
    By default, the Webapp container will be running on port 9090 and the database container will be running on port 33060.

    Example output:
    ~/biz $ docker-compose ps
         Name                    Command               State                   Ports
    -------------------------------------------------------------------------------------------------
    biz_db_1       docker-entrypoint.sh mysqld      Up      0.0.0.0:33060->3306/tcp, 33060/tcp
    biz_wacore_1   /opt/whatsapp/bin/wait_on_ ...   Up      6250/tcp, 6251/tcp, 6252/tcp, 6253/tcp
    biz_waweb_1    /opt/whatsapp/bin/wait_on_ ...   Up      0.0.0.0:9090->443/tcp
    
    
  6. You can download and configure our Postman Collection to easily interact with the WhatsApp Business API.
  7. Perform a health check on the WhatsApp Business API Client. Example response:
    {
        "health": {
            "gateway_status": "unregistered"
        }
    }
    
    Because your WhatsApp Business API Client is not registered right now, you will see "unregistered" in the health status response.
  8. Follow the Registration documentation to register the WhatsApp Business API Client.
  9. Perform another health check after registration. You should now see connected status, which means the Coreapp container is able to connect to the WhatsApp server to check contacts and send messages. Example response:
    {
        "health": {
            "gateway_status": "connected"
        }
    }
    

Upgrading

It is highly recommended to backup your current application settings before upgrading. Please follow the Backup and Restore documentation.

To upgrade an installation, change the WA_API_VERSION environment variable to the new version and restart the Docker containers:

export WA_API_VERSION=new-whatsapp-version

docker-compose up -d
Example output:
biz_db_1 is up-to-date
Recreating biz_wacore_1 ... done
Recreating biz_waweb_1  ... done

For MySQL database users upgrading to version 2.23.x and above

You can now make use of a database upgrade service that will let you upgrade your database while your application is still running to avoid downtime*.

  1. Download the dbupgrade-compose.yml file, which has fields indicating the container version.
    For example:
    services:
      dbupgrade:
        image: docker.whatsapp.biz/coreapp:v${WA_API_VERSION:-2.21.3}
    
  2. To upgrade an installation, run the dbupgrade-service container with the WA_API_VERSION environment variable set to the latest version:
    WA_API_VERSION=2.23.4 docker-compose -f dbupgrade-compose.yml up -d
    
    Note: If you are using an orchestration that restarts the container upon exit irrespective of the exit code, start the service with the EXIT_ON_SUCCESS environment variable set to FALSE in order to avoid exiting the container when the exit code is 0.
  3. Wait for the upgrade to finish. If the database upgrade is successful, the container will exit with code 0. You can use the following Docker command to track the status:
    docker wait your-database-upgrade-container-name
    This will output the exit code of the dbupgrade-service container.
  4. Restart the Coreapp and Webapp Docker containers with the WA_API_VERSION environment variable set to the latest version:
    WA_API_VERSION=2.23.4 docker-compose up -d
    

* If you're upgrading from 2.19.7, you may still experience some downtime. It is always recommended to perform upgrades during your least busiest hours.

Uninstalling

It is highly recommended to backup your current application settings before uninstallation. Please follow the Backup and Restore documentation.

If you need to reset your development environment by removing all containers, run the following command from the directory containing the docker-compose.yml file:

docker-compose down

Example output:

Stopping biz_waweb_1  ... done
Stopping biz_wacore_1 ... done
Stopping biz_db_1     ... done
Removing biz_waweb_1  ... done
Removing biz_wacore_1 ... done
Removing biz_db_1     ... done

In order to get rid of all volumes defined in the docker-compose.yml file in addition to the containers, run down with the -v parameter:

docker-compose down -v

Troubleshooting

We recommend WADebug for more effective troubleshooting. WADebug is a command line tool to help find any potential issues with WhatsApp Business API setup and to make requesting for help from WhatsApp support more effective.

In cases where WADebug cannot be used or running the tool returns errors, to collect logs from all containers, run the following command:

docker-compose logs > debug_output.txt

To collect logs of a specific service, append the service name (waweb or wacore) to the docker-compose logs command, e.g.:

docker-compose logs waweb > debug_output.txt

You can find the logs in the debug_output.txt file in the current directory.


This software uses code of FFmpeg licensed under the LGPLv2.1 and its source can be downloaded here.