Introduction to wa-automate-nodejs
wa-automate-nodejs is a sophisticated and user-friendly Node.js library that offers a high-level API for controlling WhatsApp. It is designed to cater to developers looking to interact with WhatsApp seamlessly through Node.js applications.
Key Features
- API for WhatsApp Web: This library effectively transforms your WhatsApp Web into a controllable API, enabling developers to automate and streamline interactions.
- Multi-Device Support: It supports WhatsApp's latest multi-device feature, allowing users to access their WhatsApp account on multiple devices simultaneously.
- Extensive Functionality: The library provides a wide array of functions, such as sending messages, media, stickers, and more. It also includes fetching contacts, groups, and chat lists.
Installation and Updating
To install wa-automate-nodejs and keep it updated, the following command is used:
npm i --save @open-wa/wa-automate@latest
Usage Overview
CLI
By using the Command Line Interface (CLI), developers can effortlessly convert their WhatsApp account into an API. It provides a straightforward method to interact with WhatsApp through terminal commands.
npx @open-wa/wa-automate --help
Custom Setup
For those requiring a tailored configuration, wa-automate-nodejs provides numerous options. Key configurations include setting a session ID, enabling multi-device support, and setting connection timeouts. Here is a quick setup example:
const wa = require('@open-wa/wa-automate');
wa.create({
sessionId: "COVID_HELPER",
multiDevice: true,
authTimeout: 60,
blockCrashLogs: true,
headless: true,
}).then(client => start(client));
function start(client) {
client.onMessage(async message => {
if (message.body === 'Hi') {
await client.sendText(message.from, '👋 Hello!');
}
});
}
Multi-Device Support
Currently, wa-automate-nodejs is in a transition phase to fully support WhatsApp's multi-device capability. Users can enable this manually to take advantage of accessing multiple devices.
Latest Updates
Due to frequent updates from WhatsApp, it's recommended to keep the library updated to ensure compatibility and access to new features.
Functions List
Some notable functions include:
- onMessage: Receives messages.
- sendText: Sends text messages.
- getContact: Retrieves contact information.
- getAllChats: Retrieves all chat conversations.
- sendImage: Sends images.
For a comprehensive list of functions, refer to the official documentation.
Running the Demo
Developers can explore the capabilities of wa-automate-nodejs by running a demo using TypeScript:
git clone https://github.com/open-wa/wa-automate-nodejs.git
cd wa-automate-nodejs
npm i
npm i -g ts-node typescript
cd demo
ts-node index.ts
Contributing and Support
Contribution through pull requests is encouraged. For extensive changes, it's advisable to discuss via issues first. Paid support, consulting, or sponsoring options are available for developers seeking more tailored assistance.
Legal Notice
wa-automate-nodejs is an independent software unaffiliated with WhatsApp or its affiliates. Users should adhere to legal guidelines regarding cryptographic software and comply with local laws and regulations.
This comprehensive introduction outlines how wa-automate-nodejs serves as an essential tool for developers looking to integrate WhatsApp into their Node.js applications, offering flexibility, ease of use, and powerful features.