Skip to main content

Installation

This guide covers how to install the WhatsApp SDK and its dependencies.

Package Installation

You can install the WhatsApp SDK using npm or yarn:

Using npm

npm install @deco-cx/whatsapp-sdk

Using yarn

yarn add @deco-cx/whatsapp-sdk

System Requirements

The WhatsApp SDK requires:
  • Node.js: Version 20.0.0 or higher
  • Operating System: Windows, macOS, or Linux
  • Dependencies:
    • Puppeteer (automatically installed)
    • A Chromium-based browser (will be downloaded by Puppeteer if not available)

Puppeteer Dependencies

Since the WhatsApp SDK uses Puppeteer to automate WhatsApp Web, you might need to install additional dependencies depending on your operating system.

Linux (Ubuntu/Debian)

sudo apt-get update
sudo apt-get install -y \
    gconf-service \
    libasound2 \
    libatk1.0-0 \
    libc6 \
    libcairo2 \
    libcups2 \
    libdbus-1-3 \
    libexpat1 \
    libfontconfig1 \
    libgcc1 \
    libgconf-2-4 \
    libgdk-pixbuf2.0-0 \
    libglib2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libstdc++6 \
    libx11-6 \
    libx11-xcb1 \
    libxcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxrender1 \
    libxss1 \
    libxtst6 \
    ca-certificates \
    fonts-liberation \
    libappindicator1 \
    libnss3 \
    lsb-release \
    xdg-utils \
    wget

macOS

No additional dependencies are required for macOS.

Windows

No additional dependencies are required for Windows.

Verifying Installation

To verify that the WhatsApp SDK is installed correctly, you can create a simple script:
import { WhatsAppSDK } from '@deco-cx/whatsapp-sdk';

// This should print the version if installed correctly
console.log(`WhatsApp SDK version: ${WhatsAppSDK.version}`);

Troubleshooting

Puppeteer Issues

If you encounter issues with Puppeteer, you can try:
  1. Setting the PUPPETEER_SKIP_DOWNLOAD environment variable and using a specific browser executable:
const sdk = new WhatsAppSDK({
  puppeteer: {
    executablePath: '/path/to/your/chromium'
  }
});
  1. Using a no-sandbox option (not recommended for production):
const sdk = new WhatsAppSDK({
  puppeteer: {
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  }
});

Permission Issues

If you encounter permission issues:
# Fix for Linux permission issues with Puppeteer
sudo chown -R $(whoami) ~/.cache/puppeteer

Next Steps

After installing the WhatsApp SDK, check out the Getting Started guide to create your first WhatsApp integration.