Skip to main content

Introduction

To develop and host a WhatsApp bot on Square Cloud, it’s essential to follow a structured sequence of configurations and prerequisites. This technical guide will cover the entire process, from initial setup to production deployment.

Prerequisites

  • Square Cloud Account: Register through the signup page using your email.
  • Active plan: Ensures dedicated resources and optimized performance for your application. Check our available plans and choose the most suitable for your needs.
This guide runs on the Node.js runtime.

Create the project

You need WhatsApp installed on your phone to link the bot to your account. If you don’t have the app, visit the official WhatsApp website for download and setup.
  1. Node.js verification: Confirm that Node.js is installed on your system. Otherwise, download it from the official Node.js website.
  2. Project initialization: Set up a new Node.js project by running the initialization command:
Terminal
  1. Dependencies installation: Install the essential libraries for bot functionality:
Terminal

Develop the bot

Create the index.js file with the bot’s base structure:
index.js

Configure Square Cloud

Create a squarecloud.app file at the root of your project, next to index.js. It tells Square Cloud how to run your bot:
squarecloud.app
  • MEMORY is the bot’s RAM in MB. whatsapp-web.js runs a headless Chromium browser, so give it at least 1024 MB.
  • AUTORESTART=true starts the bot again if it crashes. See how auto restart works.
  • There is no SUBDOMAIN: the bot doesn’t serve web pages.
See the configuration file reference for every field.

What goes in the ZIP

  • index.js and your other source files.
  • package.json.
  • squarecloud.app.
Leave out node_modules: Square Cloud installs your dependencies when the bot starts. Also leave out the .wwebjs_auth and .wwebjs_cache folders that a run on your computer creates, so the bot links its own session on Square Cloud. If you upload with the CLI, list both folders in your squarecloud.ignore file.

Deploy and verify

Create the ZIP described above, then upload it:

Via dashboard

1

Access the Upload Page

Access the upload page and upload your project zip file.
2

Configure Your Environment

After uploading your zip, you will need to configure the name, main file or runtime environment and other settings for your project.
If you are uploading a web project, make sure to select “Web Publication” and set a subdomain to your project.
3

Deploy Your Project

Finally, click on the “Deploy” button to host your project on Square Cloud.
After deployment, you can monitor your project’s status and logs from the dashboard.
Uploading application to Square Cloud
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. In the dashboard, wait for your application status to show as running and check the logs for any startup errors.
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.

Via CLI

To use this method, your project needs a configuration file named squarecloud.app at its root. It tells Square Cloud how to run your application.

Configuration file guide

Learn how to create the squarecloud.app configuration file that defines your application’s environment.
1

Install the CLI

Install the Square Cloud CLI. If you already have it, run the same command to update it:
2

Log In

Run the command below. It opens your browser: approve the login there and the CLI is ready. There is no API key to copy. For scripts and CI, see CLI authentication.
3

Upload Your Project

From your project folder, run the command below. The CLI zips the current folder, leaving out what squarecloud.ignore lists, and uploads it:
To upload a zip you created yourself, pass it with --file:
4

Confirm Your App Is Live

Your first deploy usually takes less than a minute. Check your application status and logs directly from the terminal:
If you deployed a website or API, open https://<your-subdomain>.squareweb.app in your browser: you should see your application responding. If you deployed a bot, send it a command to confirm it is online.
App not starting? See the Troubleshooting guide for the most common causes and fixes.
Open the application logs in the Square Cloud dashboard. On first boot, the bot prints a QR Code there: on your phone, open WhatsApp, go to Linked devices > Link a device and scan it. The WhatsApp client successfully initialized! message confirms the session is active. Then send !ping from another number to the linked WhatsApp account and confirm it replies with pong - Bot working correctly!. LocalAuth saves the session in the .wwebjs_auth folder, so restarts reconnect without a new QR Code. To link a different number, delete that folder and restart the application.

Common errors

The QR Code can’t be scanned

The QR Code is drawn with text characters, and WhatsApp replaces it periodically, so scan the most recent one. If your phone can’t read it, zoom out until the whole code fits on screen, or switch the dashboard to the dark theme.

Login stopped working after a WhatsApp Web update

Update the library with npm install whatsapp-web.js@latest and deploy again. Avoid pinning an old WhatsApp Web version with the webVersionCache option: outdated versions tend to break login.

The bot runs out of memory

whatsapp-web.js runs a headless Chromium browser, which needs memory. Keep MEMORY at 1024 MB or more, or switch to Baileys, which runs without a browser.

Use Baileys instead of whatsapp-web.js

Baileys is an alternative library that connects to WhatsApp’s multi-device API directly over a WebSocket, without launching a headless browser. Since there’s no Chromium/Puppeteer instance to run, it uses significantly less RAM than whatsapp-web.js. Baileys saves its session (the creds.json file and keys) in the auth folder through useMultiFileAuthState. Square Cloud keeps your application’s files between restarts, so you only need to scan the QR Code again if you log out or delete that folder. As with .wwebjs_auth, leave a local auth folder out of your ZIP.
  1. Install the library:
Terminal
  1. Create an index.js file using makeWASocket and useMultiFileAuthState to load and persist the session:
index.js
Since Baileys doesn’t need a browser, its configuration file on Square Cloud can use a lower MEMORY value than the whatsapp-web.js example above:
squarecloud.app

Next steps

App won't start

Fix missing modules, memory errors and other startup failures.

Evolution API

Run a WhatsApp API that manages many instances at once.

Bot hosting

What Square Cloud offers for bots that run 24/7.
For more about whatsapp-web.js, see the official whatsapp-web.js documentation.

Contact us

If you continue facing technical difficulties, our specialized support team is available to assist you. Contact us and we’ll be happy to help you resolve any issue: support quality is a big part of why developers rate Square Cloud 4.9/5 across 402 reviews on Google and Trustpilot.