open-wa Node.js Toolkit
repository·master·Indexed 25 days ago
https://github.com/open-wa/wa-automate-nodejsA Node.js toolkit for WhatsApp Web automation that provides various surfaces including a local HTTP API, bot runtime, webhook bridge, and AI agent interface via MCP. The v5 monorepo includes tools like @open-wa/orchestrator-cli for multi-session management, @open-wa/orchestrator-dashboard for session monitoring, and specialized integrations for Chatwoot, Cloudflare Tunnels, Node-RED, and S3 cloud media storage.
What's inside open-wa
- @open-wa/orchestrator-cli is a multi-session orchestration CLI tool. It is part of the @open-wa v5 monorepo and is designed to manage and orchestrate multiple WhatsApp sessions.
Overview of Open-WA Packages
masterOpen-WA is composed of several specialized packages that allow you to build WhatsApp automation solutions. Depending on your needs, you can use the high-level Easy API, the CLI, or build custom integrations using the Plugin SDK and specific browser drivers.Overview of @open-wa/wa-automate features
masterThe
@open-wa/wa-automatepackage provides a reliable WhatsApp automation solution with the following capabilities:- Easy API: Run a standalone server and interact via HTTP.
- Multi-session: Manage multiple WhatsApp accounts simultaneously.
- Robustness: Advanced retries and state management.
- Drivers: Support for Playwright, Puppeteer, and Lightpanda.
Overview of @open-wa/core features
masterThe
@open-wa/corepackage serves as the integration backbone for the Open-WA monorepo, providing the following capabilities:- Driver Abstraction: A unified interface for interacting with different browser automation engines.
- Session Management: Handles the secure storage and restoration of authentication states.
- Event Bus: Utilizes
@open-wa/hyperemitterfor high-performance internal communication.
Use open-wa with AI via MCP
masteropen-wa supports the Model Context Protocol (MCP). This allows you to expose Easy API methods as tools that can be directly connected to and used by AI assistants.Understand the registry workspace
masterTheregistryworkspace is a static component registry for OpenWA UI assets. It serves assets via apublic/registry.jsonfile. It is a component of the @open-wa v5 monorepo.Use @open-wa/integration-webhook to forward events
masterThe@open-wa/integration-webhookplugin forwards publicopen-waevents to an external URL via HTTPPOST. This allows external services to receive runtime events without needing to embedopen-wadirectly. It features event filtering, custom headers, request timeouts, exponential backoff retries, and concurrent delivery via a queue.Understand the Plugin Security Model
masterPlugins run within the
open-wahost process but operate under strict security boundaries to ensure host stability and security.Security Restrictions
- No Event Emission: Plugins can only subscribe to events; they cannot use
events.emit()to send custom events into the host system. - No Internal Event Access: The host filters out sensitive event namespaces such as
launch.*,browser.*,transport.*,license.*, and raw session/authentication data. - No Direct Browser Access: Plugins interact via a
clientproxy. You cannot execute CDP commands, manipulate the DOM, access browser cookies/storage, or inject scripts directly. - Scoped File System Access: Plugins are restricted from reading or writing arbitrary files on the host. File operations must be scoped to the plugin's own data directory.
- No Event Emission: Plugins can only subscribe to events; they cannot use
Understand Client Architecture and Concepts
masterTo effectively use the client, you should understand the following core architectural concepts:
- Schema Pipeline: Uses a single definition to create multiple projections.
- BaseClient: The generated flat client and dispatch table.
- Namespaced Client: How namespace members are mapped to the client.
- Argument Normalization: Handles the conversion between positional and object arguments, including aliases.
- Aliases: Support for function and parameter key aliases.
- Data Models: Core schemas for
Message,Contact,Chat, andGroupMetadata. - Generated Types: The source of input and output type aliases.
- Events: Registered events and their associated payloads.
- Licensed Methods: Identification of which methods require a license key.
Choose an integration pattern for open-wa
masterSelect an integration pattern based on your specific requirements for complexity and use case:
- Webhooks: Best for pushing events to an existing service (Low complexity).
- SocketClient: Best for building a bot directly in Node.js (Medium complexity).
- Plugins: Best for creating reusable integrations that run inside the open-wa process (Medium complexity).
- Chatwoot: Best for providing a full inbox experience with human agents (Medium complexity).
- MCP: Best for allowing AI agents to control WhatsApp (Low complexity).
- Embedded runtime: Best for full control over the browser (High complexity).
Use the OpenWA UI Static Component Registry
masterTheregistrypackage provides a static component registry for OpenWA UI assets. These assets are served via apublic/registry.jsonfile. This registry is part of the OpenWA monorepo and is used to manage UI components within the OpenWA ecosystem.Identify the Easy API and SocketClient usage patterns
masterDepending on your architecture, you will interact with open-wa in one of two ways:
- Easy API: A hosted runtime surface that exposes client functionality over HTTP. It is activated by running
npx @open-wa/wa-automate. It provides interactive documentation and generated schemas. - SocketClient: A remote consumer client used to connect to an Easy API instance. Use this pattern if you want to consume open-wa features without embedding the full browser automation runtime (Puppeteer/Playwright) directly into your own application.
- Easy API: A hosted runtime surface that exposes client functionality over HTTP. It is activated by running