n8n-nodes-zalo-nnt 0.6.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 +201 -0
- package/LICENSE.md +19 -0
- package/README.md +235 -0
- package/dist/ZaloSendMessage/ZaloSendMessage.node.js +431 -0
- package/dist/credentials/N8nZaloApi.credentials.d.ts +8 -0
- package/dist/credentials/N8nZaloApi.credentials.js +31 -0
- package/dist/credentials/N8nZaloApi.credentials.js.map +1 -0
- package/dist/credentials/N8nZaloApi.credentials.ts +32 -0
- package/dist/credentials/ZaloApi.credentials.d.ts +8 -0
- package/dist/credentials/ZaloApi.credentials.js +64 -0
- package/dist/credentials/ZaloApi.credentials.js.map +1 -0
- package/dist/credentials/ZaloApi.credentials.ts +66 -0
- package/dist/credentials/shared/n8n.png +0 -0
- package/dist/credentials/shared/zalo.svg +10 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.d.ts +12 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.js +129 -0
- package/dist/nodes/ZaloFriendTrigger/ZaloFriendTrigger.node.js.map +1 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.d.ts +5 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.js +228 -0
- package/dist/nodes/ZaloGroup/ZaloGroup.node.js.map +1 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.d.ts +3 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.js +348 -0
- package/dist/nodes/ZaloGroup/ZaloGroupDescription.js.map +1 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.d.ts +5 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.js +422 -0
- package/dist/nodes/ZaloLoginByQr/ZaloLoginByQr.node.js.map +1 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.d.ts +12 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.js +147 -0
- package/dist/nodes/ZaloMessageTrigger/ZaloMessageTrigger.node.js.map +1 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.d.ts +5 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.js +187 -0
- package/dist/nodes/ZaloPoll/ZaloPoll.node.js.map +1 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.d.ts +3 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.js +260 -0
- package/dist/nodes/ZaloPoll/ZaloPollDescription.js.map +1 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.d.ts +5 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.js +337 -0
- package/dist/nodes/ZaloSendMessage/ZaloSendMessage.node.js.map +1 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.d.ts +5 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.js +81 -0
- package/dist/nodes/ZaloTag/ZaloTag.node.js.map +1 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.d.ts +5 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.js +229 -0
- package/dist/nodes/ZaloUser/ZaloUser.node.js.map +1 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.d.ts +3 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.js +361 -0
- package/dist/nodes/ZaloUser/ZaloUserDescription.js.map +1 -0
- package/dist/nodes/shared/zalo.svg +10 -0
- package/dist/nodes/utils/helper.d.ts +2 -0
- package/dist/nodes/utils/helper.js +42 -0
- package/dist/nodes/utils/helper.js.map +1 -0
- package/dist/package.json +78 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/helper.js +90 -0
- package/index.js +0 -0
- package/package.json +78 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ZaloSendMessage = void 0;
|
|
40
|
+
var n8n_workflow_1 = require("n8n-workflow");
|
|
41
|
+
var zca_js_1 = require("zca-js");
|
|
42
|
+
var helper_1 = require("../utils/helper");
|
|
43
|
+
var api;
|
|
44
|
+
var ZaloSendMessage = /** @class */ (function () {
|
|
45
|
+
function ZaloSendMessage() {
|
|
46
|
+
this.description = {
|
|
47
|
+
displayName: 'Zalo Send Message',
|
|
48
|
+
name: 'zaloSendMessage',
|
|
49
|
+
icon: 'file:../shared/zalo.svg',
|
|
50
|
+
group: ['Zalo'],
|
|
51
|
+
version: 5,
|
|
52
|
+
description: 'Gửi tin nhắn qua API Zalo sử dụng kết nối đăng nhập bằng cookie',
|
|
53
|
+
defaults: {
|
|
54
|
+
name: 'Zalo Send Message',
|
|
55
|
+
},
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
inputs: ['main'],
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
outputs: ['main'],
|
|
60
|
+
credentials: [
|
|
61
|
+
{
|
|
62
|
+
name: 'zaloApi',
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
properties: [
|
|
67
|
+
{
|
|
68
|
+
displayName: 'Thread ID',
|
|
69
|
+
name: 'threadId',
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: '',
|
|
72
|
+
required: true,
|
|
73
|
+
description: 'ID của thread để gửi tin nhắn',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Type',
|
|
77
|
+
name: 'type',
|
|
78
|
+
type: 'options',
|
|
79
|
+
options: [
|
|
80
|
+
{
|
|
81
|
+
name: 'User',
|
|
82
|
+
value: 0,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Group',
|
|
86
|
+
value: 1,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
default: 0,
|
|
90
|
+
description: 'Loại của tin nhắn (user hoặc group)',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Message',
|
|
94
|
+
name: 'message',
|
|
95
|
+
type: 'string',
|
|
96
|
+
default: '',
|
|
97
|
+
required: true,
|
|
98
|
+
description: 'Nội dung tin nhắn cần gửi',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Urgency',
|
|
102
|
+
name: 'urgency',
|
|
103
|
+
type: 'options',
|
|
104
|
+
options: [
|
|
105
|
+
{
|
|
106
|
+
name: 'Default',
|
|
107
|
+
value: 0,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'Important',
|
|
111
|
+
value: 1,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'Urgent',
|
|
115
|
+
value: 2,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
default: 0,
|
|
119
|
+
description: 'Mức độ khẩn cấp của tin nhắn',
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
displayName: 'Quote Message',
|
|
123
|
+
name: 'quote',
|
|
124
|
+
type: 'collection',
|
|
125
|
+
placeholder: 'Add Quote',
|
|
126
|
+
default: {},
|
|
127
|
+
options: [
|
|
128
|
+
{
|
|
129
|
+
displayName: 'Message ID',
|
|
130
|
+
name: 'msgId',
|
|
131
|
+
type: 'string',
|
|
132
|
+
default: '',
|
|
133
|
+
description: 'ID của tin nhắn cần trích dẫn',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
displayName: 'Sender ID',
|
|
137
|
+
name: 'senderId',
|
|
138
|
+
type: 'string',
|
|
139
|
+
default: '',
|
|
140
|
+
description: 'ID của người gửi tin nhắn trích dẫn',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
displayName: 'Content',
|
|
144
|
+
name: 'content',
|
|
145
|
+
type: 'string',
|
|
146
|
+
default: '',
|
|
147
|
+
description: 'Nội dung tin nhắn trích dẫn',
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
displayName: 'Mentions',
|
|
153
|
+
name: 'mentions',
|
|
154
|
+
type: 'collection',
|
|
155
|
+
placeholder: 'Add Mention',
|
|
156
|
+
default: {},
|
|
157
|
+
options: [
|
|
158
|
+
{
|
|
159
|
+
displayName: 'User ID',
|
|
160
|
+
name: 'uid',
|
|
161
|
+
type: 'string',
|
|
162
|
+
default: '',
|
|
163
|
+
description: 'ID của người dùng được mention',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
displayName: 'Position',
|
|
167
|
+
name: 'pos',
|
|
168
|
+
type: 'number',
|
|
169
|
+
default: 0,
|
|
170
|
+
description: 'Vị trí mention trong tin nhắn',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
displayName: 'Length',
|
|
174
|
+
name: 'len',
|
|
175
|
+
type: 'number',
|
|
176
|
+
default: 0,
|
|
177
|
+
description: 'Độ dài của mention',
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
displayName: 'Attachments',
|
|
183
|
+
name: 'attachments',
|
|
184
|
+
type: 'fixedCollection',
|
|
185
|
+
typeOptions: {
|
|
186
|
+
multipleValues: true,
|
|
187
|
+
},
|
|
188
|
+
placeholder: 'Add Attachment',
|
|
189
|
+
default: {},
|
|
190
|
+
options: [
|
|
191
|
+
{
|
|
192
|
+
name: 'attachment',
|
|
193
|
+
displayName: 'Attachment',
|
|
194
|
+
values: [
|
|
195
|
+
{
|
|
196
|
+
displayName: 'Type',
|
|
197
|
+
name: 'type',
|
|
198
|
+
type: 'options',
|
|
199
|
+
options: [
|
|
200
|
+
{
|
|
201
|
+
name: 'Image URL/File URL',
|
|
202
|
+
value: 'url',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'Array of URLs',
|
|
206
|
+
value: 'urlArray',
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
default: 'url',
|
|
210
|
+
description: 'Loại file đính kèm',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Image URL/File URL',
|
|
214
|
+
name: 'imageUrl',
|
|
215
|
+
type: 'string',
|
|
216
|
+
default: '',
|
|
217
|
+
displayOptions: {
|
|
218
|
+
show: {
|
|
219
|
+
'type': ['url'],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
description: 'URL công khai của ảnh hoặc file',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
displayName: 'Image URLs Array',
|
|
226
|
+
name: 'imageUrls',
|
|
227
|
+
type: 'string',
|
|
228
|
+
default: '',
|
|
229
|
+
displayOptions: {
|
|
230
|
+
show: {
|
|
231
|
+
'type': ['urlArray'],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
description: 'Array of URLs (JSON format) hoặc comma-separated URLs. VD: ["url1","url2"] hoặc url1,url2',
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
description: 'Một hoặc nhiều ảnh đính kèm để gửi',
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
ZaloSendMessage.prototype.execute = function () {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
var returnData, items, zaloCred, cookieFromCred, imeiFromCred, userAgentFromCred, zalo, error_1, i, threadId, typeNumber, type, message, urgency, quote, mentions, attachments, messageContent, _i, _a, attachment, fileData, urls, _b, urls_1, url, fileData, recipentObj, result, e_1, response, _c, _d, attachment, error_2;
|
|
247
|
+
return __generator(this, function (_e) {
|
|
248
|
+
switch (_e.label) {
|
|
249
|
+
case 0:
|
|
250
|
+
returnData = [];
|
|
251
|
+
items = this.getInputData();
|
|
252
|
+
return [4 /*yield*/, this.getCredentials('zaloApi')];
|
|
253
|
+
case 1:
|
|
254
|
+
zaloCred = _e.sent();
|
|
255
|
+
cookieFromCred = JSON.parse(zaloCred.cookie);
|
|
256
|
+
imeiFromCred = zaloCred.imei;
|
|
257
|
+
userAgentFromCred = zaloCred.userAgent;
|
|
258
|
+
_e.label = 2;
|
|
259
|
+
case 2:
|
|
260
|
+
_e.trys.push([2, 4, , 5]);
|
|
261
|
+
zalo = new zca_js_1.Zalo();
|
|
262
|
+
return [4 /*yield*/, zalo.login({
|
|
263
|
+
cookie: cookieFromCred,
|
|
264
|
+
imei: imeiFromCred,
|
|
265
|
+
userAgent: userAgentFromCred
|
|
266
|
+
})];
|
|
267
|
+
case 3:
|
|
268
|
+
api = _e.sent();
|
|
269
|
+
if (!api) {
|
|
270
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Failed to initialize Zalo API. Check your credentials.');
|
|
271
|
+
}
|
|
272
|
+
return [3 /*break*/, 5];
|
|
273
|
+
case 4:
|
|
274
|
+
error_1 = _e.sent();
|
|
275
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Zalo login error: ".concat(error_1.message));
|
|
276
|
+
case 5:
|
|
277
|
+
i = 0;
|
|
278
|
+
_e.label = 6;
|
|
279
|
+
case 6:
|
|
280
|
+
if (!(i < items.length)) return [3 /*break*/, 23];
|
|
281
|
+
_e.label = 7;
|
|
282
|
+
case 7:
|
|
283
|
+
_e.trys.push([7, 21, , 22]);
|
|
284
|
+
threadId = this.getNodeParameter('threadId', i);
|
|
285
|
+
typeNumber = this.getNodeParameter('type', i);
|
|
286
|
+
type = typeNumber === 0 ? zca_js_1.ThreadType.User : zca_js_1.ThreadType.Group;
|
|
287
|
+
message = this.getNodeParameter('message', i);
|
|
288
|
+
urgency = this.getNodeParameter('urgency', i, 0);
|
|
289
|
+
quote = this.getNodeParameter('quote', i, {});
|
|
290
|
+
mentions = this.getNodeParameter('mentions', i, {});
|
|
291
|
+
attachments = this.getNodeParameter('attachments', i, {});
|
|
292
|
+
messageContent = {
|
|
293
|
+
msg: message,
|
|
294
|
+
};
|
|
295
|
+
// Add urgency if specified
|
|
296
|
+
if (urgency !== 0) {
|
|
297
|
+
messageContent.urgency = urgency;
|
|
298
|
+
}
|
|
299
|
+
// Add quote if specified
|
|
300
|
+
if (quote && Object.keys(quote).length > 0) {
|
|
301
|
+
messageContent.quote = {
|
|
302
|
+
msgId: quote.msgId,
|
|
303
|
+
senderId: quote.senderId,
|
|
304
|
+
content: quote.content,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
// Add mentions if specified
|
|
308
|
+
if (mentions && Object.keys(mentions).length > 0) {
|
|
309
|
+
messageContent.mentions = [{
|
|
310
|
+
pos: mentions.pos || 0,
|
|
311
|
+
uid: mentions.uid,
|
|
312
|
+
len: mentions.len || 0,
|
|
313
|
+
}];
|
|
314
|
+
}
|
|
315
|
+
if (!(attachments && attachments.attachment && attachments.attachment.length > 0)) return [3 /*break*/, 15];
|
|
316
|
+
messageContent.attachments = [];
|
|
317
|
+
_i = 0, _a = attachments.attachment;
|
|
318
|
+
_e.label = 8;
|
|
319
|
+
case 8:
|
|
320
|
+
if (!(_i < _a.length)) return [3 /*break*/, 15];
|
|
321
|
+
attachment = _a[_i];
|
|
322
|
+
if (!(attachment.type === 'url')) return [3 /*break*/, 10];
|
|
323
|
+
return [4 /*yield*/, (0, helper_1.saveFile)(attachment.imageUrl)];
|
|
324
|
+
case 9:
|
|
325
|
+
fileData = _e.sent();
|
|
326
|
+
messageContent.attachments.push(fileData);
|
|
327
|
+
return [3 /*break*/, 14];
|
|
328
|
+
case 10:
|
|
329
|
+
if (!(attachment.type === 'urlArray')) return [3 /*break*/, 14];
|
|
330
|
+
urls = [];
|
|
331
|
+
// Parse URLs from string input
|
|
332
|
+
if (typeof attachment.imageUrls === 'string') {
|
|
333
|
+
try {
|
|
334
|
+
// Try to parse as JSON array first
|
|
335
|
+
urls = JSON.parse(attachment.imageUrls);
|
|
336
|
+
}
|
|
337
|
+
catch (_f) {
|
|
338
|
+
// If not JSON, try comma-separated
|
|
339
|
+
urls = attachment.imageUrls.split(',').map(function (url) { return url.trim(); }).filter(function (url) { return url; });
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
_b = 0, urls_1 = urls;
|
|
343
|
+
_e.label = 11;
|
|
344
|
+
case 11:
|
|
345
|
+
if (!(_b < urls_1.length)) return [3 /*break*/, 14];
|
|
346
|
+
url = urls_1[_b];
|
|
347
|
+
if (!url) return [3 /*break*/, 13];
|
|
348
|
+
return [4 /*yield*/, (0, helper_1.saveFile)(url)];
|
|
349
|
+
case 12:
|
|
350
|
+
fileData = _e.sent();
|
|
351
|
+
messageContent.attachments.push(fileData);
|
|
352
|
+
_e.label = 13;
|
|
353
|
+
case 13:
|
|
354
|
+
_b++;
|
|
355
|
+
return [3 /*break*/, 11];
|
|
356
|
+
case 14:
|
|
357
|
+
_i++;
|
|
358
|
+
return [3 /*break*/, 8];
|
|
359
|
+
case 15:
|
|
360
|
+
// Log the parameters before sending
|
|
361
|
+
this.logger.info("Sending message with parameters: ".concat(JSON.stringify(messageContent)));
|
|
362
|
+
// Send the message
|
|
363
|
+
if (!api) {
|
|
364
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Zalo API not initialized');
|
|
365
|
+
}
|
|
366
|
+
_e.label = 16;
|
|
367
|
+
case 16:
|
|
368
|
+
_e.trys.push([16, 18, , 19]);
|
|
369
|
+
recipentObj = {
|
|
370
|
+
id: threadId,
|
|
371
|
+
type: type
|
|
372
|
+
};
|
|
373
|
+
return [4 /*yield*/, api.sendTypingEvent(recipentObj.id, recipentObj.type)];
|
|
374
|
+
case 17:
|
|
375
|
+
result = _e.sent();
|
|
376
|
+
if (!!result) {
|
|
377
|
+
this.logger.info("Send! typing event");
|
|
378
|
+
}
|
|
379
|
+
return [3 /*break*/, 19];
|
|
380
|
+
case 18:
|
|
381
|
+
e_1 = _e.sent();
|
|
382
|
+
this.logger.error("Cannot send typing event");
|
|
383
|
+
return [3 /*break*/, 19];
|
|
384
|
+
case 19: return [4 /*yield*/, api.sendMessage(messageContent, threadId, type)];
|
|
385
|
+
case 20:
|
|
386
|
+
response = _e.sent();
|
|
387
|
+
//Remove temp img
|
|
388
|
+
if (messageContent.attachments && messageContent.attachments.length > 0) {
|
|
389
|
+
for (_c = 0, _d = messageContent.attachments; _c < _d.length; _c++) {
|
|
390
|
+
attachment = _d[_c];
|
|
391
|
+
this.logger.info("Remove attachment: ".concat(attachment));
|
|
392
|
+
(0, helper_1.removeFile)(attachment);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
this.logger.info('Message sent successfully', { threadId: threadId, type: type });
|
|
396
|
+
returnData.push({
|
|
397
|
+
json: {
|
|
398
|
+
success: true,
|
|
399
|
+
response: response,
|
|
400
|
+
threadId: threadId,
|
|
401
|
+
threadType: type,
|
|
402
|
+
messageContent: messageContent,
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
return [3 /*break*/, 22];
|
|
406
|
+
case 21:
|
|
407
|
+
error_2 = _e.sent();
|
|
408
|
+
this.logger.error('Error sending Zalo message:', error_2);
|
|
409
|
+
if (this.continueOnFail()) {
|
|
410
|
+
returnData.push({
|
|
411
|
+
json: {
|
|
412
|
+
success: false,
|
|
413
|
+
error: error_2.message,
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error_2, { itemIndex: i });
|
|
419
|
+
}
|
|
420
|
+
return [3 /*break*/, 22];
|
|
421
|
+
case 22:
|
|
422
|
+
i++;
|
|
423
|
+
return [3 /*break*/, 6];
|
|
424
|
+
case 23: return [2 /*return*/, [returnData]];
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
};
|
|
429
|
+
return ZaloSendMessage;
|
|
430
|
+
}());
|
|
431
|
+
exports.ZaloSendMessage = ZaloSendMessage;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.N8nZaloApi = void 0;
|
|
4
|
+
class N8nZaloApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'n8nZaloApi';
|
|
7
|
+
this.displayName = 'n8n Zalo Account Credential';
|
|
8
|
+
this.documentationUrl = 'n8n-n8n-api';
|
|
9
|
+
this.icon = 'file:shared/n8n.png';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'API Key',
|
|
13
|
+
name: 'apiKey',
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: '',
|
|
16
|
+
description: 'The API key used to authenticate with the n8n API.',
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'URL',
|
|
21
|
+
name: 'url',
|
|
22
|
+
type: 'string',
|
|
23
|
+
default: 'http://127.0.0.1:5678',
|
|
24
|
+
description: 'The URL of the n8n instance',
|
|
25
|
+
required: true,
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.N8nZaloApi = N8nZaloApi;
|
|
31
|
+
//# sourceMappingURL=N8nZaloApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"N8nZaloApi.credentials.js","sourceRoot":"","sources":["../../credentials/N8nZaloApi.credentials.ts"],"names":[],"mappings":";;;AAME,MAAa,UAAU;IAAvB;QACE,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,6BAA6B,CAAC;QAC5C,qBAAgB,GAAG,aAAa,CAAC;QAEjC,SAAI,GAAS,qBAAqB,CAAC;QAEnC,eAAU,GAAsB;YAC9B;gBACE,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,oDAAoD;gBACjE,QAAQ,EAAG,IAAI;aAChB;YACD;gBACE,WAAW,EAAE,KAAK;gBAClB,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uBAAuB;gBAChC,WAAW,EAAE,6BAA6B;gBAC1C,QAAQ,EAAG,IAAI;aAChB;SACF,CAAC;IACJ,CAAC;CAAA;AAzBD,gCAyBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ICredentialType,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
Icon,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
|
|
7
|
+
export class N8nZaloApi implements ICredentialType {
|
|
8
|
+
name = 'n8nZaloApi';
|
|
9
|
+
displayName = 'n8n Zalo Account Credential';
|
|
10
|
+
documentationUrl = 'n8n-n8n-api';
|
|
11
|
+
|
|
12
|
+
icon: Icon = 'file:shared/n8n.png';
|
|
13
|
+
|
|
14
|
+
properties: INodeProperties[] = [
|
|
15
|
+
{
|
|
16
|
+
displayName: 'API Key',
|
|
17
|
+
name: 'apiKey',
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '',
|
|
20
|
+
description: 'The API key used to authenticate with the n8n API.',
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
displayName: 'URL',
|
|
25
|
+
name: 'url',
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: 'http://127.0.0.1:5678',
|
|
28
|
+
description: 'The URL of the n8n instance',
|
|
29
|
+
required: true,
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
@@ -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://developers.zalo.me/docs';
|
|
9
|
+
this.icon = 'file:shared/zalo.svg';
|
|
10
|
+
this.properties = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Cookie',
|
|
13
|
+
name: 'cookie',
|
|
14
|
+
type: 'string',
|
|
15
|
+
default: '',
|
|
16
|
+
typeOptions: {
|
|
17
|
+
password: true,
|
|
18
|
+
},
|
|
19
|
+
description: 'Cookie from Zalo login session',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
displayName: 'IMEI',
|
|
23
|
+
name: 'imei',
|
|
24
|
+
type: 'string',
|
|
25
|
+
default: '',
|
|
26
|
+
description: 'IMEI identifier from Zalo login session',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'User Agent',
|
|
30
|
+
name: 'userAgent',
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: '',
|
|
33
|
+
description: 'User Agent from Zalo login session',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Proxy',
|
|
37
|
+
name: 'proxy',
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: '',
|
|
40
|
+
placeholder: 'http(s)://user:pass@host:port',
|
|
41
|
+
description: 'HTTP proxy to use for Zalo API requests',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Support Code',
|
|
45
|
+
name: 'supportCode',
|
|
46
|
+
type: 'string',
|
|
47
|
+
default: '',
|
|
48
|
+
description: 'Support code for Zalo API',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'License Key',
|
|
52
|
+
name: 'licenseKey',
|
|
53
|
+
type: 'string',
|
|
54
|
+
default: '',
|
|
55
|
+
description: 'License key for Zalo API',
|
|
56
|
+
typeOptions: {
|
|
57
|
+
password: true,
|
|
58
|
+
},
|
|
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":";;;AAMA,MAAa,OAAO;IAApB;QACC,SAAI,GAAG,SAAS,CAAC;QACjB,gBAAW,GAAG,UAAU,CAAC;QACzB,qBAAgB,GAAG,iCAAiC,CAAC;QAErD,SAAI,GAAS,sBAAsB,CAAC;QAEpC,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,QAAQ;gBACrB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,WAAW,EAAE,gCAAgC;aAC7C;YACD;gBACC,WAAW,EAAE,MAAM;gBACnB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,yCAAyC;aACtD;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,oCAAoC;aACjD;YACD;gBACC,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,+BAA+B;gBAC5C,WAAW,EAAE,yCAAyC;aACtD;YACD;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,2BAA2B;aACxC;YACD;gBACC,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,0BAA0B;gBACvC,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;aACD;SACD,CAAC;IAEH,CAAC;CAAA;AA3DD,0BA2DC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ICredentialType,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
Icon,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
|
|
7
|
+
export class ZaloApi implements ICredentialType {
|
|
8
|
+
name = 'zaloApi';
|
|
9
|
+
displayName = 'Zalo API';
|
|
10
|
+
documentationUrl = 'https://developers.zalo.me/docs';
|
|
11
|
+
|
|
12
|
+
icon: Icon = 'file:shared/zalo.svg';
|
|
13
|
+
|
|
14
|
+
properties: INodeProperties[] = [
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Cookie',
|
|
17
|
+
name: 'cookie',
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '',
|
|
20
|
+
typeOptions: {
|
|
21
|
+
password: true,
|
|
22
|
+
},
|
|
23
|
+
description: 'Cookie from Zalo login session',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'IMEI',
|
|
27
|
+
name: 'imei',
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: '',
|
|
30
|
+
description: 'IMEI identifier from Zalo login session',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
displayName: 'User Agent',
|
|
34
|
+
name: 'userAgent',
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: '',
|
|
37
|
+
description: 'User Agent from Zalo login session',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Proxy',
|
|
41
|
+
name: 'proxy',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: '',
|
|
44
|
+
placeholder: 'http(s)://user:pass@host:port',
|
|
45
|
+
description: 'HTTP proxy to use for Zalo API requests',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Support Code',
|
|
49
|
+
name: 'supportCode',
|
|
50
|
+
type: 'string',
|
|
51
|
+
default: '',
|
|
52
|
+
description: 'Support code for Zalo API',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
displayName: 'License Key',
|
|
56
|
+
name: 'licenseKey',
|
|
57
|
+
type: 'string',
|
|
58
|
+
default: '',
|
|
59
|
+
description: 'License key for Zalo API',
|
|
60
|
+
typeOptions: {
|
|
61
|
+
password: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.782 0.166016H27.199C33.2653 0.166016 36.8103 1.05701 39.9572 2.74421C43.1041 4.4314 45.5875 6.89585 47.2557 10.0428C48.9429 13.1897 49.8339 16.7347 49.8339 22.801V27.1991C49.8339 33.2654 48.9429 36.8104 47.2557 39.9573C45.5685 43.1042 43.1041 45.5877 39.9572 47.2559C36.8103 48.9431 33.2653 49.8341 27.199 49.8341H22.8009C16.7346 49.8341 13.1896 48.9431 10.0427 47.2559C6.89583 45.5687 4.41243 43.1042 2.7442 39.9573C1.057 36.8104 0.166016 33.2654 0.166016 27.1991V22.801C0.166016 16.7347 1.057 13.1897 2.7442 10.0428C4.43139 6.89585 6.89583 4.41245 10.0427 2.74421C13.1707 1.05701 16.7346 0.166016 22.782 0.166016Z" fill="#0068FF"/>
|
|
3
|
+
<path opacity="0.12" fill-rule="evenodd" clip-rule="evenodd" d="M49.8336 26.4736V27.1994C49.8336 33.2657 48.9427 36.8107 47.2555 39.9576C45.5683 43.1045 43.1038 45.5879 39.9569 47.2562C36.81 48.9434 33.265 49.8344 27.1987 49.8344H22.8007C17.8369 49.8344 14.5612 49.2378 11.8104 48.0966L7.27539 43.4267L49.8336 26.4736Z" fill="#001A33"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.779 43.5892C10.1019 43.846 13.0061 43.1836 15.0682 42.1825C24.0225 47.1318 38.0197 46.8954 46.4923 41.4732C46.8209 40.9803 47.1279 40.4677 47.4128 39.9363C49.1062 36.7779 50.0004 33.22 50.0004 27.1316V22.7175C50.0004 16.629 49.1062 13.0711 47.4128 9.91273C45.7385 6.75436 43.2461 4.28093 40.0877 2.58758C36.9293 0.894239 33.3714 0 27.283 0H22.8499C17.6644 0 14.2982 0.652754 11.4699 1.89893C11.3153 2.03737 11.1636 2.17818 11.0151 2.32135C2.71734 10.3203 2.08658 27.6593 9.12279 37.0782C9.13064 37.0921 9.13933 37.1061 9.14889 37.1203C10.2334 38.7185 9.18694 41.5154 7.55068 43.1516C7.28431 43.399 7.37944 43.5512 7.779 43.5892Z" fill="white"/>
|
|
5
|
+
<path d="M20.5632 17H10.8382V19.0853H17.5869L10.9329 27.3317C10.7244 27.635 10.5728 27.9194 10.5728 28.5639V29.0947H19.748C20.203 29.0947 20.5822 28.7156 20.5822 28.2606V27.1421H13.4922L19.748 19.2938C19.8428 19.1801 20.0134 18.9716 20.0893 18.8768L20.1272 18.8199C20.4874 18.2891 20.5632 17.8341 20.5632 17.2844V17Z" fill="#0068FF"/>
|
|
6
|
+
<path d="M32.9416 29.0947H34.3255V17H32.2402V28.3933C32.2402 28.7725 32.5435 29.0947 32.9416 29.0947Z" fill="#0068FF"/>
|
|
7
|
+
<path d="M25.814 19.6924C23.1979 19.6924 21.0747 21.8156 21.0747 24.4317C21.0747 27.0478 23.1979 29.171 25.814 29.171C28.4301 29.171 30.5533 27.0478 30.5533 24.4317C30.5723 21.8156 28.4491 19.6924 25.814 19.6924ZM25.814 27.2184C24.2785 27.2184 23.0273 25.9672 23.0273 24.4317C23.0273 22.8962 24.2785 21.645 25.814 21.645C27.3495 21.645 28.6007 22.8962 28.6007 24.4317C28.6007 25.9672 27.3685 27.2184 25.814 27.2184Z" fill="#0068FF"/>
|
|
8
|
+
<path d="M40.4867 19.6162C37.8516 19.6162 35.7095 21.7584 35.7095 24.3934C35.7095 27.0285 37.8516 29.1707 40.4867 29.1707C43.1217 29.1707 45.2639 27.0285 45.2639 24.3934C45.2639 21.7584 43.1217 19.6162 40.4867 19.6162ZM40.4867 27.2181C38.9322 27.2181 37.681 25.9669 37.681 24.4124C37.681 22.8579 38.9322 21.6067 40.4867 21.6067C42.0412 21.6067 43.2924 22.8579 43.2924 24.4124C43.2924 25.9669 42.0412 27.2181 40.4867 27.2181Z" fill="#0068FF"/>
|
|
9
|
+
<path d="M29.4562 29.0944H30.5747V19.957H28.6221V28.2793C28.6221 28.7153 29.0012 29.0944 29.4562 29.0944Z" fill="#0068FF"/>
|
|
10
|
+
</svg>
|