n8n-nodes-wwebjs-api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +204 -0
- package/README.md +381 -0
- package/dist/credentials/WWebJsApiCredentials.d.ts +9 -0
- package/dist/credentials/WWebJsApiCredentials.js +54 -0
- package/dist/credentials/WWebJsApiCredentials.js.map +1 -0
- package/dist/nodes/WWebJsApi/WWebJsApi.node.d.ts +5 -0
- package/dist/nodes/WWebJsApi/WWebJsApi.node.js +516 -0
- package/dist/nodes/WWebJsApi/WWebJsApi.node.js.map +1 -0
- package/dist/nodes/WWebJsApi/WWebJsApiTrigger.node.d.ts +5 -0
- package/dist/nodes/WWebJsApi/WWebJsApiTrigger.node.js +363 -0
- package/dist/nodes/WWebJsApi/WWebJsApiTrigger.node.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/ChannelDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/ChannelDescription.js +114 -0
- package/dist/nodes/WWebJsApi/descriptions/ChannelDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/ChatDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/ChatDescription.js +73 -0
- package/dist/nodes/WWebJsApi/descriptions/ChatDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/ClientDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/ClientDescription.js +220 -0
- package/dist/nodes/WWebJsApi/descriptions/ClientDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/ContactDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/ContactDescription.js +45 -0
- package/dist/nodes/WWebJsApi/descriptions/ContactDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/GroupChatDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/GroupChatDescription.js +84 -0
- package/dist/nodes/WWebJsApi/descriptions/GroupChatDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/MessageDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/MessageDescription.js +135 -0
- package/dist/nodes/WWebJsApi/descriptions/MessageDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/SessionDescription.d.ts +3 -0
- package/dist/nodes/WWebJsApi/descriptions/SessionDescription.js +44 -0
- package/dist/nodes/WWebJsApi/descriptions/SessionDescription.js.map +1 -0
- package/dist/nodes/WWebJsApi/descriptions/index.d.ts +7 -0
- package/dist/nodes/WWebJsApi/descriptions/index.js +25 -0
- package/dist/nodes/WWebJsApi/descriptions/index.js.map +1 -0
- package/dist/nodes/WWebJsApi/transport.d.ts +53 -0
- package/dist/nodes/WWebJsApi/transport.js +253 -0
- package/dist/nodes/WWebJsApi/transport.js.map +1 -0
- package/dist/nodes/WWebJsApi/types.d.ts +139 -0
- package/dist/nodes/WWebJsApi/types.js +6 -0
- package/dist/nodes/WWebJsApi/types.js.map +1 -0
- package/dist/nodes/WWebJsApi/wwebjs-api.svg +10 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
|
|
204
|
+
Copyright 2024 Victor García Pastor
|
package/README.md
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# n8n-nodes-wwebjs-api
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/n8n-nodes-wwebjs-api)
|
|
4
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
5
|
+
[](https://github.com/vgpastor/n8n-nodes-wwebjs-api)
|
|
6
|
+
|
|
7
|
+
n8n community node for **[WWebJS REST API](https://github.com/avoylenko/wwebjs-api)** — automate WhatsApp Web messaging from n8n.
|
|
8
|
+
|
|
9
|
+
This node provides a bridge between n8n and WhatsApp Web, powered by the excellent [whatsapp-web.js](https://github.com/pedroslopez/whatsapp-web.js) library.
|
|
10
|
+
|
|
11
|
+
## Architecture
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────┐ ┌──────────────────────┐ ┌─────────────────┐ ┌──────────────┐
|
|
15
|
+
│ n8n │────▶│ n8n-nodes-wwebjs-api │────▶│ wwebjs-api │────▶│ whatsapp-web.js │
|
|
16
|
+
│ │◀────│ (this package) │◀────│ (REST server) │◀────│ (library) │
|
|
17
|
+
└─────────┘ └──────────────────────┘ └─────────────────┘ └──────────────┘
|
|
18
|
+
│
|
|
19
|
+
▼
|
|
20
|
+
┌──────────────┐
|
|
21
|
+
│ WhatsApp Web │
|
|
22
|
+
└──────────────┘
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- **[whatsapp-web.js](https://github.com/pedroslopez/whatsapp-web.js)** - A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
|
|
26
|
+
- **[wwebjs-api](https://github.com/avoylenko/wwebjs-api)** - REST API wrapper that exposes whatsapp-web.js functionality via HTTP endpoints
|
|
27
|
+
- **n8n-nodes-wwebjs-api** (this package) - n8n nodes that integrate with wwebjs-api
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
This package provides two nodes:
|
|
32
|
+
|
|
33
|
+
- **WWebJS API** — Action node with 7 resources and 60+ operations
|
|
34
|
+
- **WWebJS API Trigger** — Webhook trigger for incoming WhatsApp events with advanced filtering
|
|
35
|
+
|
|
36
|
+
### Highlights
|
|
37
|
+
|
|
38
|
+
- Send text, media, location, contacts, and polls
|
|
39
|
+
- Manage multiple WhatsApp sessions
|
|
40
|
+
- Group management (add/remove participants, admin controls)
|
|
41
|
+
- Channel support (WhatsApp Channels/Newsletters)
|
|
42
|
+
- Message reactions, replies, forwards, and edits
|
|
43
|
+
- Webhook trigger with filters (session, chat, content, sender)
|
|
44
|
+
- Webhook authentication (Header Auth, HMAC signature)
|
|
45
|
+
- Input validation with descriptive error messages
|
|
46
|
+
|
|
47
|
+
## Prerequisites
|
|
48
|
+
|
|
49
|
+
1. **WWebJS API instance** running and accessible — [Setup instructions](https://github.com/avoylenko/wwebjs-api#installation)
|
|
50
|
+
2. **n8n** v1.0.0+ instance
|
|
51
|
+
|
|
52
|
+
### Quick start with Docker Compose
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
version: '3.8'
|
|
56
|
+
services:
|
|
57
|
+
wwebjs-api:
|
|
58
|
+
image: avoylenko/wwebjs-api:latest
|
|
59
|
+
ports:
|
|
60
|
+
- "3000:3000"
|
|
61
|
+
environment:
|
|
62
|
+
- API_KEY=your-secret-api-key
|
|
63
|
+
- BASE_WEBHOOK_URL=http://n8n:5678/webhook/whatsapp
|
|
64
|
+
volumes:
|
|
65
|
+
- wwebjs_sessions:/app/sessions
|
|
66
|
+
|
|
67
|
+
n8n:
|
|
68
|
+
image: n8nio/n8n:latest
|
|
69
|
+
ports:
|
|
70
|
+
- "5678:5678"
|
|
71
|
+
volumes:
|
|
72
|
+
- n8n_data:/home/node/.n8n
|
|
73
|
+
|
|
74
|
+
volumes:
|
|
75
|
+
wwebjs_sessions:
|
|
76
|
+
n8n_data:
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
### Option A: Community Nodes (Recommended)
|
|
82
|
+
|
|
83
|
+
1. Go to **Settings → Community Nodes**
|
|
84
|
+
2. Click **Install a community node**
|
|
85
|
+
3. Enter: `n8n-nodes-wwebjs-api`
|
|
86
|
+
4. Click **Install**
|
|
87
|
+
5. Restart n8n if prompted
|
|
88
|
+
|
|
89
|
+
### Option B: Install from GitHub
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd ~/.n8n
|
|
93
|
+
npm install github:vgpastor/n8n-nodes-wwebjs-api
|
|
94
|
+
|
|
95
|
+
# Or with a specific version/tag
|
|
96
|
+
npm install github:vgpastor/n8n-nodes-wwebjs-api#v1.0.0
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Option C: Install from npm
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cd ~/.n8n
|
|
103
|
+
npm install n8n-nodes-wwebjs-api
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Option D: Local development
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Clone and build
|
|
110
|
+
git clone https://github.com/vgpastor/n8n-nodes-wwebjs-api.git
|
|
111
|
+
cd n8n-nodes-wwebjs-api
|
|
112
|
+
npm install
|
|
113
|
+
npm run build
|
|
114
|
+
npm link
|
|
115
|
+
|
|
116
|
+
# Link to n8n
|
|
117
|
+
cd ~/.n8n
|
|
118
|
+
npm link n8n-nodes-wwebjs-api
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
After installation, restart n8n and the nodes will appear in the node palette.
|
|
122
|
+
|
|
123
|
+
## Configuration
|
|
124
|
+
|
|
125
|
+
### 1. Set up WWebJS API credentials
|
|
126
|
+
|
|
127
|
+
In n8n, go to **Settings → Credentials → Add Credential → WWebJS API** and configure:
|
|
128
|
+
|
|
129
|
+
| Field | Description | Example |
|
|
130
|
+
| ------------------ | ----------------------------------------------------- | ----------------------- |
|
|
131
|
+
| Base URL | URL of your WWebJS API instance | `http://localhost:3000` |
|
|
132
|
+
| API Key | The `API_KEY` env var from your WWebJS API | `my-secret-key` |
|
|
133
|
+
| Default Session ID | Default session to use when not specified in the node | `main-session` |
|
|
134
|
+
|
|
135
|
+
### 2. Configure webhook URL in WWebJS API
|
|
136
|
+
|
|
137
|
+
Set the `BASE_WEBHOOK_URL` env var in your WWebJS API instance to point to your n8n webhook URL:
|
|
138
|
+
|
|
139
|
+
```env
|
|
140
|
+
BASE_WEBHOOK_URL=https://your-n8n-instance.com/webhook/whatsapp
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
You can find the exact URL in the **WWebJS API Trigger** node settings.
|
|
144
|
+
|
|
145
|
+
## Resources & Operations
|
|
146
|
+
|
|
147
|
+
### Session
|
|
148
|
+
|
|
149
|
+
| Operation | Description |
|
|
150
|
+
| ------------------ | ---------------------------- |
|
|
151
|
+
| Start | Start a new WhatsApp session |
|
|
152
|
+
| Stop | Stop a session |
|
|
153
|
+
| Get Status | Get session status |
|
|
154
|
+
| Get QR Code | Get QR code for login |
|
|
155
|
+
| Get QR Image | Get QR as PNG image |
|
|
156
|
+
| Restart | Restart a session |
|
|
157
|
+
| Terminate | Terminate and delete session |
|
|
158
|
+
| Terminate All | Terminate all sessions |
|
|
159
|
+
| Terminate Inactive | Terminate inactive sessions |
|
|
160
|
+
| Get All Sessions | List all active sessions |
|
|
161
|
+
|
|
162
|
+
### Client (core messaging)
|
|
163
|
+
|
|
164
|
+
| Operation | Description |
|
|
165
|
+
| -------------------- | -------------------------------------------- |
|
|
166
|
+
| Send Message | Send text, media, location, contact, or poll |
|
|
167
|
+
| Get Chats | Get all current chats |
|
|
168
|
+
| Get Chat By ID | Get a specific chat |
|
|
169
|
+
| Get Contacts | Get all contacts |
|
|
170
|
+
| Get Contact By ID | Get a specific contact |
|
|
171
|
+
| Search Messages | Search for messages |
|
|
172
|
+
| Is Registered User | Check if a number is on WhatsApp |
|
|
173
|
+
| Get Number ID | Get the WhatsApp ID for a number |
|
|
174
|
+
| Get Connection State | Get the client connection state |
|
|
175
|
+
| Send Seen | Mark a chat as seen |
|
|
176
|
+
| Set Status | Update your status message |
|
|
177
|
+
| Get Profile Pic URL | Get a contact's profile picture |
|
|
178
|
+
| Archive/Unarchive | Archive or unarchive a chat |
|
|
179
|
+
| Mute/Unmute | Mute or unmute a chat |
|
|
180
|
+
| Pin/Unpin | Pin or unpin a chat |
|
|
181
|
+
| Get Blocked | Get blocked contacts |
|
|
182
|
+
|
|
183
|
+
### Message
|
|
184
|
+
|
|
185
|
+
| Operation | Description |
|
|
186
|
+
| -------------- | --------------------------- |
|
|
187
|
+
| Reply | Reply to a specific message |
|
|
188
|
+
| React | React with an emoji |
|
|
189
|
+
| Forward | Forward to another chat |
|
|
190
|
+
| Edit | Edit a sent message |
|
|
191
|
+
| Delete | Delete a message |
|
|
192
|
+
| Download Media | Download attached media |
|
|
193
|
+
| Get Info | Get message delivery info |
|
|
194
|
+
| Star/Unstar | Star or unstar a message |
|
|
195
|
+
|
|
196
|
+
### Chat
|
|
197
|
+
|
|
198
|
+
| Operation | Description |
|
|
199
|
+
| -------------------- | ------------------------ |
|
|
200
|
+
| Fetch Messages | Load messages from chat |
|
|
201
|
+
| Get Contact | Get contact for a chat |
|
|
202
|
+
| Get Info | Get chat details |
|
|
203
|
+
| Get Labels | Get labels for a chat |
|
|
204
|
+
| Send Typing State | Show typing indicator |
|
|
205
|
+
| Send Recording State | Show recording indicator |
|
|
206
|
+
| Send Seen | Mark messages as seen |
|
|
207
|
+
| Mark Unread | Mark chat as unread |
|
|
208
|
+
| Clear Messages | Clear all messages |
|
|
209
|
+
| Delete | Delete a chat |
|
|
210
|
+
|
|
211
|
+
### Group Chat
|
|
212
|
+
|
|
213
|
+
| Operation | Description |
|
|
214
|
+
| -------------------- | ------------------------ |
|
|
215
|
+
| Get Info | Get group details |
|
|
216
|
+
| Add Participants | Add members to group |
|
|
217
|
+
| Remove Participants | Remove members from group|
|
|
218
|
+
| Promote Participants | Promote to admin |
|
|
219
|
+
| Demote Participants | Demote from admin |
|
|
220
|
+
| Get Invite Code | Get group invite link |
|
|
221
|
+
| Leave | Leave the group |
|
|
222
|
+
| Revoke Invite | Invalidate invite code |
|
|
223
|
+
| Set Subject | Update group name |
|
|
224
|
+
| Set Description | Update group description |
|
|
225
|
+
|
|
226
|
+
### Contact
|
|
227
|
+
|
|
228
|
+
| Operation | Description |
|
|
229
|
+
| ---------------- | ------------------------ |
|
|
230
|
+
| Get Info | Get contact details |
|
|
231
|
+
| Block | Block a contact |
|
|
232
|
+
| Unblock | Unblock a contact |
|
|
233
|
+
| Get About | Get contact status text |
|
|
234
|
+
| Get Chat | Get chat for a contact |
|
|
235
|
+
| Get Profile Pic | Get profile picture URL |
|
|
236
|
+
| Get Common Groups| Get groups in common |
|
|
237
|
+
|
|
238
|
+
### Channel (WhatsApp Newsletters)
|
|
239
|
+
|
|
240
|
+
| Operation | Description |
|
|
241
|
+
| -------------- | --------------------------- |
|
|
242
|
+
| Get All | Get all subscribed channels |
|
|
243
|
+
| Get Info | Get channel details |
|
|
244
|
+
| Send Message | Send message to a channel |
|
|
245
|
+
| Fetch Messages | Load channel messages |
|
|
246
|
+
| Create | Create a new channel |
|
|
247
|
+
| Subscribe | Subscribe to a channel |
|
|
248
|
+
| Unsubscribe | Unsubscribe from a channel |
|
|
249
|
+
| Search | Search public channels |
|
|
250
|
+
| Delete | Delete a channel you own |
|
|
251
|
+
|
|
252
|
+
## Trigger Events
|
|
253
|
+
|
|
254
|
+
The **WWebJS API Trigger** node can listen for these events:
|
|
255
|
+
|
|
256
|
+
| Event | Description |
|
|
257
|
+
| ------------------------- | ----------------------------------------- |
|
|
258
|
+
| `message` | New incoming message received |
|
|
259
|
+
| `message_create` | Any message created (including sent) |
|
|
260
|
+
| `message_ack` | Message status (sent/delivered/read) |
|
|
261
|
+
| `message_revoke_everyone` | Message deleted for everyone |
|
|
262
|
+
| `message_revoke_me` | Message deleted for me |
|
|
263
|
+
| `qr` | QR code for authentication |
|
|
264
|
+
| `authenticated` | Client authenticated |
|
|
265
|
+
| `auth_failure` | Authentication failed |
|
|
266
|
+
| `ready` | Client ready |
|
|
267
|
+
| `disconnected` | Client disconnected |
|
|
268
|
+
| `change_state` | Connection state changed |
|
|
269
|
+
| `group_join` | Someone joined a group |
|
|
270
|
+
| `group_leave` | Someone left a group |
|
|
271
|
+
| `group_update` | Group info updated |
|
|
272
|
+
| `call` | Incoming call |
|
|
273
|
+
|
|
274
|
+
### Trigger Filters
|
|
275
|
+
|
|
276
|
+
Filter incoming events to only trigger workflows when conditions are met:
|
|
277
|
+
|
|
278
|
+
| Filter | Description |
|
|
279
|
+
| ------------------------- | ------------------------------------------------ |
|
|
280
|
+
| Session ID | Only events from a specific session |
|
|
281
|
+
| Chat ID Contains | Filter by phone number or chat type (`@g.us`) |
|
|
282
|
+
| Body Contains | Filter by message content (e.g., `/command`) |
|
|
283
|
+
| From Me Only | Only messages sent by you |
|
|
284
|
+
| Exclude From Me | Only messages from others |
|
|
285
|
+
| Groups Only | Only group chat messages |
|
|
286
|
+
| Individuals Only | Only individual chat messages |
|
|
287
|
+
|
|
288
|
+
### Trigger Authentication
|
|
289
|
+
|
|
290
|
+
Secure your webhook endpoint:
|
|
291
|
+
|
|
292
|
+
| Method | Description |
|
|
293
|
+
| -------------- | ---------------------------------------------- |
|
|
294
|
+
| None | No authentication (not recommended) |
|
|
295
|
+
| Header Auth | Validate a custom header token |
|
|
296
|
+
| HMAC Signature | Validate SHA-256 signature (timing-safe) |
|
|
297
|
+
|
|
298
|
+
## Usage Examples
|
|
299
|
+
|
|
300
|
+
### Send a WhatsApp message
|
|
301
|
+
|
|
302
|
+
1. Add **WWebJS API** node
|
|
303
|
+
2. Select **Client → Send Message**
|
|
304
|
+
3. Set **Session ID** = `my-session`
|
|
305
|
+
4. Set **Chat ID** = `34612345678@c.us`
|
|
306
|
+
5. Set **Content Type** = `Text`
|
|
307
|
+
6. Set **Message Text** = `Hello from n8n!`
|
|
308
|
+
|
|
309
|
+
### Auto-reply to incoming messages
|
|
310
|
+
|
|
311
|
+
1. Add **WWebJS API Trigger** node with event `message`
|
|
312
|
+
2. Set filter: **Exclude From Me** = `true`
|
|
313
|
+
3. Add **IF** node to check message content
|
|
314
|
+
4. Add **WWebJS API** node with **Client → Send Message**
|
|
315
|
+
5. Use expression `{{ $json.data.from }}` for Chat ID
|
|
316
|
+
|
|
317
|
+
### Send media from URL
|
|
318
|
+
|
|
319
|
+
1. Add **WWebJS API** node
|
|
320
|
+
2. Select **Client → Send Message**
|
|
321
|
+
3. Set **Content Type** = `Media (URL)`
|
|
322
|
+
4. Set **Content (JSON)**:
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"url": "https://example.com/image.jpg",
|
|
326
|
+
"caption": "Check out this image!"
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Forward messages to another chat
|
|
331
|
+
|
|
332
|
+
1. Add **WWebJS API Trigger** with filter **Body Contains** = `/forward`
|
|
333
|
+
2. Add **WWebJS API** node with **Message → Forward**
|
|
334
|
+
3. Use `{{ $json.data.id._serialized }}` for Message ID
|
|
335
|
+
4. Set destination Chat ID
|
|
336
|
+
|
|
337
|
+
## Development
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Install dependencies
|
|
341
|
+
npm install
|
|
342
|
+
|
|
343
|
+
# Build
|
|
344
|
+
npm run build
|
|
345
|
+
|
|
346
|
+
# Run tests
|
|
347
|
+
npm test
|
|
348
|
+
|
|
349
|
+
# Watch mode
|
|
350
|
+
npm run dev
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Related Projects
|
|
354
|
+
|
|
355
|
+
- [whatsapp-web.js](https://github.com/pedroslopez/whatsapp-web.js) - The underlying WhatsApp Web client library
|
|
356
|
+
- [wwebjs-api](https://github.com/avoylenko/wwebjs-api) - REST API server that this node connects to
|
|
357
|
+
- [n8n](https://github.com/n8n-io/n8n) - Workflow automation platform
|
|
358
|
+
|
|
359
|
+
## Disclaimer
|
|
360
|
+
|
|
361
|
+
This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.
|
|
362
|
+
|
|
363
|
+
Use this software at your own risk. The authors are not responsible for any bans or restrictions imposed by WhatsApp.
|
|
364
|
+
|
|
365
|
+
## Author
|
|
366
|
+
|
|
367
|
+
**Victor García Pastor** - [@vgpastor](https://github.com/vgpastor)
|
|
368
|
+
|
|
369
|
+
## License
|
|
370
|
+
|
|
371
|
+
Apache-2.0 - See [LICENSE](LICENSE) for details.
|
|
372
|
+
|
|
373
|
+
## Contributing
|
|
374
|
+
|
|
375
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
376
|
+
|
|
377
|
+
1. Fork the repository
|
|
378
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
379
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
380
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
381
|
+
5. Open a Pull Request
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class WWebJsApiCredentials implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
authenticate: IAuthenticateGeneric;
|
|
8
|
+
test: ICredentialTestRequest;
|
|
9
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WWebJsApiCredentials = void 0;
|
|
4
|
+
class WWebJsApiCredentials {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'wWebJsApi';
|
|
7
|
+
this.displayName = 'WWebJS API';
|
|
8
|
+
this.documentationUrl = 'https://github.com/avoylenko/wwebjs-api';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Base URL',
|
|
12
|
+
name: 'baseUrl',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: 'http://localhost:3000',
|
|
15
|
+
placeholder: 'http://localhost:3000',
|
|
16
|
+
description: 'The base URL of your WWebJS API instance',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'API Key',
|
|
21
|
+
name: 'apiKey',
|
|
22
|
+
type: 'string',
|
|
23
|
+
typeOptions: { password: true },
|
|
24
|
+
default: '',
|
|
25
|
+
description: 'The API key configured in the API_KEY environment variable of your WWebJS API instance. Leave empty if not set.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Default Session ID',
|
|
29
|
+
name: 'defaultSessionId',
|
|
30
|
+
type: 'string',
|
|
31
|
+
default: '',
|
|
32
|
+
placeholder: 'my-session',
|
|
33
|
+
description: 'Default session ID to use when not specified in the node. Alphanumeric and hyphens allowed.',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
this.authenticate = {
|
|
37
|
+
type: 'generic',
|
|
38
|
+
properties: {
|
|
39
|
+
headers: {
|
|
40
|
+
'x-api-key': '={{$credentials.apiKey}}',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
this.test = {
|
|
45
|
+
request: {
|
|
46
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
47
|
+
url: '/ping',
|
|
48
|
+
method: 'GET',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.WWebJsApiCredentials = WWebJsApiCredentials;
|
|
54
|
+
//# sourceMappingURL=WWebJsApiCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WWebJsApiCredentials.js","sourceRoot":"","sources":["../../credentials/WWebJsApiCredentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,oBAAoB;IAAjC;QACC,SAAI,GAAG,WAAW,CAAC;QACnB,gBAAW,GAAG,YAAY,CAAC;QAC3B,qBAAgB,GAAG,yCAAyC,CAAC;QAE7D,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,uBAAuB;gBACpC,WAAW,EAAE,0CAA0C;gBACvD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,iHAAiH;aAC9H;YACD;gBACC,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,YAAY;gBACzB,WAAW,EAAE,6FAA6F;aAC1G;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,WAAW,EAAE,0BAA0B;iBACvC;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,OAAO;gBACZ,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AAjDD,oDAiDC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class WWebJsApi implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|