@raevon/n8n-nodes-whatsapp 1.0.2 → 1.0.3
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.
|
@@ -17,7 +17,7 @@ class WhatsAppApi {
|
|
|
17
17
|
type: 'string',
|
|
18
18
|
default: '~/.n8n/whatsapp-auth',
|
|
19
19
|
required: true,
|
|
20
|
-
description: 'Directory path where WhatsApp session files are stored. After first QR scan, session persists here.',
|
|
20
|
+
description: 'Directory path where WhatsApp session files are stored. After first QR scan, session persists here. Use the "WhatsApp Connect" node to scan QR on first setup.',
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
displayName: 'QR Server Port',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { WhatsAppSend } from './nodes/WhatsApp/WhatsAppSend.node';
|
|
2
2
|
export { WhatsAppTrigger } from './nodes/WhatsApp/WhatsAppTrigger.node';
|
|
3
|
+
export { WhatsAppConnect } from './nodes/WhatsApp/WhatsAppConnect.node';
|
|
3
4
|
export { WhatsAppApi } from './credentials/WhatsAppApi.credentials';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WhatsAppApi = exports.WhatsAppTrigger = exports.WhatsAppSend = void 0;
|
|
3
|
+
exports.WhatsAppApi = exports.WhatsAppConnect = exports.WhatsAppTrigger = exports.WhatsAppSend = void 0;
|
|
4
4
|
var WhatsAppSend_node_1 = require("./nodes/WhatsApp/WhatsAppSend.node");
|
|
5
5
|
Object.defineProperty(exports, "WhatsAppSend", { enumerable: true, get: function () { return WhatsAppSend_node_1.WhatsAppSend; } });
|
|
6
6
|
var WhatsAppTrigger_node_1 = require("./nodes/WhatsApp/WhatsAppTrigger.node");
|
|
7
7
|
Object.defineProperty(exports, "WhatsAppTrigger", { enumerable: true, get: function () { return WhatsAppTrigger_node_1.WhatsAppTrigger; } });
|
|
8
|
+
var WhatsAppConnect_node_1 = require("./nodes/WhatsApp/WhatsAppConnect.node");
|
|
9
|
+
Object.defineProperty(exports, "WhatsAppConnect", { enumerable: true, get: function () { return WhatsAppConnect_node_1.WhatsAppConnect; } });
|
|
8
10
|
var WhatsAppApi_credentials_1 = require("./credentials/WhatsAppApi.credentials");
|
|
9
11
|
Object.defineProperty(exports, "WhatsAppApi", { enumerable: true, get: function () { return WhatsAppApi_credentials_1.WhatsAppApi; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class WhatsAppConnect implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsAppConnect = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const WhatsAppApiHelper_1 = require("./WhatsAppApiHelper");
|
|
6
|
+
class WhatsAppConnect {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.description = {
|
|
9
|
+
displayName: 'WhatsApp Connect',
|
|
10
|
+
name: 'whatsAppConnect',
|
|
11
|
+
icon: 'file:icons/whatsapp.svg',
|
|
12
|
+
group: ['transform'],
|
|
13
|
+
version: 1,
|
|
14
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
15
|
+
description: 'Connect to WhatsApp — scan QR code on first run, then reconnects automatically',
|
|
16
|
+
defaults: { name: 'WhatsApp Connect' },
|
|
17
|
+
inputs: ['main'],
|
|
18
|
+
outputs: ['main'],
|
|
19
|
+
credentials: [{ name: 'whatsappApi', required: true }],
|
|
20
|
+
properties: [
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Operation',
|
|
23
|
+
name: 'operation',
|
|
24
|
+
type: 'options',
|
|
25
|
+
noDataExpression: true,
|
|
26
|
+
options: [
|
|
27
|
+
{ name: 'Connect', value: 'connect', description: 'Connect to WhatsApp (scan QR on first run)', action: 'Connect to WhatsApp' },
|
|
28
|
+
{ name: 'Get Status', value: 'status', description: 'Get current connection status', action: 'Get connection status' },
|
|
29
|
+
],
|
|
30
|
+
default: 'connect',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async execute() {
|
|
36
|
+
const items = this.getInputData();
|
|
37
|
+
const returnData = [];
|
|
38
|
+
const credentials = await this.getCredentials('whatsappApi');
|
|
39
|
+
const cfg = await (0, WhatsAppApiHelper_1.getWhatsAppCredentials)(credentials);
|
|
40
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
41
|
+
for (let i = 0; i < items.length; i++) {
|
|
42
|
+
try {
|
|
43
|
+
if (operation === 'connect') {
|
|
44
|
+
// Connect to WhatsApp — this triggers QR flow on first run
|
|
45
|
+
const sock = await (0, WhatsAppApiHelper_1.ensureConnected)(cfg);
|
|
46
|
+
const status = (0, WhatsAppApiHelper_1.getConnectionStatus)();
|
|
47
|
+
returnData.push({
|
|
48
|
+
json: {
|
|
49
|
+
success: true,
|
|
50
|
+
status: status.status,
|
|
51
|
+
connected: status.connected,
|
|
52
|
+
message: status.connected
|
|
53
|
+
? 'WhatsApp connected successfully'
|
|
54
|
+
: `QR code ready — open http://localhost:${cfg.qrPort}/qr in your browser to scan`,
|
|
55
|
+
qrUrl: status.qrAvailable ? `http://localhost:${cfg.qrPort}/qr` : null,
|
|
56
|
+
sessionPath: cfg.sessionPath,
|
|
57
|
+
},
|
|
58
|
+
pairedItem: { item: i },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (operation === 'status') {
|
|
62
|
+
const status = (0, WhatsAppApiHelper_1.getConnectionStatus)();
|
|
63
|
+
returnData.push({
|
|
64
|
+
json: {
|
|
65
|
+
...status,
|
|
66
|
+
sessionPath: cfg.sessionPath,
|
|
67
|
+
},
|
|
68
|
+
pairedItem: { item: i },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (this.continueOnFail()) {
|
|
74
|
+
returnData.push({
|
|
75
|
+
json: {
|
|
76
|
+
error: error.message,
|
|
77
|
+
success: false,
|
|
78
|
+
},
|
|
79
|
+
pairedItem: { item: i },
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return [returnData];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.WhatsAppConnect = WhatsAppConnect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raevon/n8n-nodes-whatsapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "n8n community node for WhatsApp — send and receive messages with anti-ban protection via the Baileys library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
],
|
|
31
31
|
"nodes": [
|
|
32
32
|
"dist/nodes/WhatsApp/WhatsAppSend.node.js",
|
|
33
|
-
"dist/nodes/WhatsApp/WhatsAppTrigger.node.js"
|
|
33
|
+
"dist/nodes/WhatsApp/WhatsAppTrigger.node.js",
|
|
34
|
+
"dist/nodes/WhatsApp/WhatsAppConnect.node.js"
|
|
34
35
|
]
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|