n8n-nodes-zalo-user-noti 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Noti VN
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,321 @@
1
+ # n8n-nodes-zalo-user-noti
2
+
3
+ ![Zalo Logo](./nodes/Zalo/zalo.png)
4
+
5
+ Unofficial n8n community node for **Zalo personal account automation** using [zca-js](https://github.com/RFS-ADRENO/zca-js).
6
+
7
+ > ⚠️ **Warning**: Using this node could get your Zalo account locked or banned. Use at your own risk.
8
+
9
+ ## Features
10
+
11
+ ### 📨 Message Operations
12
+ - Send text messages (with quote/reply, mentions)
13
+ - Send links with preview
14
+ - Send voice messages
15
+ - Send video messages
16
+ - Send contact cards
17
+ - Send bank cards
18
+ - Forward messages
19
+ - Delete/Undo messages
20
+ - Add reactions
21
+ - Send typing/seen events
22
+
23
+ ### 👥 Friend Operations
24
+ - Get all friends
25
+ - Get user info
26
+ - Find user by phone number
27
+ - Send/Accept/Cancel friend requests
28
+ - Block/Unblock users
29
+ - Change friend aliases
30
+ - Check last online time
31
+
32
+ ### 👨‍👩‍👧‍👦 Group Operations
33
+ - Create/Manage groups
34
+ - Add/Remove members
35
+ - Add/Remove deputies
36
+ - Block/Unblock members
37
+ - Enable/Disable invite links
38
+ - Join group by link
39
+ - Review pending requests
40
+ - Update group settings
41
+
42
+ ### 🎨 Sticker Operations
43
+ - Search stickers
44
+ - Get sticker details
45
+ - Send stickers
46
+
47
+ ### 📊 Poll Operations
48
+ - Create polls
49
+ - Get poll details
50
+ - Lock polls
51
+
52
+ ### ⏰ Reminder Operations
53
+ - Create/Edit/Remove reminders
54
+ - Get reminder list and responses
55
+
56
+ ### 💬 Conversation Operations
57
+ - Pin/Unpin conversations
58
+ - Hide conversations
59
+ - Mute/Unmute
60
+ - Mark as unread
61
+ - Set auto-delete timer
62
+
63
+ ### 👤 Account Operations
64
+ - Get account info
65
+ - Update profile
66
+ - Change avatar
67
+ - Manage labels
68
+
69
+ ### ⚡ Quick Message & Auto Reply
70
+ - Manage quick messages
71
+ - Create auto-reply rules
72
+
73
+ ### 🛒 Catalog Operations (ZBusiness)
74
+ - Manage catalogs
75
+ - Create/Update/Delete products
76
+
77
+ ### 📡 Trigger Events
78
+ - New message (User/Group)
79
+ - Reactions
80
+ - Message undo/recall
81
+ - Group events (join, leave, kick, etc.)
82
+
83
+ ## Installation
84
+
85
+ ### Cách 1: Cài đặt từ npm (Khuyến nghị)
86
+
87
+ Sau khi publish lên npm, bạn có thể cài đặt qua Community Nodes:
88
+
89
+ 1. Mở n8n → **Settings** → **Community Nodes**
90
+ 2. Click **Install a community node**
91
+ 3. Nhập `n8n-nodes-zalo-user-noti`
92
+ 4. Click **Install**
93
+
94
+ ---
95
+
96
+ ### Cách 2: Cài đặt thủ công (Manual Installation)
97
+
98
+ #### Bước 1: Chuẩn bị thư mục
99
+
100
+ **Trên Linux/macOS:**
101
+ ```bash
102
+ # Tạo thư mục custom nodes nếu chưa có
103
+ mkdir -p ~/.n8n/custom
104
+ ```
105
+
106
+ **Trên Windows:**
107
+ ```powershell
108
+ # Mở PowerShell và chạy
109
+ mkdir $env:USERPROFILE\.n8n\custom
110
+ ```
111
+
112
+ **Nếu dùng Docker:**
113
+ ```bash
114
+ # Tạo thư mục trên host
115
+ mkdir -p /path/to/n8n-data/custom
116
+ ```
117
+
118
+ #### Bước 2: Clone/Download và Build
119
+
120
+ ```bash
121
+ # Clone repository
122
+ git clone https://github.com/notivn/n8n-nodes-zalo-user-noti.git
123
+ cd n8n-nodes-zalo-user-noti
124
+
125
+ # Cài đặt dependencies
126
+ npm install
127
+
128
+ # Build project
129
+ npm run build
130
+ ```
131
+
132
+ #### Bước 3: Copy vào n8n
133
+
134
+ **Trên Linux/macOS:**
135
+ ```bash
136
+ # Copy toàn bộ package (không chỉ dist)
137
+ cp -r . ~/.n8n/custom/n8n-nodes-zalo-user-noti
138
+ ```
139
+
140
+ **Trên Windows:**
141
+ ```powershell
142
+ # Copy toàn bộ folder
143
+ xcopy /E /I . %USERPROFILE%\.n8n\custom\n8n-nodes-zalo-user-noti
144
+ ```
145
+
146
+ **Nếu dùng Docker:** thêm volume mount trong docker-compose.yml:
147
+ ```yaml
148
+ services:
149
+ n8n:
150
+ image: n8nio/n8n
151
+ volumes:
152
+ - /path/to/n8n-data:/home/node/.n8n
153
+ - /path/to/n8n-nodes-zalo-user-noti:/home/node/.n8n/custom/n8n-nodes-zalo-user-noti
154
+ environment:
155
+ - N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
156
+ ```
157
+
158
+ #### Bước 4: Cấu hình n8n để load custom nodes
159
+
160
+ Thêm biến môi trường:
161
+
162
+ **Linux/macOS (~/.bashrc hoặc ~/.zshrc):**
163
+ ```bash
164
+ export N8N_CUSTOM_EXTENSIONS="~/.n8n/custom"
165
+ ```
166
+
167
+ **Windows (Environment Variables):**
168
+ ```
169
+ N8N_CUSTOM_EXTENSIONS=%USERPROFILE%\.n8n\custom
170
+ ```
171
+
172
+ **Docker (docker-compose.yml):**
173
+ ```yaml
174
+ environment:
175
+ - N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/custom
176
+ ```
177
+
178
+ #### Bước 5: Restart n8n
179
+
180
+ ```bash
181
+ # Nếu chạy trực tiếp
182
+ # Ctrl+C để stop, rồi chạy lại
183
+ n8n start
184
+
185
+ # Nếu dùng Docker
186
+ docker-compose restart n8n
187
+
188
+ # Nếu dùng PM2
189
+ pm2 restart n8n
190
+ ```
191
+
192
+ #### Bước 6: Kiểm tra
193
+
194
+ 1. Mở n8n trong browser
195
+ 2. Tạo workflow mới
196
+ 3. Tìm kiếm "Zalo" trong nodes panel
197
+ 4. Bạn sẽ thấy **Zalo User** và **Zalo Trigger**
198
+
199
+ ---
200
+
201
+ ### Cách 3: Link trực tiếp (Development)
202
+
203
+ Phù hợp khi đang phát triển/debug:
204
+
205
+ ```bash
206
+ # Trong thư mục project
207
+ npm link
208
+
209
+ # Link vào n8n
210
+ cd ~/.n8n
211
+ npm link n8n-nodes-zalo-user-noti
212
+ ```
213
+
214
+ ---
215
+
216
+ ### Troubleshooting
217
+
218
+ **Node không hiển thị:**
219
+ - Kiểm tra logs: `n8n start` và xem có lỗi gì không
220
+ - Đảm bảo đã build: kiểm tra folder `dist/` có tồn tại
221
+ - Kiểm tra biến môi trường `N8N_CUSTOM_EXTENSIONS`
222
+
223
+ **Lỗi "Cannot find module":**
224
+ ```bash
225
+ cd ~/.n8n/custom/n8n-nodes-zalo-user-noti
226
+ npm install
227
+ ```
228
+
229
+ **Lỗi TypeScript:**
230
+ ```bash
231
+ npm run build
232
+ ```
233
+
234
+ ## Credentials Setup
235
+
236
+ You need to extract credentials from Zalo Web:
237
+
238
+ 1. Install the [ZaloDataExtractor](https://github.com/JustKemForFun/ZaloDataExtractor) browser extension
239
+ 2. Open [Zalo Web](https://chat.zalo.me) and log in
240
+ 3. Click the extension to extract:
241
+ - **IMEI**
242
+ - **Cookie**
243
+ - **User Agent**
244
+ 4. Add these to your n8n credentials
245
+
246
+ ### Credential Fields
247
+
248
+ | Field | Description |
249
+ |-------|-------------|
250
+ | IMEI | Device IMEI from Zalo Web |
251
+ | Cookie | Full cookie string |
252
+ | User Agent | Browser user agent |
253
+ | Proxy URL | Optional proxy (http://user:pass@host:port) |
254
+
255
+ ## Usage Examples
256
+
257
+ ### Send a Message
258
+
259
+ ```
260
+ Resource: Message
261
+ Operation: Send Text
262
+ Thread Type: User
263
+ Thread ID: <user_id>
264
+ Message: Hello from n8n!
265
+ ```
266
+
267
+ ### Echo Bot with Trigger
268
+
269
+ 1. Add **Zalo Trigger** node
270
+ - Event: New Message
271
+ - Filter: Ignore Self Messages ✓
272
+
273
+ 2. Connect to **Zalo User** node
274
+ - Resource: Message
275
+ - Operation: Send Text
276
+ - Thread ID: `{{ $json.threadId }}`
277
+ - Message: `Echo: {{ $json.content }}`
278
+
279
+ ### Auto-Welcome New Group Members
280
+
281
+ 1. Add **Zalo Trigger** node
282
+ - Event: Group Event
283
+ - Group Event Types: Member Join
284
+
285
+ 2. Connect to **Zalo User** node
286
+ - Resource: Message
287
+ - Operation: Send Text
288
+ - Thread Type: Group
289
+ - Thread ID: `{{ $json.groupId }}`
290
+ - Message: `Welcome to the group!`
291
+
292
+ ## Important Notes
293
+
294
+ 1. **Single Listener Limitation**: Only one listener can run per account at a time. If you open Zalo Web while the trigger is active, the trigger will stop.
295
+
296
+ 2. **Session Management**: Cookies may expire. Re-extract credentials if you get authentication errors.
297
+
298
+ 3. **Rate Limiting**: Zalo may rate-limit requests. Add delays between operations if needed.
299
+
300
+ 4. **Account Safety**: Use a secondary account for testing to avoid bans.
301
+
302
+ ## Resources
303
+
304
+ - [zca-js Documentation](https://zca-js.tdung.com/vi/get-started/introduction.html)
305
+ - [zca-js GitHub](https://github.com/RFS-ADRENO/zca-js)
306
+ - [ZaloDataExtractor](https://github.com/JustKemForFun/ZaloDataExtractor)
307
+
308
+ ## Support
309
+
310
+ - 🐛 [Report Issues](https://github.com/notivn/n8n-nodes-zalo-user-noti/issues)
311
+ - 💬 [Discussions](https://github.com/notivn/n8n-nodes-zalo-user-noti/discussions)
312
+
313
+ ## License
314
+
315
+ [MIT](LICENSE)
316
+
317
+ ## Credits
318
+
319
+ - [zca-js](https://github.com/RFS-ADRENO/zca-js) - Unofficial Zalo API
320
+ - [n8n](https://n8n.io) - Workflow automation platform
321
+ - [Noti VN](https://noti.vn) - n8n Ambassador Vietnam
@@ -0,0 +1,9 @@
1
+ import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class ZaloApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZaloApi = void 0;
4
+ class ZaloApi {
5
+ constructor() {
6
+ this.name = 'zaloApi';
7
+ this.displayName = 'Zalo API';
8
+ this.documentationUrl = 'https://zca-js.tdung.com/vi/get-started/introduction.html';
9
+ this.properties = [
10
+ {
11
+ displayName: 'IMEI',
12
+ name: 'imei',
13
+ type: 'string',
14
+ default: '',
15
+ required: true,
16
+ description: 'IMEI from Zalo Web. Use ZaloDataExtractor extension to get this.',
17
+ placeholder: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
18
+ },
19
+ {
20
+ displayName: 'Cookie',
21
+ name: 'cookie',
22
+ type: 'string',
23
+ typeOptions: {
24
+ password: true,
25
+ },
26
+ default: '',
27
+ required: true,
28
+ description: 'Cookie from Zalo Web. Can be JSON array format from ZaloDataExtractor or string format (name1=value1; name2=value2)',
29
+ },
30
+ {
31
+ displayName: 'User Agent',
32
+ name: 'userAgent',
33
+ type: 'string',
34
+ default: '',
35
+ required: true,
36
+ description: 'User Agent from browser. Use ZaloDataExtractor extension to get this.',
37
+ placeholder: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ...',
38
+ },
39
+ {
40
+ displayName: 'Proxy URL',
41
+ name: 'proxyUrl',
42
+ type: 'string',
43
+ default: '',
44
+ required: false,
45
+ description: 'Optional proxy URL (e.g., http://user:pass@proxy:port)',
46
+ placeholder: 'http://username:password@proxy.example.com:8080',
47
+ },
48
+ ];
49
+ // Không sử dụng authenticate vì zca-js xử lý riêng
50
+ this.authenticate = {
51
+ type: 'generic',
52
+ properties: {},
53
+ };
54
+ this.test = {
55
+ request: {
56
+ baseURL: 'https://chat.zalo.me',
57
+ url: '/',
58
+ method: 'GET',
59
+ },
60
+ };
61
+ }
62
+ }
63
+ exports.ZaloApi = ZaloApi;
64
+ //# sourceMappingURL=ZaloApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZaloApi.credentials.js","sourceRoot":"","sources":["../../credentials/ZaloApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,OAAO;IAApB;QACC,SAAI,GAAG,SAAS,CAAC;QACjB,gBAAW,GAAG,UAAU,CAAC;QACzB,qBAAgB,GAAG,2DAA2D,CAAC;QAC/E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,kEAAkE;gBAC/E,WAAW,EAAE,sCAAsC;aACnD;YACD;gBACC,WAAW,EAAE,QAAQ;gBACrB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,qHAAqH;aAClI;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,uEAAuE;gBACpF,WAAW,EAAE,+CAA+C;aAC5D;YACD;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,wDAAwD;gBACrE,WAAW,EAAE,iDAAiD;aAC9D;SACD,CAAC;QAEF,mDAAmD;QACnD,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,EAAE;SACd,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,sBAAsB;gBAC/B,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AA1DD,0BA0DC"}
@@ -0,0 +1,5 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class ZaloUserNoti implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,456 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZaloUserNoti = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const zca_js_1 = require("zca-js");
6
+ // Helper function để parse cookie string thành object
7
+ function parseCookieString(cookieString) {
8
+ // Nếu đã là JSON array, parse trực tiếp
9
+ if (cookieString.trim().startsWith('[')) {
10
+ try {
11
+ return JSON.parse(cookieString);
12
+ }
13
+ catch {
14
+ // Không phải JSON hợp lệ, tiếp tục parse như string
15
+ }
16
+ }
17
+ // Parse cookie string format: "name1=value1; name2=value2"
18
+ const cookies = [];
19
+ const pairs = cookieString.split(';');
20
+ for (const pair of pairs) {
21
+ const [name, ...valueParts] = pair.trim().split('=');
22
+ if (name && valueParts.length > 0) {
23
+ cookies.push({
24
+ name: name.trim(),
25
+ value: valueParts.join('=').trim(),
26
+ domain: '.zalo.me',
27
+ path: '/',
28
+ });
29
+ }
30
+ }
31
+ return cookies;
32
+ }
33
+ // Helper function để khởi tạo Zalo API
34
+ async function initZaloApi(credentials) {
35
+ const zalo = new zca_js_1.Zalo();
36
+ const cookieData = parseCookieString(credentials.cookie);
37
+ const api = await zalo.login({
38
+ cookie: cookieData,
39
+ imei: credentials.imei,
40
+ userAgent: credentials.userAgent,
41
+ });
42
+ return api;
43
+ }
44
+ class ZaloUserNoti {
45
+ constructor() {
46
+ this.description = {
47
+ displayName: 'Zalo User',
48
+ name: 'zaloUserNoti',
49
+ icon: 'file:zalo.png',
50
+ group: ['transform'],
51
+ version: 1,
52
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
53
+ description: 'Interact with Zalo personal account using zca-js',
54
+ defaults: {
55
+ name: 'Zalo User',
56
+ },
57
+ inputs: ['main'],
58
+ outputs: ['main'],
59
+ credentials: [
60
+ {
61
+ name: 'zaloApi',
62
+ required: true,
63
+ },
64
+ ],
65
+ properties: [
66
+ // RESOURCE SELECTION
67
+ {
68
+ displayName: 'Resource',
69
+ name: 'resource',
70
+ type: 'options',
71
+ noDataExpression: true,
72
+ options: [
73
+ { name: 'Message', value: 'message', description: 'Send, delete, forward messages' },
74
+ { name: 'Friend', value: 'friend', description: 'Manage friends and contacts' },
75
+ { name: 'Group', value: 'group', description: 'Manage groups and members' },
76
+ { name: 'Sticker', value: 'sticker', description: 'Search and send stickers' },
77
+ { name: 'Account', value: 'account', description: 'Manage account settings' },
78
+ ],
79
+ default: 'message',
80
+ },
81
+ // MESSAGE OPERATIONS
82
+ {
83
+ displayName: 'Operation',
84
+ name: 'operation',
85
+ type: 'options',
86
+ noDataExpression: true,
87
+ displayOptions: { show: { resource: ['message'] } },
88
+ options: [
89
+ { name: 'Send Text', value: 'sendText', action: 'Send a text message' },
90
+ { name: 'Send Sticker', value: 'sendSticker', action: 'Send a sticker' },
91
+ { name: 'Delete', value: 'delete', action: 'Delete a message' },
92
+ { name: 'Undo', value: 'undo', action: 'Recall a message' },
93
+ { name: 'Add Reaction', value: 'addReaction', action: 'Add reaction to a message' },
94
+ ],
95
+ default: 'sendText',
96
+ },
97
+ // FRIEND OPERATIONS
98
+ {
99
+ displayName: 'Operation',
100
+ name: 'operation',
101
+ type: 'options',
102
+ noDataExpression: true,
103
+ displayOptions: { show: { resource: ['friend'] } },
104
+ options: [
105
+ { name: 'Get All', value: 'getAll', action: 'Get all friends' },
106
+ { name: 'Get Info', value: 'getInfo', action: 'Get user info' },
107
+ { name: 'Find User', value: 'findUser', action: 'Find user by phone' },
108
+ { name: 'Send Friend Request', value: 'sendRequest', action: 'Send friend request' },
109
+ { name: 'Block User', value: 'block', action: 'Block user' },
110
+ { name: 'Unblock User', value: 'unblock', action: 'Unblock user' },
111
+ ],
112
+ default: 'getAll',
113
+ },
114
+ // GROUP OPERATIONS
115
+ {
116
+ displayName: 'Operation',
117
+ name: 'operation',
118
+ type: 'options',
119
+ noDataExpression: true,
120
+ displayOptions: { show: { resource: ['group'] } },
121
+ options: [
122
+ { name: 'Get All Groups', value: 'getAll', action: 'Get all groups' },
123
+ { name: 'Get Info', value: 'getInfo', action: 'Get group info' },
124
+ { name: 'Create', value: 'create', action: 'Create group' },
125
+ { name: 'Add Member', value: 'addMember', action: 'Add member' },
126
+ { name: 'Remove Member', value: 'removeMember', action: 'Remove member' },
127
+ { name: 'Leave', value: 'leave', action: 'Leave group' },
128
+ ],
129
+ default: 'getAll',
130
+ },
131
+ // STICKER OPERATIONS
132
+ {
133
+ displayName: 'Operation',
134
+ name: 'operation',
135
+ type: 'options',
136
+ noDataExpression: true,
137
+ displayOptions: { show: { resource: ['sticker'] } },
138
+ options: [
139
+ { name: 'Search', value: 'search', action: 'Search stickers' },
140
+ { name: 'Get Detail', value: 'getDetail', action: 'Get sticker details' },
141
+ ],
142
+ default: 'search',
143
+ },
144
+ // ACCOUNT OPERATIONS
145
+ {
146
+ displayName: 'Operation',
147
+ name: 'operation',
148
+ type: 'options',
149
+ noDataExpression: true,
150
+ displayOptions: { show: { resource: ['account'] } },
151
+ options: [
152
+ { name: 'Get Info', value: 'getInfo', action: 'Get account info' },
153
+ { name: 'Get Own ID', value: 'getOwnId', action: 'Get own ID' },
154
+ ],
155
+ default: 'getInfo',
156
+ },
157
+ // COMMON FIELDS
158
+ {
159
+ displayName: 'Thread Type',
160
+ name: 'threadType',
161
+ type: 'options',
162
+ options: [
163
+ { name: 'User (Direct Message)', value: 'user' },
164
+ { name: 'Group', value: 'group' },
165
+ ],
166
+ default: 'user',
167
+ displayOptions: {
168
+ show: {
169
+ resource: ['message'],
170
+ operation: ['sendText', 'sendSticker', 'delete', 'undo', 'addReaction'],
171
+ },
172
+ },
173
+ },
174
+ {
175
+ displayName: 'Thread ID',
176
+ name: 'threadId',
177
+ type: 'string',
178
+ default: '',
179
+ required: true,
180
+ description: 'User ID or Group ID',
181
+ displayOptions: {
182
+ show: {
183
+ resource: ['message'],
184
+ operation: ['sendText', 'sendSticker', 'delete', 'undo', 'addReaction'],
185
+ },
186
+ },
187
+ },
188
+ // MESSAGE FIELDS
189
+ {
190
+ displayName: 'Message',
191
+ name: 'message',
192
+ type: 'string',
193
+ typeOptions: { rows: 4 },
194
+ default: '',
195
+ required: true,
196
+ displayOptions: { show: { resource: ['message'], operation: ['sendText'] } },
197
+ },
198
+ {
199
+ displayName: 'Message ID',
200
+ name: 'messageId',
201
+ type: 'string',
202
+ default: '',
203
+ required: true,
204
+ displayOptions: { show: { resource: ['message'], operation: ['delete', 'undo', 'addReaction'] } },
205
+ },
206
+ {
207
+ displayName: 'Reaction',
208
+ name: 'reaction',
209
+ type: 'options',
210
+ options: [
211
+ { name: '❤️ Heart', value: 'heart' },
212
+ { name: '😆 Haha', value: 'haha' },
213
+ { name: '😮 Wow', value: 'wow' },
214
+ { name: '😢 Sad', value: 'sad' },
215
+ { name: '😠 Angry', value: 'angry' },
216
+ { name: '👍 Like', value: 'like' },
217
+ ],
218
+ default: 'like',
219
+ displayOptions: { show: { resource: ['message'], operation: ['addReaction'] } },
220
+ },
221
+ // FRIEND FIELDS
222
+ {
223
+ displayName: 'User ID',
224
+ name: 'userId',
225
+ type: 'string',
226
+ default: '',
227
+ required: true,
228
+ displayOptions: { show: { resource: ['friend'], operation: ['getInfo', 'sendRequest', 'block', 'unblock'] } },
229
+ },
230
+ {
231
+ displayName: 'Phone Number',
232
+ name: 'phoneNumber',
233
+ type: 'string',
234
+ default: '',
235
+ required: true,
236
+ displayOptions: { show: { resource: ['friend'], operation: ['findUser'] } },
237
+ },
238
+ // GROUP FIELDS
239
+ {
240
+ displayName: 'Group ID',
241
+ name: 'groupId',
242
+ type: 'string',
243
+ default: '',
244
+ required: true,
245
+ displayOptions: { show: { resource: ['group'], operation: ['getInfo', 'addMember', 'removeMember', 'leave'] } },
246
+ },
247
+ {
248
+ displayName: 'Group Name',
249
+ name: 'groupName',
250
+ type: 'string',
251
+ default: '',
252
+ required: true,
253
+ displayOptions: { show: { resource: ['group'], operation: ['create'] } },
254
+ },
255
+ {
256
+ displayName: 'Member IDs',
257
+ name: 'memberIds',
258
+ type: 'string',
259
+ default: '',
260
+ required: true,
261
+ description: 'Comma-separated user IDs',
262
+ displayOptions: { show: { resource: ['group'], operation: ['create', 'addMember'] } },
263
+ },
264
+ {
265
+ displayName: 'Member ID',
266
+ name: 'memberId',
267
+ type: 'string',
268
+ default: '',
269
+ required: true,
270
+ displayOptions: { show: { resource: ['group'], operation: ['removeMember'] } },
271
+ },
272
+ // STICKER FIELDS
273
+ {
274
+ displayName: 'Keyword',
275
+ name: 'stickerKeyword',
276
+ type: 'string',
277
+ default: '',
278
+ required: true,
279
+ displayOptions: { show: { resource: ['sticker'], operation: ['search'] } },
280
+ },
281
+ {
282
+ displayName: 'Sticker ID',
283
+ name: 'stickerId',
284
+ type: 'string',
285
+ default: '',
286
+ required: true,
287
+ displayOptions: { show: { resource: ['sticker'], operation: ['getDetail'] } },
288
+ },
289
+ ],
290
+ };
291
+ }
292
+ async execute() {
293
+ const items = this.getInputData();
294
+ const returnData = [];
295
+ const credentials = await this.getCredentials('zaloApi');
296
+ let api;
297
+ try {
298
+ api = await initZaloApi(credentials);
299
+ }
300
+ catch (error) {
301
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
302
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to initialize Zalo API: ${errorMessage}`);
303
+ }
304
+ const resource = this.getNodeParameter('resource', 0);
305
+ const operation = this.getNodeParameter('operation', 0);
306
+ for (let i = 0; i < items.length; i++) {
307
+ try {
308
+ let result;
309
+ if (resource === 'message') {
310
+ const threadType = this.getNodeParameter('threadType', i);
311
+ const threadId = this.getNodeParameter('threadId', i);
312
+ const type = threadType === 'user' ? zca_js_1.ThreadType.User : zca_js_1.ThreadType.Group;
313
+ switch (operation) {
314
+ case 'sendText': {
315
+ const message = this.getNodeParameter('message', i);
316
+ result = await api.sendMessage({ msg: message }, threadId, type);
317
+ break;
318
+ }
319
+ case 'delete': {
320
+ const messageId = this.getNodeParameter('messageId', i);
321
+ result = await api.deleteMessage(messageId, threadId, type);
322
+ break;
323
+ }
324
+ case 'undo': {
325
+ const messageId = this.getNodeParameter('messageId', i);
326
+ result = await api.undo(messageId, threadId, type);
327
+ break;
328
+ }
329
+ case 'addReaction': {
330
+ const messageId = this.getNodeParameter('messageId', i);
331
+ const reaction = this.getNodeParameter('reaction', i);
332
+ result = await api.addReaction(reaction, messageId, threadId, type);
333
+ break;
334
+ }
335
+ }
336
+ }
337
+ else if (resource === 'friend') {
338
+ switch (operation) {
339
+ case 'getAll': {
340
+ result = await api.getAllFriends();
341
+ break;
342
+ }
343
+ case 'getInfo': {
344
+ const userId = this.getNodeParameter('userId', i);
345
+ result = await api.getUserInfo(userId);
346
+ break;
347
+ }
348
+ case 'findUser': {
349
+ const phoneNumber = this.getNodeParameter('phoneNumber', i);
350
+ result = await api.findUser(phoneNumber);
351
+ break;
352
+ }
353
+ case 'sendRequest': {
354
+ const userId = this.getNodeParameter('userId', i);
355
+ result = await api.sendFriendRequest(userId, 'Xin chào!');
356
+ break;
357
+ }
358
+ case 'block': {
359
+ const userId = this.getNodeParameter('userId', i);
360
+ result = await api.blockUser(userId);
361
+ break;
362
+ }
363
+ case 'unblock': {
364
+ const userId = this.getNodeParameter('userId', i);
365
+ result = await api.unblockUser(userId);
366
+ break;
367
+ }
368
+ }
369
+ }
370
+ else if (resource === 'group') {
371
+ switch (operation) {
372
+ case 'getAll': {
373
+ result = await api.getAllGroups();
374
+ break;
375
+ }
376
+ case 'getInfo': {
377
+ const groupId = this.getNodeParameter('groupId', i);
378
+ result = await api.getGroupInfo(groupId);
379
+ break;
380
+ }
381
+ case 'create': {
382
+ const groupName = this.getNodeParameter('groupName', i);
383
+ const memberIds = this.getNodeParameter('memberIds', i);
384
+ const members = memberIds.split(',').map(id => id.trim());
385
+ result = await api.createGroup(groupName, members);
386
+ break;
387
+ }
388
+ case 'addMember': {
389
+ const groupId = this.getNodeParameter('groupId', i);
390
+ const memberIds = this.getNodeParameter('memberIds', i);
391
+ const members = memberIds.split(',').map(id => id.trim());
392
+ result = await api.addUserToGroup(groupId, members);
393
+ break;
394
+ }
395
+ case 'removeMember': {
396
+ const groupId = this.getNodeParameter('groupId', i);
397
+ const memberId = this.getNodeParameter('memberId', i);
398
+ result = await api.removeUserFromGroup(groupId, memberId);
399
+ break;
400
+ }
401
+ case 'leave': {
402
+ const groupId = this.getNodeParameter('groupId', i);
403
+ result = await api.leaveGroup(groupId);
404
+ break;
405
+ }
406
+ }
407
+ }
408
+ else if (resource === 'sticker') {
409
+ switch (operation) {
410
+ case 'search': {
411
+ const keyword = this.getNodeParameter('stickerKeyword', i);
412
+ result = await api.getStickers(keyword);
413
+ break;
414
+ }
415
+ case 'getDetail': {
416
+ const stickerId = this.getNodeParameter('stickerId', i);
417
+ result = await api.getStickersDetail(stickerId);
418
+ break;
419
+ }
420
+ }
421
+ }
422
+ else if (resource === 'account') {
423
+ switch (operation) {
424
+ case 'getInfo': {
425
+ result = await api.fetchAccountInfo();
426
+ break;
427
+ }
428
+ case 'getOwnId': {
429
+ result = { ownId: api.getOwnId() };
430
+ break;
431
+ }
432
+ }
433
+ }
434
+ returnData.push({
435
+ json: result || { success: true },
436
+ pairedItem: { item: i },
437
+ });
438
+ }
439
+ catch (error) {
440
+ if (this.continueOnFail()) {
441
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
442
+ returnData.push({
443
+ json: { error: errorMessage },
444
+ pairedItem: { item: i },
445
+ });
446
+ continue;
447
+ }
448
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
449
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage, { itemIndex: i });
450
+ }
451
+ }
452
+ return [returnData];
453
+ }
454
+ }
455
+ exports.ZaloUserNoti = ZaloUserNoti;
456
+ //# sourceMappingURL=Zalo.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Zalo.node.js","sourceRoot":"","sources":["../../../nodes/Zalo/Zalo.node.ts"],"names":[],"mappings":";;;AAAA,+CAOsB;AAEtB,mCAAqD;AAErD,sDAAsD;AACtD,SAAS,iBAAiB,CAAC,YAAoB;IAC9C,wCAAwC;IACxC,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACR,oDAAoD;QACrD,CAAC;IACF,CAAC;IAED,2DAA2D;IAC3D,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC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zB,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;oBAC3B,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;oBAC9E,UAAU,CAAC,IAAI,CAAC;wBACf,IAAI,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;wBAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;qBACvB,CAAC,CAAC;oBACH,SAAS;gBACV,CAAC;gBACD,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBAC9E,MAAM,IAAI,iCAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9E,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AA9aD,oCA8aC"}
@@ -0,0 +1,5 @@
1
+ import { ITriggerFunctions, INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow';
2
+ export declare class ZaloTriggerNoti implements INodeType {
3
+ description: INodeTypeDescription;
4
+ trigger(this: ITriggerFunctions): Promise<ITriggerResponse>;
5
+ }
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZaloTriggerNoti = void 0;
4
+ const zca_js_1 = require("zca-js");
5
+ // Helper function để parse cookie string thành object
6
+ function parseCookieString(cookieString) {
7
+ // Nếu đã là JSON array, parse trực tiếp
8
+ if (cookieString.trim().startsWith('[')) {
9
+ try {
10
+ return JSON.parse(cookieString);
11
+ }
12
+ catch {
13
+ // Không phải JSON hợp lệ, tiếp tục parse như string
14
+ }
15
+ }
16
+ // Parse cookie string format: "name1=value1; name2=value2"
17
+ const cookies = [];
18
+ const pairs = cookieString.split(';');
19
+ for (const pair of pairs) {
20
+ const [name, ...valueParts] = pair.trim().split('=');
21
+ if (name && valueParts.length > 0) {
22
+ cookies.push({
23
+ name: name.trim(),
24
+ value: valueParts.join('=').trim(),
25
+ domain: '.zalo.me',
26
+ path: '/',
27
+ });
28
+ }
29
+ }
30
+ return cookies;
31
+ }
32
+ class ZaloTriggerNoti {
33
+ constructor() {
34
+ this.description = {
35
+ displayName: 'Zalo Trigger',
36
+ name: 'zaloTriggerNoti',
37
+ icon: 'file:zalo.png',
38
+ group: ['trigger'],
39
+ version: 1,
40
+ subtitle: '={{$parameter["event"]}}',
41
+ description: 'Listen to Zalo events (messages, reactions, etc.)',
42
+ defaults: {
43
+ name: 'Zalo Trigger',
44
+ },
45
+ inputs: [],
46
+ outputs: ['main'],
47
+ credentials: [
48
+ {
49
+ name: 'zaloApi',
50
+ required: true,
51
+ },
52
+ ],
53
+ properties: [
54
+ {
55
+ displayName: 'Event',
56
+ name: 'event',
57
+ type: 'options',
58
+ options: [
59
+ { name: 'New Message', value: 'message', description: 'Trigger when a new message is received' },
60
+ { name: 'Reaction', value: 'reaction', description: 'Trigger when someone reacts to a message' },
61
+ { name: 'Message Undo', value: 'undo', description: 'Trigger when a message is recalled' },
62
+ { name: 'Group Event', value: 'group_event', description: 'Trigger on group events' },
63
+ { name: 'All Events', value: 'all', description: 'Trigger on all events' },
64
+ ],
65
+ default: 'message',
66
+ },
67
+ {
68
+ displayName: 'Options',
69
+ name: 'options',
70
+ type: 'collection',
71
+ placeholder: 'Add Option',
72
+ default: {},
73
+ options: [
74
+ {
75
+ displayName: 'Ignore Self Messages',
76
+ name: 'ignoreSelf',
77
+ type: 'boolean',
78
+ default: true,
79
+ description: 'Whether to ignore messages sent by yourself',
80
+ },
81
+ {
82
+ displayName: 'Thread Type Filter',
83
+ name: 'threadType',
84
+ type: 'options',
85
+ options: [
86
+ { name: 'All', value: 'all' },
87
+ { name: 'User Only', value: 'user' },
88
+ { name: 'Group Only', value: 'group' },
89
+ ],
90
+ default: 'all',
91
+ },
92
+ ],
93
+ },
94
+ ],
95
+ };
96
+ }
97
+ async trigger() {
98
+ const credentials = await this.getCredentials('zaloApi');
99
+ const event = this.getNodeParameter('event');
100
+ const options = this.getNodeParameter('options', {});
101
+ const ignoreSelf = options.ignoreSelf !== false;
102
+ const threadTypeFilter = options.threadType || 'all';
103
+ let api;
104
+ const startListening = async () => {
105
+ const zalo = new zca_js_1.Zalo();
106
+ const cookieData = parseCookieString(credentials.cookie);
107
+ api = await zalo.login({
108
+ cookie: cookieData,
109
+ imei: credentials.imei,
110
+ userAgent: credentials.userAgent,
111
+ });
112
+ const listener = api.listener;
113
+ // Message event
114
+ if (event === 'message' || event === 'all') {
115
+ listener.on('message', (message) => {
116
+ if (ignoreSelf && message.isSelf)
117
+ return;
118
+ const msgThreadType = message.type === zca_js_1.ThreadType.User ? 'user' : 'group';
119
+ if (threadTypeFilter !== 'all' && threadTypeFilter !== msgThreadType)
120
+ return;
121
+ this.emit([
122
+ this.helpers.returnJsonArray([{
123
+ event: 'message',
124
+ threadId: message.threadId,
125
+ threadType: msgThreadType,
126
+ messageId: message.data?.msgId,
127
+ senderId: message.data?.uidFrom,
128
+ senderName: message.data?.dName,
129
+ content: message.data?.content,
130
+ isSelf: message.isSelf,
131
+ timestamp: message.data?.ts || Date.now(),
132
+ rawData: message,
133
+ }]),
134
+ ]);
135
+ });
136
+ }
137
+ // Reaction event
138
+ if (event === 'reaction' || event === 'all') {
139
+ listener.on('reaction', (reaction) => {
140
+ this.emit([
141
+ this.helpers.returnJsonArray([{
142
+ event: 'reaction',
143
+ threadId: reaction.threadId,
144
+ messageId: reaction.data?.msgId,
145
+ userId: reaction.data?.uidFrom,
146
+ reaction: reaction.data?.content,
147
+ timestamp: reaction.data?.ts || Date.now(),
148
+ rawData: reaction,
149
+ }]),
150
+ ]);
151
+ });
152
+ }
153
+ // Undo event
154
+ if (event === 'undo' || event === 'all') {
155
+ listener.on('undo', (undo) => {
156
+ this.emit([
157
+ this.helpers.returnJsonArray([{
158
+ event: 'undo',
159
+ threadId: undo.threadId,
160
+ messageId: undo.data?.msgId,
161
+ userId: undo.data?.uidFrom,
162
+ timestamp: undo.data?.ts || Date.now(),
163
+ rawData: undo,
164
+ }]),
165
+ ]);
166
+ });
167
+ }
168
+ // Group event
169
+ if (event === 'group_event' || event === 'all') {
170
+ listener.on('group_event', (groupEvent) => {
171
+ this.emit([
172
+ this.helpers.returnJsonArray([{
173
+ event: 'group_event',
174
+ eventType: groupEvent.data?.subType || 'unknown',
175
+ groupId: groupEvent.threadId,
176
+ userId: groupEvent.data?.uidFrom,
177
+ timestamp: groupEvent.data?.ts || Date.now(),
178
+ rawData: groupEvent,
179
+ }]),
180
+ ]);
181
+ });
182
+ }
183
+ listener.start();
184
+ };
185
+ await startListening();
186
+ const closeFunction = async () => {
187
+ if (api?.listener) {
188
+ api.listener.stop();
189
+ }
190
+ };
191
+ return { closeFunction };
192
+ }
193
+ }
194
+ exports.ZaloTriggerNoti = ZaloTriggerNoti;
195
+ //# sourceMappingURL=ZaloTrigger.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZaloTrigger.node.js","sourceRoot":"","sources":["../../../nodes/Zalo/ZaloTrigger.node.ts"],"names":[],"mappings":";;;AAQA,mCAAqD;AAErD,sDAAsD;AACtD,SAAS,iBAAiB,CAAC,YAAoB;IAC9C,wCAAwC;IACxC,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACR,oDAAoD;QACrD,CAAC;IACF,CAAC;IAED,2DAA2D;IAC3D,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAA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AE,OAAO;gCAC1B,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;gCACtC,OAAO,EAAE,IAAI;6BACb,CAAC,CAAC;qBACH,CAAC,CAAC;gBACJ,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,cAAc;YACd,IAAI,KAAK,KAAK,aAAa,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;gBAChD,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,UAAe,EAAE,EAAE;oBAC9C,IAAI,CAAC,IAAI,CAAC;wBACT,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;gCAC7B,KAAK,EAAE,aAAa;gCACpB,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO,IAAI,SAAS;gCAChD,OAAO,EAAE,UAAU,CAAC,QAAQ;gCAC5B,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,OAAO;gCAChC,SAAS,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;gCAC5C,OAAO,EAAE,UAAU;6BACnB,CAAC,CAAC;qBACH,CAAC,CAAC;gBACJ,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,QAAQ,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC,CAAC;QAEF,MAAM,cAAc,EAAE,CAAC;QAEvB,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;YAChC,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC;gBACnB,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;QACF,CAAC,CAAC;QAEF,OAAO,EAAE,aAAa,EAAE,CAAC;IAC1B,CAAC;CACD;AA9KD,0CA8KC"}
Binary file
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "n8n-nodes-zalo-user-noti",
3
+ "version": "1.0.0",
4
+ "description": "n8n node for Zalo personal account automation using zca-js",
5
+ "keywords": [
6
+ "n8n",
7
+ "n8n-community-node-package",
8
+ "zalo",
9
+ "zca-js",
10
+ "vietnam",
11
+ "chat",
12
+ "automation",
13
+ "messaging"
14
+ ],
15
+ "author": {
16
+ "name": "Noti VN",
17
+ "url": "https://noti.vn"
18
+ },
19
+ "license": "MIT",
20
+ "homepage": "https://github.com/notivn/n8n-nodes-zalo-user-noti",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/notivn/n8n-nodes-zalo-user-noti.git"
24
+ },
25
+ "main": "dist/index.js",
26
+ "scripts": {
27
+ "build": "tsc && gulp build:icons",
28
+ "dev": "tsc --watch",
29
+ "format": "prettier nodes credentials --write",
30
+ "lint": "eslint nodes credentials package.json",
31
+ "lintfix": "eslint nodes credentials package.json --fix",
32
+ "prepublishOnly": "npm run build"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "n8n": {
38
+ "n8nNodesApiVersion": 1,
39
+ "credentials": [
40
+ "dist/credentials/ZaloApi.credentials.js"
41
+ ],
42
+ "nodes": [
43
+ "dist/nodes/Zalo/Zalo.node.js",
44
+ "dist/nodes/Zalo/ZaloTrigger.node.js"
45
+ ]
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.10.0",
49
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
50
+ "@typescript-eslint/parser": "^6.0.0",
51
+ "eslint": "^8.56.0",
52
+ "eslint-plugin-n8n-nodes-base": "^1.16.0",
53
+ "gulp": "^4.0.2",
54
+ "n8n-workflow": "^1.20.0",
55
+ "prettier": "^3.1.0",
56
+ "typescript": "^5.3.0"
57
+ },
58
+ "dependencies": {
59
+ "zca-js": "^2.0.4"
60
+ },
61
+ "peerDependencies": {
62
+ "n8n-workflow": "*"
63
+ }
64
+ }