n8n-nodes-whatsapp-retentionstack 0.1.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 +21 -0
- package/README.md +131 -0
- package/dist/credentials/WhatsAppRetentionStackApi.credentials.d.ts +11 -0
- package/dist/credentials/WhatsAppRetentionStackApi.credentials.js +35 -0
- package/dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStack.node.d.ts +4 -0
- package/dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStack.node.js +336 -0
- package/dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStackTrigger.node.d.ts +12 -0
- package/dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStackTrigger.node.js +103 -0
- package/dist/nodes/WhatsAppRetentionStack/endpoints.d.ts +1 -0
- package/dist/nodes/WhatsAppRetentionStack/endpoints.js +67 -0
- package/dist/nodes/WhatsAppRetentionStack/whatsapp.svg +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Retention Stack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# n8n-nodes-whatsapp-retentionstack
|
|
2
|
+
|
|
3
|
+
n8n community nodes for the [WhatsApp Messaging API by Retention Stack](https://whatsapp-messaging.retentionstack.agency).
|
|
4
|
+
Send WhatsApp text, images, files, videos, locations and OTPs from any workflow, and trigger workflows on incoming messages.
|
|
5
|
+
|
|
6
|
+
No Meta approval queue. No WhatsApp Business account. 5 minutes from subscribe to first message.
|
|
7
|
+
|
|
8
|
+
## Nodes
|
|
9
|
+
|
|
10
|
+
**WhatsApp by Retention Stack** (action)
|
|
11
|
+
|
|
12
|
+
| Resource | Operations |
|
|
13
|
+
|---|---|
|
|
14
|
+
| Message | Send Text, Image, File, Video, Voice, Location, Contact, Poll · Reply · React · Star · Mark as Seen · Start/Stop Typing · Get Many |
|
|
15
|
+
| Session | Get, Get Many, Get Me, Start, Stop, Logout, Delete · Get QR Code (base64 or PNG binary) · Request Pairing Code · Set/Get Presence · Chat Presence |
|
|
16
|
+
| Group | Create, Get, Get Many, Count, Join, Leave, Delete, Refresh · Subject, Description, Picture · Participants add/remove, Promote/Demote admins · Admin-only settings · Invite code get/revoke |
|
|
17
|
+
| Channel | Create, Get, Get Many, Delete, Get Preview Messages |
|
|
18
|
+
| Contact | Check Exists |
|
|
19
|
+
|
|
20
|
+
Media can be sent from a public URL or as base64 data. Participant and contact lists take comma-separated phone numbers.
|
|
21
|
+
|
|
22
|
+
**WhatsApp by Retention Stack Trigger**
|
|
23
|
+
|
|
24
|
+
Fires on `message`, `message.any`, `message.ack`, `message.reaction`, `message.edited`, `message.revoked`, `group.join`, `group.leave`, `session.status`. The webhook is registered on activation and removed on deactivation.
|
|
25
|
+
|
|
26
|
+
## Node to API mapping
|
|
27
|
+
|
|
28
|
+
Dropdown labels follow n8n conventions (for example "Get Many"). The action text shown in the node picker is the name used in the [API docs](https://whatsapp-messaging.retentionstack.agency/docs), and each operation's tooltip shows the endpoint.
|
|
29
|
+
|
|
30
|
+
<!-- api-map:start -->
|
|
31
|
+
| Resource | Operation | API docs name | Endpoint |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| Message | Get Many | Get messages | `GET /v1/messages` |
|
|
34
|
+
| Message | Mark as Seen | Mark message as seen | `POST /v1/sendSeen` |
|
|
35
|
+
| Message | React | Set message reaction | `PUT /v1/reaction` |
|
|
36
|
+
| Message | Reply | Reply to message | `POST /v1/reply` |
|
|
37
|
+
| Message | Send Contact | Send contact vCard | `POST /v1/sendContactVcard` |
|
|
38
|
+
| Message | Send File | Send file | `POST /v1/sendFile` |
|
|
39
|
+
| Message | Send Image | Send image | `POST /v1/sendImage` |
|
|
40
|
+
| Message | Send Location | Send location | `POST /v1/sendLocation` |
|
|
41
|
+
| Message | Send Poll | Send poll | `POST /v1/sendPoll` |
|
|
42
|
+
| Message | Send Text | Send text message | `POST /v1/sendText` |
|
|
43
|
+
| Message | Send Video | Send video | `POST /v1/sendVideo` |
|
|
44
|
+
| Message | Send Voice | Send voice message | `POST /v1/sendVoice` |
|
|
45
|
+
| Message | Star | Star or unstar message | `PUT /v1/star` |
|
|
46
|
+
| Message | Start Typing | Start typing indicator | `POST /v1/startTyping` |
|
|
47
|
+
| Message | Stop Typing | Stop typing indicator | `POST /v1/stopTyping` |
|
|
48
|
+
| Session | Delete | Delete session | `DELETE /v1/sessions/{session}` |
|
|
49
|
+
| Session | Get | Get session | `GET /v1/sessions/{session}` |
|
|
50
|
+
| Session | Get Chat Presence | Get chat presence | `GET /v1/sessions/{session}/presence/{chatId}` |
|
|
51
|
+
| Session | Get Many | List sessions | `GET /v1/sessions` |
|
|
52
|
+
| Session | Get Me | Get session me | `GET /v1/sessions/{session}/me` |
|
|
53
|
+
| Session | Get Presence | Get all chats presence | `GET /v1/sessions/{session}/presence` |
|
|
54
|
+
| Session | Get QR Code | Get QR code | `GET /v1/{session}/auth/qr` |
|
|
55
|
+
| Session | Logout | Logout session | `POST /v1/sessions/logout` |
|
|
56
|
+
| Session | Request Pairing Code | Request pairing code | `POST /v1/{session}/auth/pairing-code` |
|
|
57
|
+
| Session | Set Presence | Set presence | `POST /v1/sessions/{session}/presence` |
|
|
58
|
+
| Session | Start | Start session | `POST /v1/sessions/start` |
|
|
59
|
+
| Session | Stop | Stop session | `POST /v1/sessions/stop` |
|
|
60
|
+
| Session | Subscribe Chat Presence | Subscribe to chat presence | `POST /v1/sessions/{session}/presence/{chatId}/subscribe` |
|
|
61
|
+
| Group | Add Participants | Add participants | `POST /v1/sessions/{session}/groups/{groupId}/participants/add` |
|
|
62
|
+
| Group | Count | Get groups count | `GET /v1/sessions/{session}/groups/count` |
|
|
63
|
+
| Group | Create | Create group | `POST /v1/sessions/{session}/groups` |
|
|
64
|
+
| Group | Delete | Delete group | `DELETE /v1/sessions/{session}/groups/{groupId}` |
|
|
65
|
+
| Group | Delete Picture | Delete group picture | `DELETE /v1/sessions/{session}/groups/{groupId}/picture` |
|
|
66
|
+
| Group | Demote From Admin | Demote from admin | `POST /v1/sessions/{session}/groups/{groupId}/admin/demote` |
|
|
67
|
+
| Group | Get | Get group | `GET /v1/sessions/{session}/groups/{groupId}` |
|
|
68
|
+
| Group | Get Info Admin Only | Get info admin-only setting | `GET /v1/sessions/{session}/groups/{groupId}/settings/security/info-admin-only` |
|
|
69
|
+
| Group | Get Invite Code | Get invite code | `GET /v1/sessions/{session}/groups/{groupId}/invite-code` |
|
|
70
|
+
| Group | Get Many | List groups (paginated, excludes participants) | `GET /v1/sessions/{session}/groups` |
|
|
71
|
+
| Group | Get Messages Admin Only | Get messages admin-only setting | `GET /v1/sessions/{session}/groups/{groupId}/settings/security/messages-admin-only` |
|
|
72
|
+
| Group | Get Participants | Get participants | `GET /v1/sessions/{session}/groups/{groupId}/participants` |
|
|
73
|
+
| Group | Get Picture | Get group picture | `GET /v1/sessions/{session}/groups/{groupId}/picture` |
|
|
74
|
+
| Group | Join | Join group | `POST /v1/sessions/{session}/groups/join` |
|
|
75
|
+
| Group | Leave | Leave group | `POST /v1/sessions/{session}/groups/{groupId}/leave` |
|
|
76
|
+
| Group | Promote to Admin | Promote to admin | `POST /v1/sessions/{session}/groups/{groupId}/admin/promote` |
|
|
77
|
+
| Group | Refresh | Refresh groups | `POST /v1/sessions/{session}/groups/refresh` |
|
|
78
|
+
| Group | Remove Participants | Remove participants | `POST /v1/sessions/{session}/groups/{groupId}/participants/remove` |
|
|
79
|
+
| Group | Revoke Invite Code | Revoke invite code | `POST /v1/sessions/{session}/groups/{groupId}/invite-code/revoke` |
|
|
80
|
+
| Group | Set Description | Set group description | `PUT /v1/sessions/{session}/groups/{groupId}/description` |
|
|
81
|
+
| Group | Set Info Admin Only | Set info admin-only | `PUT /v1/sessions/{session}/groups/{groupId}/settings/security/info-admin-only` |
|
|
82
|
+
| Group | Set Messages Admin Only | Set messages admin-only | `PUT /v1/sessions/{session}/groups/{groupId}/settings/security/messages-admin-only` |
|
|
83
|
+
| Group | Set Picture | Set group picture | `PUT /v1/sessions/{session}/groups/{groupId}/picture` |
|
|
84
|
+
| Group | Set Subject | Set group subject | `PUT /v1/sessions/{session}/groups/{groupId}/subject` |
|
|
85
|
+
| Channel | Create | Create channel | `POST /v1/sessions/{session}/channels` |
|
|
86
|
+
| Channel | Delete | Delete channel | `DELETE /v1/sessions/{session}/channels/{channelId}` |
|
|
87
|
+
| Channel | Get | Get channel | `GET /v1/sessions/{session}/channels/{channelId}` |
|
|
88
|
+
| Channel | Get Many | List channels | `GET /v1/sessions/{session}/channels` |
|
|
89
|
+
| Channel | Get Preview Messages | Get channel preview messages | `GET /v1/sessions/{session}/channels/{channelId}/messages/preview` |
|
|
90
|
+
| Contact | Check Exists | Check if phone number exists on WhatsApp | `GET /v1/contacts/check-exists` |
|
|
91
|
+
<!-- api-map:end -->
|
|
92
|
+
|
|
93
|
+
## Setup
|
|
94
|
+
|
|
95
|
+
1. Subscribe on RapidAPI (free plan, 100 requests/month, no credit card): [rapidapi.com/jevil257/api/whatsapp-messaging-bot](https://rapidapi.com/jevil257/api/whatsapp-messaging-bot). Copy your `X-RapidAPI-Key`.
|
|
96
|
+
2. Pair your phone once: run **Session → Start**, then **Session → Get QR Code** and scan it in WhatsApp → Linked Devices. Or follow the [getting started guide](https://whatsapp-messaging.retentionstack.agency/docs).
|
|
97
|
+
3. In n8n, add credentials **WhatsApp by Retention Stack API** and paste the key.
|
|
98
|
+
4. Drop the node into a workflow. Session name defaults to `default`.
|
|
99
|
+
|
|
100
|
+
## Install
|
|
101
|
+
|
|
102
|
+
**Self-hosted n8n:** Settings → Community Nodes → Install → `n8n-nodes-whatsapp-retentionstack`.
|
|
103
|
+
|
|
104
|
+
**Docker / manual:**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
cd ~/.n8n/nodes && npm install n8n-nodes-whatsapp-retentionstack
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Example: send an OTP
|
|
111
|
+
|
|
112
|
+
Message → Send Text
|
|
113
|
+
- Chat ID: `{{ $json.phone }}`
|
|
114
|
+
- Text: `Your login code is {{ $json.otp }}. Valid for 5 minutes.`
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm install
|
|
120
|
+
npm test # builds to dist/ and runs the smoke check
|
|
121
|
+
npm run gen # regenerate endpoints.ts and the README table from ../wp-rapidapi/openapi.json
|
|
122
|
+
npm link # then in ~/.n8n/nodes: npm link n8n-nodes-whatsapp-retentionstack
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Links
|
|
126
|
+
|
|
127
|
+
- API docs: https://whatsapp-messaging.retentionstack.agency/docs
|
|
128
|
+
- RapidAPI listing: https://rapidapi.com/jevil257/api/whatsapp-messaging-bot
|
|
129
|
+
- Issues: https://github.com/jevil25/n8n-nodes-whatsapp-retentionstack/issues
|
|
130
|
+
|
|
131
|
+
MIT © Retention Stack
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare const BASE_URL = "https://whatsapp-messaging-bot.p.rapidapi.com";
|
|
3
|
+
export declare const RAPIDAPI_HOST = "whatsapp-messaging-bot.p.rapidapi.com";
|
|
4
|
+
export declare class WhatsAppRetentionStackApi implements ICredentialType {
|
|
5
|
+
name: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
documentationUrl: string;
|
|
8
|
+
properties: INodeProperties[];
|
|
9
|
+
authenticate: IAuthenticateGeneric;
|
|
10
|
+
test: ICredentialTestRequest;
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsAppRetentionStackApi = exports.RAPIDAPI_HOST = exports.BASE_URL = void 0;
|
|
4
|
+
exports.BASE_URL = 'https://whatsapp-messaging-bot.p.rapidapi.com';
|
|
5
|
+
exports.RAPIDAPI_HOST = 'whatsapp-messaging-bot.p.rapidapi.com';
|
|
6
|
+
class WhatsAppRetentionStackApi {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.name = 'whatsAppRetentionStackApi';
|
|
9
|
+
this.displayName = 'WhatsApp by Retention Stack API';
|
|
10
|
+
this.documentationUrl = 'https://whatsapp-messaging.retentionstack.agency/docs';
|
|
11
|
+
this.properties = [
|
|
12
|
+
{
|
|
13
|
+
displayName: 'RapidAPI Key',
|
|
14
|
+
name: 'apiKey',
|
|
15
|
+
type: 'string',
|
|
16
|
+
typeOptions: { password: true },
|
|
17
|
+
default: '',
|
|
18
|
+
description: 'Your X-RapidAPI-Key. Subscribe (free plan, no credit card) at rapidapi.com/jevil257/api/whatsapp-messaging-bot.',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
this.authenticate = {
|
|
22
|
+
type: 'generic',
|
|
23
|
+
properties: {
|
|
24
|
+
headers: {
|
|
25
|
+
'x-rapidapi-key': '={{$credentials.apiKey}}',
|
|
26
|
+
'x-rapidapi-host': exports.RAPIDAPI_HOST,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
this.test = {
|
|
31
|
+
request: { baseURL: exports.BASE_URL, url: '/v1/sessions' },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.WhatsAppRetentionStackApi = WhatsAppRetentionStackApi;
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsAppRetentionStack = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const WhatsAppRetentionStackApi_credentials_1 = require("../../credentials/WhatsAppRetentionStackApi.credentials");
|
|
6
|
+
const endpoints_1 = require("./endpoints");
|
|
7
|
+
const S = '{{$parameter.session}}';
|
|
8
|
+
const G = `/v1/sessions/${S}/groups/{{$parameter.groupId}}`;
|
|
9
|
+
const C = `/v1/sessions/${S}/channels/{{$parameter.channelId}}`;
|
|
10
|
+
// Dropdown label follows n8n conventions ("Get Many"); action text is the API docs name
|
|
11
|
+
// (searchable in the node picker) and the description is the endpoint (shown as tooltip).
|
|
12
|
+
const op = (name, value, method, url) => {
|
|
13
|
+
const route = `${method} ${url.replace(/\{\{\$parameter\.(\w+)\}\}/g, '{$1}')}`;
|
|
14
|
+
const action = endpoints_1.ENDPOINTS[route];
|
|
15
|
+
if (!action)
|
|
16
|
+
throw new Error(`No summary in openapi.json for ${route}; run npm run gen`);
|
|
17
|
+
return { name, value, action, description: route, routing: { request: { method, url: url.includes('{{') ? `=${url}` : url } } };
|
|
18
|
+
};
|
|
19
|
+
const show = (resource, operation) => ({
|
|
20
|
+
displayOptions: { show: { resource: [resource], ...(operation ? { operation } : {}) } },
|
|
21
|
+
});
|
|
22
|
+
const body = (property) => ({ routing: { send: { type: 'body', property } } });
|
|
23
|
+
const query = (property) => ({ routing: { send: { type: 'query', property } } });
|
|
24
|
+
// comma-separated text → array; `ids` wraps each as {id: "<number>@c.us"} for participant endpoints
|
|
25
|
+
const CSV = '$value.split(",").map(s => s.trim()).filter(Boolean)';
|
|
26
|
+
const csv = (property, ids = false) => ({
|
|
27
|
+
routing: {
|
|
28
|
+
send: {
|
|
29
|
+
type: 'body',
|
|
30
|
+
property,
|
|
31
|
+
value: ids ? `={{ ${CSV}.map(id => ({ id: id.includes("@") ? id : id + "@c.us" })) }}` : `={{ ${CSV} }}`,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
const operation = (resource, options, def) => ({
|
|
36
|
+
displayName: 'Operation',
|
|
37
|
+
name: 'operation',
|
|
38
|
+
type: 'options',
|
|
39
|
+
noDataExpression: true,
|
|
40
|
+
...show(resource),
|
|
41
|
+
options,
|
|
42
|
+
default: def,
|
|
43
|
+
});
|
|
44
|
+
const str = (displayName, name, resource, ops, extra = {}) => ({
|
|
45
|
+
displayName,
|
|
46
|
+
name,
|
|
47
|
+
type: 'string',
|
|
48
|
+
default: '',
|
|
49
|
+
...show(resource, ops),
|
|
50
|
+
...extra,
|
|
51
|
+
});
|
|
52
|
+
const session = (resource, ops, routing = {}) => str('Session', 'session', resource, ops, { default: 'default', required: true, description: 'Name of the connected WhatsApp session (the number you paired)', ...routing });
|
|
53
|
+
const chatId = (resource, ops, routing = body('chatId')) => str('Chat ID', 'chatId', resource, ops, { required: true, placeholder: '1234567890', description: 'Phone number with country code (no +), or a group/channel ID', ...routing });
|
|
54
|
+
const groupId = (ops) => str('Group ID', 'groupId', 'group', ops, { required: true, placeholder: '120363012345678901@g.us' });
|
|
55
|
+
const extra = (resource, ops, options) => ({
|
|
56
|
+
displayName: 'Additional Fields',
|
|
57
|
+
name: 'additionalFields',
|
|
58
|
+
type: 'collection',
|
|
59
|
+
placeholder: 'Add Field',
|
|
60
|
+
default: {},
|
|
61
|
+
...show(resource, ops),
|
|
62
|
+
options,
|
|
63
|
+
});
|
|
64
|
+
const replyTo = { displayName: 'Reply To Message ID', name: 'reply_to', type: 'string', default: '', ...body('reply_to') };
|
|
65
|
+
const mentions = { displayName: 'Mentions', name: 'mentions', type: 'string', default: '', description: 'Comma-separated contact IDs to mention', ...csv('mentions') };
|
|
66
|
+
// ── Message ──────────────────────────────────────────────────────────────
|
|
67
|
+
const MEDIA = ['sendImage', 'sendFile', 'sendVideo', 'sendVoice'];
|
|
68
|
+
const MSG_BODY_SESSION = ['sendText', ...MEDIA, 'sendLocation', 'sendContactVcard', 'sendPoll', 'reply', 'reaction', 'star', 'sendSeen', 'startTyping', 'stopTyping'];
|
|
69
|
+
const message = [
|
|
70
|
+
operation('message', [
|
|
71
|
+
op('Get Many', 'getMany', 'GET', '/v1/messages'),
|
|
72
|
+
op('Mark as Seen', 'sendSeen', 'POST', '/v1/sendSeen'),
|
|
73
|
+
op('React', 'reaction', 'PUT', '/v1/reaction'),
|
|
74
|
+
op('Reply', 'reply', 'POST', '/v1/reply'),
|
|
75
|
+
op('Send Contact', 'sendContactVcard', 'POST', '/v1/sendContactVcard'),
|
|
76
|
+
op('Send File', 'sendFile', 'POST', '/v1/sendFile'),
|
|
77
|
+
op('Send Image', 'sendImage', 'POST', '/v1/sendImage'),
|
|
78
|
+
op('Send Location', 'sendLocation', 'POST', '/v1/sendLocation'),
|
|
79
|
+
op('Send Poll', 'sendPoll', 'POST', '/v1/sendPoll'),
|
|
80
|
+
op('Send Text', 'sendText', 'POST', '/v1/sendText'),
|
|
81
|
+
op('Send Video', 'sendVideo', 'POST', '/v1/sendVideo'),
|
|
82
|
+
op('Send Voice', 'sendVoice', 'POST', '/v1/sendVoice'),
|
|
83
|
+
op('Star', 'star', 'PUT', '/v1/star'),
|
|
84
|
+
op('Start Typing', 'startTyping', 'POST', '/v1/startTyping'),
|
|
85
|
+
op('Stop Typing', 'stopTyping', 'POST', '/v1/stopTyping'),
|
|
86
|
+
], 'sendText'),
|
|
87
|
+
session('message', MSG_BODY_SESSION, body('session')),
|
|
88
|
+
session('message', ['getMany'], query('session')),
|
|
89
|
+
chatId('message', ['sendText', ...MEDIA, 'sendLocation', 'sendContactVcard', 'sendPoll', 'reply', 'sendSeen', 'startTyping', 'stopTyping']),
|
|
90
|
+
chatId('message', ['getMany'], query('chatId')),
|
|
91
|
+
str('Text', 'text', 'message', ['sendText', 'reply'], { required: true, typeOptions: { rows: 3 }, ...body('text') }),
|
|
92
|
+
str('Reply To Message ID', 'replyTo', 'message', ['reply'], { required: true, ...body('reply_to') }),
|
|
93
|
+
str('Message ID', 'messageId', 'message', ['reaction', 'star'], { required: true, ...body('messageId') }),
|
|
94
|
+
str('Reaction', 'reaction', 'message', ['reaction'], { required: true, placeholder: '👍', description: 'Emoji to react with. Leave empty to remove the reaction.', ...body('reaction') }),
|
|
95
|
+
{ displayName: 'Star', name: 'star', type: 'boolean', default: true, ...show('message', ['star']), ...body('star') },
|
|
96
|
+
// media
|
|
97
|
+
{
|
|
98
|
+
displayName: 'File Source',
|
|
99
|
+
name: 'fileSource',
|
|
100
|
+
type: 'options',
|
|
101
|
+
options: [
|
|
102
|
+
{ name: 'URL', value: 'url' },
|
|
103
|
+
{ name: 'Base64', value: 'base64' },
|
|
104
|
+
],
|
|
105
|
+
default: 'url',
|
|
106
|
+
...show('message', MEDIA),
|
|
107
|
+
},
|
|
108
|
+
str('File URL', 'fileUrl', 'message', MEDIA, {
|
|
109
|
+
required: true,
|
|
110
|
+
placeholder: 'https://example.com/photo.jpg',
|
|
111
|
+
description: 'Public URL the API downloads the file from',
|
|
112
|
+
displayOptions: { show: { resource: ['message'], operation: MEDIA, fileSource: ['url'] } },
|
|
113
|
+
...body('file.url'),
|
|
114
|
+
}),
|
|
115
|
+
str('File Data (Base64)', 'fileData', 'message', MEDIA, {
|
|
116
|
+
required: true,
|
|
117
|
+
description: 'Base64-encoded file contents',
|
|
118
|
+
displayOptions: { show: { resource: ['message'], operation: MEDIA, fileSource: ['base64'] } },
|
|
119
|
+
...body('file.data'),
|
|
120
|
+
}),
|
|
121
|
+
str('MIME Type', 'mimetype', 'message', MEDIA, {
|
|
122
|
+
required: true,
|
|
123
|
+
placeholder: 'image/jpeg',
|
|
124
|
+
displayOptions: { show: { resource: ['message'], operation: MEDIA, fileSource: ['base64'] } },
|
|
125
|
+
...body('file.mimetype'),
|
|
126
|
+
}),
|
|
127
|
+
str('Caption', 'caption', 'message', ['sendImage', 'sendFile', 'sendVideo'], body('caption')),
|
|
128
|
+
// location / contact / poll
|
|
129
|
+
{ displayName: 'Latitude', name: 'latitude', type: 'number', default: 0, required: true, ...show('message', ['sendLocation']), ...body('latitude') },
|
|
130
|
+
{ displayName: 'Longitude', name: 'longitude', type: 'number', default: 0, required: true, ...show('message', ['sendLocation']), ...body('longitude') },
|
|
131
|
+
str('Contact IDs', 'contactsId', 'message', ['sendContactVcard'], { required: true, placeholder: '1234567890@c.us, 0987654321@c.us', description: 'Comma-separated contact IDs to share as vCards', ...csv('contactsId') }),
|
|
132
|
+
str('Question', 'pollName', 'message', ['sendPoll'], { required: true, ...body('poll.name') }),
|
|
133
|
+
str('Options', 'pollOptions', 'message', ['sendPoll'], { required: true, placeholder: 'Yes, No, Maybe', description: 'Comma-separated poll options (2 to 12)', ...csv('poll.options') }),
|
|
134
|
+
{ displayName: 'Allow Multiple Answers', name: 'multipleAnswers', type: 'boolean', default: false, ...show('message', ['sendPoll']), ...body('poll.multipleAnswers') },
|
|
135
|
+
// get many
|
|
136
|
+
{ displayName: 'Limit', name: 'limit', type: 'number', default: 100, typeOptions: { minValue: 1 }, description: 'Max number of results to return', ...show('message', ['getMany']), ...query('limit') },
|
|
137
|
+
{ displayName: 'Download Media', name: 'downloadMedia', type: 'boolean', default: false, ...show('message', ['getMany']), ...query('downloadMedia') },
|
|
138
|
+
// additional fields, scoped so nothing unsupported is sent
|
|
139
|
+
extra('message', ['sendText'], [
|
|
140
|
+
{ displayName: 'Link Preview', name: 'linkPreview', type: 'boolean', default: true, ...body('linkPreview') },
|
|
141
|
+
{ displayName: 'Link Preview High Quality', name: 'linkPreviewHighQuality', type: 'boolean', default: false, ...body('linkPreviewHighQuality') },
|
|
142
|
+
mentions,
|
|
143
|
+
replyTo,
|
|
144
|
+
]),
|
|
145
|
+
extra('message', ['sendImage', 'sendFile', 'sendVideo'], [
|
|
146
|
+
{ displayName: 'Filename', name: 'filename', type: 'string', default: '', ...body('file.filename') },
|
|
147
|
+
mentions,
|
|
148
|
+
{ displayName: 'MIME Type', name: 'mimetypeUrl', type: 'string', default: '', placeholder: 'image/jpeg', ...body('file.mimetype') },
|
|
149
|
+
replyTo,
|
|
150
|
+
]),
|
|
151
|
+
extra('message', ['sendVoice'], [
|
|
152
|
+
{ displayName: 'Filename', name: 'filename', type: 'string', default: '', ...body('file.filename') },
|
|
153
|
+
{ displayName: 'MIME Type', name: 'mimetypeUrl', type: 'string', default: '', placeholder: 'audio/ogg; codecs=opus', ...body('file.mimetype') },
|
|
154
|
+
replyTo,
|
|
155
|
+
]),
|
|
156
|
+
extra('message', ['sendLocation'], [replyTo, { displayName: 'Title', name: 'title', type: 'string', default: '', ...body('title') }]),
|
|
157
|
+
extra('message', ['sendContactVcard', 'sendPoll'], [replyTo]),
|
|
158
|
+
extra('message', ['reply'], [mentions]),
|
|
159
|
+
extra('message', ['sendSeen'], [{ displayName: 'Message ID', name: 'messageId', type: 'string', default: '', ...body('messageId') }]),
|
|
160
|
+
];
|
|
161
|
+
// ── Session ──────────────────────────────────────────────────────────────
|
|
162
|
+
const PRESENCE_CHAT = `/v1/sessions/${S}/presence/{{$parameter.chatId}}`;
|
|
163
|
+
const sessionProps = [
|
|
164
|
+
operation('session', [
|
|
165
|
+
op('Delete', 'delete', 'DELETE', `/v1/sessions/${S}`),
|
|
166
|
+
op('Get', 'get', 'GET', `/v1/sessions/${S}`),
|
|
167
|
+
op('Get Chat Presence', 'getChatPresence', 'GET', PRESENCE_CHAT),
|
|
168
|
+
op('Get Many', 'getMany', 'GET', '/v1/sessions'),
|
|
169
|
+
op('Get Me', 'me', 'GET', `/v1/sessions/${S}/me`),
|
|
170
|
+
op('Get Presence', 'getPresence', 'GET', `/v1/sessions/${S}/presence`),
|
|
171
|
+
op('Get QR Code', 'qr', 'GET', `/v1/${S}/auth/qr`),
|
|
172
|
+
op('Logout', 'logout', 'POST', '/v1/sessions/logout'),
|
|
173
|
+
op('Request Pairing Code', 'pairingCode', 'POST', `/v1/${S}/auth/pairing-code`),
|
|
174
|
+
op('Set Presence', 'setPresence', 'POST', `/v1/sessions/${S}/presence`),
|
|
175
|
+
op('Start', 'start', 'POST', '/v1/sessions/start'),
|
|
176
|
+
op('Stop', 'stop', 'POST', '/v1/sessions/stop'),
|
|
177
|
+
op('Subscribe Chat Presence', 'subscribePresence', 'POST', `${PRESENCE_CHAT}/subscribe`),
|
|
178
|
+
], 'get'),
|
|
179
|
+
session('session', ['delete', 'get', 'getChatPresence', 'me', 'getPresence', 'qr', 'pairingCode', 'subscribePresence']),
|
|
180
|
+
session('session', ['start', 'stop', 'logout'], body('name')),
|
|
181
|
+
session('session', ['setPresence'], body('session')),
|
|
182
|
+
chatId('session', ['getChatPresence', 'subscribePresence'], {}),
|
|
183
|
+
{ displayName: 'Logout', name: 'logout', type: 'boolean', default: false, description: 'Whether to also log out (unpair) when stopping', ...show('session', ['stop']), ...body('logout') },
|
|
184
|
+
str('Phone Number', 'phoneNumber', 'session', ['pairingCode'], { required: true, placeholder: '1234567890', description: 'Number to pair, with country code', ...body('phoneNumber') }),
|
|
185
|
+
{
|
|
186
|
+
displayName: 'Presence',
|
|
187
|
+
name: 'presence',
|
|
188
|
+
type: 'options',
|
|
189
|
+
options: ['online', 'offline', 'typing', 'recording', 'paused'].map((v) => ({ name: v[0].toUpperCase() + v.slice(1), value: v })),
|
|
190
|
+
default: 'online',
|
|
191
|
+
...show('session', ['setPresence']),
|
|
192
|
+
...body('presence'),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
displayName: 'Format',
|
|
196
|
+
name: 'format',
|
|
197
|
+
type: 'options',
|
|
198
|
+
options: [
|
|
199
|
+
{ name: 'Base64 (JSON)', value: 'base64', routing: { request: { qs: { format: 'base64' } } } },
|
|
200
|
+
{
|
|
201
|
+
name: 'Binary (PNG File)',
|
|
202
|
+
value: 'binary',
|
|
203
|
+
routing: {
|
|
204
|
+
request: { qs: { format: 'binary' }, encoding: 'arraybuffer', returnFullResponse: true },
|
|
205
|
+
output: { postReceive: [{ type: 'binaryData', properties: { destinationProperty: 'data' } }] },
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
default: 'base64',
|
|
210
|
+
...show('session', ['qr']),
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
// ── Group ────────────────────────────────────────────────────────────────
|
|
214
|
+
const PARTICIPANT_OPS = ['addParticipants', 'removeParticipants', 'promote', 'demote'];
|
|
215
|
+
const GROUP_ID_OPS = ['get', 'delete', 'leave', 'setSubject', 'setDescription', 'setInfoAdminOnly', 'getInfoAdminOnly', 'setMessagesAdminOnly', 'getMessagesAdminOnly', 'getParticipants', ...PARTICIPANT_OPS, 'getInviteCode', 'revokeInviteCode', 'getPicture', 'setPicture', 'deletePicture'];
|
|
216
|
+
const group = [
|
|
217
|
+
operation('group', [
|
|
218
|
+
op('Add Participants', 'addParticipants', 'POST', `${G}/participants/add`),
|
|
219
|
+
op('Count', 'count', 'GET', `/v1/sessions/${S}/groups/count`),
|
|
220
|
+
op('Create', 'create', 'POST', `/v1/sessions/${S}/groups`),
|
|
221
|
+
op('Delete', 'delete', 'DELETE', G),
|
|
222
|
+
op('Delete Picture', 'deletePicture', 'DELETE', `${G}/picture`),
|
|
223
|
+
op('Demote From Admin', 'demote', 'POST', `${G}/admin/demote`),
|
|
224
|
+
op('Get', 'get', 'GET', G),
|
|
225
|
+
op('Get Info Admin Only', 'getInfoAdminOnly', 'GET', `${G}/settings/security/info-admin-only`),
|
|
226
|
+
op('Get Invite Code', 'getInviteCode', 'GET', `${G}/invite-code`),
|
|
227
|
+
op('Get Many', 'getMany', 'GET', `/v1/sessions/${S}/groups`),
|
|
228
|
+
op('Get Messages Admin Only', 'getMessagesAdminOnly', 'GET', `${G}/settings/security/messages-admin-only`),
|
|
229
|
+
op('Get Participants', 'getParticipants', 'GET', `${G}/participants`),
|
|
230
|
+
op('Get Picture', 'getPicture', 'GET', `${G}/picture`),
|
|
231
|
+
op('Join', 'join', 'POST', `/v1/sessions/${S}/groups/join`),
|
|
232
|
+
op('Leave', 'leave', 'POST', `${G}/leave`),
|
|
233
|
+
op('Promote to Admin', 'promote', 'POST', `${G}/admin/promote`),
|
|
234
|
+
op('Refresh', 'refresh', 'POST', `/v1/sessions/${S}/groups/refresh`),
|
|
235
|
+
op('Remove Participants', 'removeParticipants', 'POST', `${G}/participants/remove`),
|
|
236
|
+
op('Revoke Invite Code', 'revokeInviteCode', 'POST', `${G}/invite-code/revoke`),
|
|
237
|
+
op('Set Description', 'setDescription', 'PUT', `${G}/description`),
|
|
238
|
+
op('Set Info Admin Only', 'setInfoAdminOnly', 'PUT', `${G}/settings/security/info-admin-only`),
|
|
239
|
+
op('Set Messages Admin Only', 'setMessagesAdminOnly', 'PUT', `${G}/settings/security/messages-admin-only`),
|
|
240
|
+
op('Set Picture', 'setPicture', 'PUT', `${G}/picture`),
|
|
241
|
+
op('Set Subject', 'setSubject', 'PUT', `${G}/subject`),
|
|
242
|
+
], 'create'),
|
|
243
|
+
session('group'),
|
|
244
|
+
groupId(GROUP_ID_OPS),
|
|
245
|
+
str('Group Name', 'name', 'group', ['create'], { required: true, ...body('name') }),
|
|
246
|
+
str('Participants', 'participants', 'group', ['create', ...PARTICIPANT_OPS], { required: true, placeholder: '1234567890, 0987654321', description: 'Comma-separated phone numbers or contact IDs', ...csv('participants', true) }),
|
|
247
|
+
str('Description', 'description', 'group', ['create'], body('description')),
|
|
248
|
+
str('Description', 'descriptionSet', 'group', ['setDescription'], { required: true, ...body('description') }),
|
|
249
|
+
str('Subject', 'subject', 'group', ['setSubject'], { required: true, ...body('subject') }),
|
|
250
|
+
str('Invite Code', 'code', 'group', ['join'], { required: true, placeholder: 'AbCdEfGhIjK', description: 'The code from a chat.whatsapp.com invite link', ...body('code') }),
|
|
251
|
+
{ displayName: 'Admins Only', name: 'adminsOnly', type: 'boolean', default: true, ...show('group', ['setInfoAdminOnly', 'setMessagesAdminOnly']), ...body('adminsOnly') },
|
|
252
|
+
str('Picture URL', 'pictureUrl', 'group', ['setPicture'], { required: true, placeholder: 'https://example.com/logo.jpg', ...body('file.url') }),
|
|
253
|
+
str('MIME Type', 'pictureMimetype', 'group', ['setPicture'], { placeholder: 'image/jpeg', ...body('file.mimetype') }),
|
|
254
|
+
{
|
|
255
|
+
displayName: 'Options',
|
|
256
|
+
name: 'options',
|
|
257
|
+
type: 'collection',
|
|
258
|
+
placeholder: 'Add Option',
|
|
259
|
+
default: {},
|
|
260
|
+
...show('group', ['getMany']),
|
|
261
|
+
options: [
|
|
262
|
+
{ displayName: 'Limit', name: 'limit', type: 'number', default: 10, typeOptions: { minValue: 1 }, description: 'Max number of results to return', ...query('limit') },
|
|
263
|
+
{ displayName: 'Offset', name: 'offset', type: 'number', default: 0, ...query('offset') },
|
|
264
|
+
{ displayName: 'Sort By', name: 'sortBy', type: 'options', options: [{ name: 'ID', value: 'id' }, { name: 'Subject', value: 'subject' }], default: 'subject', ...query('sortBy') },
|
|
265
|
+
{ displayName: 'Sort Order', name: 'sortOrder', type: 'options', options: [{ name: 'Ascending', value: 'asc' }, { name: 'Descending', value: 'desc' }], default: 'asc', ...query('sortOrder') },
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
];
|
|
269
|
+
// ── Channel ──────────────────────────────────────────────────────────────
|
|
270
|
+
const channel = [
|
|
271
|
+
operation('channel', [
|
|
272
|
+
op('Create', 'create', 'POST', `/v1/sessions/${S}/channels`),
|
|
273
|
+
op('Delete', 'delete', 'DELETE', C),
|
|
274
|
+
op('Get', 'get', 'GET', C),
|
|
275
|
+
op('Get Many', 'getMany', 'GET', `/v1/sessions/${S}/channels`),
|
|
276
|
+
op('Get Preview Messages', 'preview', 'GET', `${C}/messages/preview`),
|
|
277
|
+
], 'getMany'),
|
|
278
|
+
session('channel'),
|
|
279
|
+
str('Channel ID', 'channelId', 'channel', ['get', 'delete', 'preview'], { required: true, placeholder: '120363012345678901@newsletter' }),
|
|
280
|
+
str('Name', 'name', 'channel', ['create'], { required: true, ...body('name') }),
|
|
281
|
+
str('Description', 'description', 'channel', ['create'], body('description')),
|
|
282
|
+
str('Picture URL', 'pictureUrl', 'channel', ['create'], { placeholder: 'https://example.com/logo.jpg', ...body('picture.url') }),
|
|
283
|
+
str('Picture MIME Type', 'pictureMimetype', 'channel', ['create'], { placeholder: 'image/jpeg', ...body('picture.mimetype') }),
|
|
284
|
+
{ displayName: 'Limit', name: 'limit', type: 'number', default: 50, typeOptions: { minValue: 1 }, description: 'Max number of results to return', ...show('channel', ['preview']), ...query('limit') },
|
|
285
|
+
{ displayName: 'Download Media', name: 'downloadMedia', type: 'boolean', default: false, ...show('channel', ['preview']), ...query('downloadMedia') },
|
|
286
|
+
];
|
|
287
|
+
// ── Contact ──────────────────────────────────────────────────────────────
|
|
288
|
+
const contact = [
|
|
289
|
+
operation('contact', [op('Check Exists', 'checkExists', 'GET', '/v1/contacts/check-exists')], 'checkExists'),
|
|
290
|
+
session('contact', undefined, query('session')),
|
|
291
|
+
str('Phone Number', 'phone', 'contact', ['checkExists'], { required: true, placeholder: '1234567890', ...query('phone') }),
|
|
292
|
+
];
|
|
293
|
+
class WhatsAppRetentionStack {
|
|
294
|
+
constructor() {
|
|
295
|
+
this.description = {
|
|
296
|
+
displayName: 'WhatsApp by Retention Stack',
|
|
297
|
+
name: 'whatsAppRetentionStack',
|
|
298
|
+
icon: 'file:whatsapp.svg',
|
|
299
|
+
group: ['output'],
|
|
300
|
+
version: 1,
|
|
301
|
+
subtitle: '={{ $parameter["operation"] + ": " + $parameter["resource"] }}',
|
|
302
|
+
description: 'Send WhatsApp messages, images, files and OTPs via the Retention Stack REST API. No Meta approval needed.',
|
|
303
|
+
defaults: { name: 'WhatsApp' },
|
|
304
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
305
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
306
|
+
usableAsTool: true,
|
|
307
|
+
credentials: [{ name: 'whatsAppRetentionStackApi', required: true }],
|
|
308
|
+
requestDefaults: {
|
|
309
|
+
baseURL: WhatsAppRetentionStackApi_credentials_1.BASE_URL,
|
|
310
|
+
headers: { Accept: 'application/json', 'Content-Type': 'application/json' },
|
|
311
|
+
},
|
|
312
|
+
properties: [
|
|
313
|
+
{
|
|
314
|
+
displayName: 'Resource',
|
|
315
|
+
name: 'resource',
|
|
316
|
+
type: 'options',
|
|
317
|
+
noDataExpression: true,
|
|
318
|
+
options: [
|
|
319
|
+
{ name: 'Channel', value: 'channel' },
|
|
320
|
+
{ name: 'Contact', value: 'contact' },
|
|
321
|
+
{ name: 'Group', value: 'group' },
|
|
322
|
+
{ name: 'Message', value: 'message' },
|
|
323
|
+
{ name: 'Session', value: 'session' },
|
|
324
|
+
],
|
|
325
|
+
default: 'message',
|
|
326
|
+
},
|
|
327
|
+
...message,
|
|
328
|
+
...sessionProps,
|
|
329
|
+
...group,
|
|
330
|
+
...channel,
|
|
331
|
+
...contact,
|
|
332
|
+
],
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
exports.WhatsAppRetentionStack = WhatsAppRetentionStack;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
export declare class WhatsAppRetentionStackTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
webhookMethods: {
|
|
5
|
+
default: {
|
|
6
|
+
checkExists(this: IHookFunctions): Promise<boolean>;
|
|
7
|
+
create(this: IHookFunctions): Promise<boolean>;
|
|
8
|
+
delete(this: IHookFunctions): Promise<boolean>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhatsAppRetentionStackTrigger = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const WhatsAppRetentionStackApi_credentials_1 = require("../../credentials/WhatsAppRetentionStackApi.credentials");
|
|
6
|
+
const EVENTS = [
|
|
7
|
+
{ name: 'Message Received', value: 'message', description: 'A new incoming message' },
|
|
8
|
+
{ name: 'Any Message', value: 'message.any', description: 'Incoming and outgoing messages' },
|
|
9
|
+
{ name: 'Message Ack', value: 'message.ack', description: 'Sent, delivered or read receipt' },
|
|
10
|
+
{ name: 'Message Reaction', value: 'message.reaction' },
|
|
11
|
+
{ name: 'Message Edited', value: 'message.edited' },
|
|
12
|
+
{ name: 'Message Revoked', value: 'message.revoked' },
|
|
13
|
+
{ name: 'Group Join', value: 'group.join' },
|
|
14
|
+
{ name: 'Group Leave', value: 'group.leave' },
|
|
15
|
+
{ name: 'Session Status', value: 'session.status', description: 'Session connected, disconnected, etc.' },
|
|
16
|
+
];
|
|
17
|
+
class WhatsAppRetentionStackTrigger {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.description = {
|
|
20
|
+
displayName: 'WhatsApp by Retention Stack Trigger',
|
|
21
|
+
name: 'whatsAppRetentionStackTrigger',
|
|
22
|
+
icon: 'file:whatsapp.svg',
|
|
23
|
+
group: ['trigger'],
|
|
24
|
+
version: 1,
|
|
25
|
+
subtitle: '={{ $parameter["events"].join(", ") }}',
|
|
26
|
+
description: 'Starts the workflow when a WhatsApp message or event arrives',
|
|
27
|
+
defaults: { name: 'WhatsApp Trigger' },
|
|
28
|
+
inputs: [],
|
|
29
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
30
|
+
credentials: [{ name: 'whatsAppRetentionStackApi', required: true }],
|
|
31
|
+
webhooks: [{ name: 'default', httpMethod: 'POST', responseMode: 'onReceived', path: 'webhook' }],
|
|
32
|
+
properties: [
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Session',
|
|
35
|
+
name: 'session',
|
|
36
|
+
type: 'string',
|
|
37
|
+
default: 'default',
|
|
38
|
+
required: true,
|
|
39
|
+
description: 'Name of the connected WhatsApp session to listen on',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Events',
|
|
43
|
+
name: 'events',
|
|
44
|
+
type: 'multiOptions',
|
|
45
|
+
options: EVENTS,
|
|
46
|
+
default: ['message'],
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
this.webhookMethods = {
|
|
52
|
+
default: {
|
|
53
|
+
async checkExists() {
|
|
54
|
+
const url = this.getNodeWebhookUrl('default');
|
|
55
|
+
const session = this.getNodeParameter('session');
|
|
56
|
+
try {
|
|
57
|
+
const res = await this.helpers.httpRequestWithAuthentication.call(this, 'whatsAppRetentionStackApi', {
|
|
58
|
+
method: 'GET',
|
|
59
|
+
url: `${WhatsAppRetentionStackApi_credentials_1.BASE_URL}/v1/sessions/${encodeURIComponent(session)}`,
|
|
60
|
+
json: true,
|
|
61
|
+
});
|
|
62
|
+
return JSON.stringify(res).includes(url);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async create() {
|
|
69
|
+
const url = this.getNodeWebhookUrl('default');
|
|
70
|
+
const session = this.getNodeParameter('session');
|
|
71
|
+
const events = this.getNodeParameter('events');
|
|
72
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'whatsAppRetentionStackApi', {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
url: `${WhatsAppRetentionStackApi_credentials_1.BASE_URL}/v1/sessions/${encodeURIComponent(session)}/webhooks`,
|
|
75
|
+
body: { webhookUrl: url, events },
|
|
76
|
+
json: true,
|
|
77
|
+
});
|
|
78
|
+
return true;
|
|
79
|
+
},
|
|
80
|
+
async delete() {
|
|
81
|
+
const url = this.getNodeWebhookUrl('default');
|
|
82
|
+
const session = this.getNodeParameter('session');
|
|
83
|
+
try {
|
|
84
|
+
await this.helpers.httpRequestWithAuthentication.call(this, 'whatsAppRetentionStackApi', {
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
url: `${WhatsAppRetentionStackApi_credentials_1.BASE_URL}/v1/sessions/${encodeURIComponent(session)}/webhooks`,
|
|
87
|
+
body: { webhookUrl: url },
|
|
88
|
+
json: true,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// webhook already gone; nothing to clean up
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async webhook() {
|
|
100
|
+
return { workflowData: [this.helpers.returnJsonArray(this.getBodyData())] };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.WhatsAppRetentionStackTrigger = WhatsAppRetentionStackTrigger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ENDPOINTS: Record<string, string>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENDPOINTS = void 0;
|
|
4
|
+
// Generated by scripts/gen.mjs from openapi.json. Do not edit.
|
|
5
|
+
exports.ENDPOINTS = {
|
|
6
|
+
"POST /v1/sessions": "Create session",
|
|
7
|
+
"GET /v1/sessions": "List sessions",
|
|
8
|
+
"DELETE /v1/sessions/{session}": "Delete session",
|
|
9
|
+
"GET /v1/sessions/{session}": "Get session",
|
|
10
|
+
"GET /v1/sessions/{session}/me": "Get session me",
|
|
11
|
+
"POST /v1/sessions/start": "Start session",
|
|
12
|
+
"POST /v1/sessions/stop": "Stop session",
|
|
13
|
+
"POST /v1/sessions/logout": "Logout session",
|
|
14
|
+
"POST /v1/sessions/{session}/webhooks": "Add session webhook",
|
|
15
|
+
"DELETE /v1/sessions/{session}/webhooks": "Delete session webhook",
|
|
16
|
+
"GET /v1/{session}/auth/qr": "Get QR code",
|
|
17
|
+
"POST /v1/{session}/auth/pairing-code": "Request pairing code",
|
|
18
|
+
"POST /v1/sendText": "Send text message",
|
|
19
|
+
"POST /v1/sendImage": "Send image",
|
|
20
|
+
"POST /v1/sendFile": "Send file",
|
|
21
|
+
"POST /v1/sendVoice": "Send voice message",
|
|
22
|
+
"POST /v1/sendVideo": "Send video",
|
|
23
|
+
"POST /v1/sendLocation": "Send location",
|
|
24
|
+
"POST /v1/sendContactVcard": "Send contact vCard",
|
|
25
|
+
"POST /v1/sendPoll": "Send poll",
|
|
26
|
+
"POST /v1/reply": "Reply to message",
|
|
27
|
+
"POST /v1/sendSeen": "Mark message as seen",
|
|
28
|
+
"POST /v1/startTyping": "Start typing indicator",
|
|
29
|
+
"POST /v1/stopTyping": "Stop typing indicator",
|
|
30
|
+
"PUT /v1/reaction": "Set message reaction",
|
|
31
|
+
"PUT /v1/star": "Star or unstar message",
|
|
32
|
+
"GET /v1/messages": "Get messages",
|
|
33
|
+
"POST /v1/sessions/{session}/presence": "Set presence",
|
|
34
|
+
"GET /v1/sessions/{session}/presence": "Get all chats presence",
|
|
35
|
+
"GET /v1/sessions/{session}/presence/{chatId}": "Get chat presence",
|
|
36
|
+
"POST /v1/sessions/{session}/presence/{chatId}/subscribe": "Subscribe to chat presence",
|
|
37
|
+
"POST /v1/sessions/{session}/groups": "Create group",
|
|
38
|
+
"GET /v1/sessions/{session}/groups": "List groups (paginated, excludes participants)",
|
|
39
|
+
"GET /v1/sessions/{session}/groups/count": "Get groups count",
|
|
40
|
+
"POST /v1/sessions/{session}/groups/join": "Join group",
|
|
41
|
+
"POST /v1/sessions/{session}/groups/refresh": "Refresh groups",
|
|
42
|
+
"GET /v1/sessions/{session}/groups/{groupId}": "Get group",
|
|
43
|
+
"DELETE /v1/sessions/{session}/groups/{groupId}": "Delete group",
|
|
44
|
+
"POST /v1/sessions/{session}/groups/{groupId}/leave": "Leave group",
|
|
45
|
+
"PUT /v1/sessions/{session}/groups/{groupId}/subject": "Set group subject",
|
|
46
|
+
"PUT /v1/sessions/{session}/groups/{groupId}/description": "Set group description",
|
|
47
|
+
"PUT /v1/sessions/{session}/groups/{groupId}/settings/security/info-admin-only": "Set info admin-only",
|
|
48
|
+
"GET /v1/sessions/{session}/groups/{groupId}/settings/security/info-admin-only": "Get info admin-only setting",
|
|
49
|
+
"PUT /v1/sessions/{session}/groups/{groupId}/settings/security/messages-admin-only": "Set messages admin-only",
|
|
50
|
+
"GET /v1/sessions/{session}/groups/{groupId}/settings/security/messages-admin-only": "Get messages admin-only setting",
|
|
51
|
+
"GET /v1/sessions/{session}/groups/{groupId}/participants": "Get participants",
|
|
52
|
+
"POST /v1/sessions/{session}/groups/{groupId}/participants/add": "Add participants",
|
|
53
|
+
"POST /v1/sessions/{session}/groups/{groupId}/participants/remove": "Remove participants",
|
|
54
|
+
"POST /v1/sessions/{session}/groups/{groupId}/admin/promote": "Promote to admin",
|
|
55
|
+
"POST /v1/sessions/{session}/groups/{groupId}/admin/demote": "Demote from admin",
|
|
56
|
+
"GET /v1/sessions/{session}/groups/{groupId}/invite-code": "Get invite code",
|
|
57
|
+
"POST /v1/sessions/{session}/groups/{groupId}/invite-code/revoke": "Revoke invite code",
|
|
58
|
+
"GET /v1/sessions/{session}/groups/{groupId}/picture": "Get group picture",
|
|
59
|
+
"PUT /v1/sessions/{session}/groups/{groupId}/picture": "Set group picture",
|
|
60
|
+
"DELETE /v1/sessions/{session}/groups/{groupId}/picture": "Delete group picture",
|
|
61
|
+
"GET /v1/sessions/{session}/channels": "List channels",
|
|
62
|
+
"POST /v1/sessions/{session}/channels": "Create channel",
|
|
63
|
+
"GET /v1/sessions/{session}/channels/{channelId}": "Get channel",
|
|
64
|
+
"DELETE /v1/sessions/{session}/channels/{channelId}": "Delete channel",
|
|
65
|
+
"GET /v1/sessions/{session}/channels/{channelId}/messages/preview": "Get channel preview messages",
|
|
66
|
+
"GET /v1/contacts/check-exists": "Check if phone number exists on WhatsApp"
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><circle cx="32" cy="32" r="32" fill="#25D366"/><path fill="#fff" d="M35.5 12 20 36h10l-3.5 16L44 28H34z"/></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-whatsapp-retentionstack",
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"n8n",
|
|
8
|
+
"whatsapp",
|
|
9
|
+
"whatsapp-api",
|
|
10
|
+
"messaging",
|
|
11
|
+
"otp",
|
|
12
|
+
"rapidapi"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://whatsapp-messaging.retentionstack.agency",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Retention Stack",
|
|
18
|
+
"email": "jevil257@gmail.com"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/jevil25/n8n-nodes-whatsapp-retentionstack.git"
|
|
23
|
+
},
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rm -rf dist && tsc && cp nodes/WhatsAppRetentionStack/*.svg dist/nodes/WhatsAppRetentionStack/",
|
|
30
|
+
"dev": "tsc --watch",
|
|
31
|
+
"test": "npm run build && node test/smoke.mjs",
|
|
32
|
+
"prepublishOnly": "npm test",
|
|
33
|
+
"gen": "node scripts/gen.mjs"
|
|
34
|
+
},
|
|
35
|
+
"n8n": {
|
|
36
|
+
"n8nNodesApiVersion": 1,
|
|
37
|
+
"credentials": [
|
|
38
|
+
"dist/credentials/WhatsAppRetentionStackApi.credentials.js"
|
|
39
|
+
],
|
|
40
|
+
"nodes": [
|
|
41
|
+
"dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStack.node.js",
|
|
42
|
+
"dist/nodes/WhatsAppRetentionStack/WhatsAppRetentionStackTrigger.node.js"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"n8n-workflow": "*"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.0.0",
|
|
50
|
+
"n8n-workflow": "^2.16.0",
|
|
51
|
+
"typescript": "^5.5.4"
|
|
52
|
+
}
|
|
53
|
+
}
|