n8n-nodes-whatsapp-retentionstack 0.3.2 → 0.3.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.
package/README.md
CHANGED
|
@@ -146,6 +146,10 @@ npm link # then in ~/.n8n/nodes: npm link n8n-nodes-whatsapp-retentionsta
|
|
|
146
146
|
|
|
147
147
|
MIT © Retention Stack
|
|
148
148
|
|
|
149
|
+
## Using the trigger on your own computer
|
|
150
|
+
|
|
151
|
+
The trigger gives WhatsApp's servers an address to send incoming messages to. `localhost` and other private addresses can't be reached from the internet, so activating the workflow fails with "WhatsApp cannot reach this n8n". Expose n8n through a tunnel (ngrok or Cloudflare Tunnel, for example), set the `WEBHOOK_URL` environment variable to the tunnel's public address, and activate the workflow again. Sending messages works on any machine.
|
|
152
|
+
|
|
149
153
|
## Workflow templates
|
|
150
154
|
|
|
151
155
|
Import these from **Workflows → Import from file**, then select your WhatsApp credential in each WhatsApp node:
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
/** True for addresses WhatsApp's servers cannot reach: localhost, private ranges, .local names. */
|
|
3
|
+
export declare const isLocalAddress: (url: string) => boolean;
|
|
2
4
|
export declare class WhatsAppRetentionStackTrigger implements INodeType {
|
|
3
5
|
description: INodeTypeDescription;
|
|
4
6
|
webhookMethods: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WhatsAppRetentionStackTrigger = void 0;
|
|
3
|
+
exports.WhatsAppRetentionStackTrigger = exports.isLocalAddress = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
5
|
const WhatsAppRetentionStackApi_credentials_1 = require("../../credentials/WhatsAppRetentionStackApi.credentials");
|
|
6
6
|
const EVENTS = [
|
|
@@ -14,6 +14,23 @@ const EVENTS = [
|
|
|
14
14
|
{ name: 'Group Leave', value: 'group.leave' },
|
|
15
15
|
{ name: 'Session Status', value: 'session.status', description: 'Session connected, disconnected, or other state changes' },
|
|
16
16
|
];
|
|
17
|
+
/** True for addresses WhatsApp's servers cannot reach: localhost, private ranges, .local names. */
|
|
18
|
+
const isLocalAddress = (url) => {
|
|
19
|
+
let host;
|
|
20
|
+
try {
|
|
21
|
+
host = new URL(url).hostname;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return (host === 'localhost' ||
|
|
27
|
+
/\.(localhost|local|internal)$/i.test(host) ||
|
|
28
|
+
/^(127|10|0)\./.test(host) ||
|
|
29
|
+
/^192\.168\./.test(host) ||
|
|
30
|
+
/^172\.(1[6-9]|2\d|3[01])\./.test(host) ||
|
|
31
|
+
host === '[::1]');
|
|
32
|
+
};
|
|
33
|
+
exports.isLocalAddress = isLocalAddress;
|
|
17
34
|
class WhatsAppRetentionStackTrigger {
|
|
18
35
|
constructor() {
|
|
19
36
|
this.description = {
|
|
@@ -72,6 +89,11 @@ class WhatsAppRetentionStackTrigger {
|
|
|
72
89
|
const url = this.getNodeWebhookUrl('default');
|
|
73
90
|
const session = this.getNodeParameter('session');
|
|
74
91
|
const events = this.getNodeParameter('events');
|
|
92
|
+
if ((0, exports.isLocalAddress)(url)) {
|
|
93
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'WhatsApp cannot reach this n8n at its current address', {
|
|
94
|
+
description: 'Incoming messages are sent from the internet, so a localhost or private address cannot receive them. Expose n8n through a tunnel (for example ngrok or Cloudflare Tunnel) and set the WEBHOOK_URL environment variable to that public address, then activate the workflow again.',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
75
97
|
await this.helpers.httpRequestWithAuthentication.call(this, 'whatsAppRetentionStackApi', {
|
|
76
98
|
method: 'POST',
|
|
77
99
|
url: `${WhatsAppRetentionStackApi_credentials_1.BASE_URL}/v1/sessions/${encodeURIComponent(session)}/webhooks`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-whatsapp-retentionstack",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "n8n nodes for the WhatsApp Messaging API by Retention Stack. Send WhatsApp text, images, files and OTPs, and trigger workflows on incoming messages. No Meta approval needed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|