Skip to content

A version of Baileys WhatsApp that works on Cloudflare Workers

License

Notifications You must be signed in to change notification settings

rafaelsg-01/whatsapp-cloudflare-workers

 
 

Repository files navigation

WhatsApp Cloudflare Workers

This project is a modified version of Baileys WhatsApp, specifically optimized to run on Cloudflare Workers. It allows you to register multiple WhatsApp numbers and send messages to any number efficiently.

How does it work?

  • The system operates directly on the edge, using Cloudflare Workers to establish connections with WhatsApp.
  • A direct connection is made with the WhatsApp server WebSocket and maintained for a short period (between 10 and 50 seconds).
  • This duration is sufficient to register an account and obtain the key or to send messages.
  • After this period, the connection is closed, ensuring efficient resource consumption and significant processing savings.

Scalability

  • Scalability tests have not yet been conducted.
  • It is suspected that message sending will be managed through a queue system, rather than horizontal scalability.

This approach aims to keep the system lightweight and efficient without requiring persistent connections.

Page to register multiple WhatsApp accounts

image

Generate QR Code

image

Page to send message

image

How to Set Up and Run the Project

1. Clone the Repository

git clone https://github.com/rafaelsg-01/whatsapp-cloudflare-workers.git
cd whatsapp-cloudflare-workers

2. Install Dependencies

npm install

3. Run the Local Server

wrangler dev

The server will be available at: http://127.0.0.1:8787


UserBot Registration

Choose a name for your UserBot, using only characters from a-z, A-Z and 0-9.

The default admin password is 123456, and it can be changed in the file:

/Example/example.ts

In the variable:

const PASSWORD_ADMIN = "123456";

1. Connect to WhatsApp

  1. Access the main page.
  2. Fill in the UserBot and Admin Password fields.
  3. Click the blue "Generate QR Code" button.
  4. Scan the QR Code with WhatsApp on your phone as quickly as possible to avoid errors.
  5. Wait 30 seconds for the UserBot to appear in the list.

2. Test Message Sending

  1. Go to the Send Message page by clicking the green "Go to Send Message" button.
  2. Fill in the following fields:
    • UserBot (the one you just created)
    • Phone number (destination)
    • Message
    • Admin Password
  3. Click "Send Message" and if everything is correct, the message will be sent!

This project is also available via npm:

npm i whatsapp-cloudflare-workers

If you have any questions or need help, feel free to open an issue or contribute with improvements!

About

A version of Baileys WhatsApp that works on Cloudflare Workers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.4%
  • TypeScript 8.4%
  • Other 0.2%