Hosting a Whatsapp Bot on Square Cloud
This article guides you through creating and hosting a Whatsapp bot on Square Cloud.
Introduction
- Before you start coding it is necessary to properly set up your bot on WhatsApp. First, you need to have WhatsApp downloaded on your phone. If you don’t have it yet, you can visit the official WhatsApp website. After having WhatsApp installed and configured, you can start programming your bot.
- Next, you will need to create an account on Square Cloud, which can be done through the sign up page. You can use your email to create an account.
- Finally, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.
Starting Project
- Ensure you have Node.js installed on your system. If not, you can download it from the official Node.js website.
- Initialize a new Node.js project using
npm init
. This will create a newpackage.json
file for your project:
- Install the whatsapp-web.js and qrcode library using npm:
- Create a new JavaScript file (e.g.,
index.js
) and add the following code to create a basic Whatsapp bot:
Creating the squarecloud config file
Learn about: how to make the configuration file for Square Cloud.
The squarecloud.app file is a configuration file that will be used to configure your application; it will be used to define the name, description, version, main file, among other things.
Configuring the START Field
In the Square Cloud configuration file, the START field is optional and only needed if you are using a custom script to start the bot. In the provided example, the START field is not necessary.
Uploading Project to Square Cloud
After preparing your project files, you can now upload them to Square Cloud and host your project.
Access the Square Cloud Dashboard and upload your project files.
Access the Square Cloud Dashboard and upload your project files.
First Step
First, you need to have the CLI installed in your environment. If you don’t have it yet, run the following command in your terminal:
If you already have it, we recommend updating it. To do this, run the following command in your terminal:
Second Step
Now, to authenticate and use other CLI commands, you will find your authorization key here by clicking on “Request API Key”. After obtaining your authorization key, run the following command:
Third Step
Finally, to deploy your application to Square Cloud using the CLI, you need to execute the following command, passing the path of your zip file:
Additional Resources
For more information on creating bots with whatsapp-web.js, visit the official whatsapp-web.js documentation. There, you’ll find detailed guides, tutorials, and API documentation to help you make the most of these libraries.
If you continue to experience any issues, please don’t hesitate to contact our support team.