@connectorx/n8n-nodes-cortex 0.1.16 → 0.1.18
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/dist/nodes/Cortex/Cortex.node.js +99 -23
- package/package.json +1 -1
|
@@ -142,20 +142,6 @@ class Cortex {
|
|
|
142
142
|
default: '',
|
|
143
143
|
description: 'The UUID of the contact',
|
|
144
144
|
},
|
|
145
|
-
{
|
|
146
|
-
displayName: 'Content (Text, URL, or Template JSON)',
|
|
147
|
-
name: 'content',
|
|
148
|
-
type: 'string',
|
|
149
|
-
required: true,
|
|
150
|
-
displayOptions: {
|
|
151
|
-
show: {
|
|
152
|
-
resource: ['message'],
|
|
153
|
-
operation: ['send'],
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
default: '',
|
|
157
|
-
description: 'Message text, media URL, or JSON string for templates',
|
|
158
|
-
},
|
|
159
145
|
{
|
|
160
146
|
displayName: 'Message Type',
|
|
161
147
|
name: 'msg_type',
|
|
@@ -179,6 +165,68 @@ class Cortex {
|
|
|
179
165
|
],
|
|
180
166
|
default: 'text',
|
|
181
167
|
},
|
|
168
|
+
{
|
|
169
|
+
displayName: 'Message Content',
|
|
170
|
+
name: 'content_text',
|
|
171
|
+
type: 'string',
|
|
172
|
+
required: true,
|
|
173
|
+
displayOptions: {
|
|
174
|
+
show: {
|
|
175
|
+
resource: ['message'],
|
|
176
|
+
operation: ['send'],
|
|
177
|
+
msg_type: ['text', 'internal_note', 'reaction'],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
default: '',
|
|
181
|
+
description: 'The text content of the message',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
displayName: 'Media URL',
|
|
185
|
+
name: 'content_media',
|
|
186
|
+
type: 'string',
|
|
187
|
+
required: true,
|
|
188
|
+
displayOptions: {
|
|
189
|
+
show: {
|
|
190
|
+
resource: ['message'],
|
|
191
|
+
operation: ['send'],
|
|
192
|
+
msg_type: ['image', 'video', 'audio', 'voice', 'document'],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
default: '',
|
|
196
|
+
description: 'URL of the media file',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
displayName: 'Caption',
|
|
200
|
+
name: 'caption',
|
|
201
|
+
type: 'string',
|
|
202
|
+
displayOptions: {
|
|
203
|
+
show: {
|
|
204
|
+
resource: ['message'],
|
|
205
|
+
operation: ['send'],
|
|
206
|
+
msg_type: ['image', 'video', 'document'],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
default: '',
|
|
210
|
+
description: 'Optional caption for the media',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Template JSON',
|
|
214
|
+
name: 'template_json',
|
|
215
|
+
type: 'json',
|
|
216
|
+
required: true,
|
|
217
|
+
displayOptions: {
|
|
218
|
+
show: {
|
|
219
|
+
resource: ['message'],
|
|
220
|
+
operation: ['send'],
|
|
221
|
+
msg_type: ['template'],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
default: '{\n "name": "template_name",\n "language": "pt_BR",\n "components": [\n {\n "type": "BODY",\n "parameters": [\n {\n "type": "text",\n "text": "variable_value"\n }\n ]\n }\n ]\n}',
|
|
225
|
+
description: 'JSON structure for the WhatsApp template',
|
|
226
|
+
typeOptions: {
|
|
227
|
+
alwaysOpenEditWindow: true,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
182
230
|
{
|
|
183
231
|
displayName: 'Sender ID',
|
|
184
232
|
name: 'sender_id',
|
|
@@ -371,10 +419,11 @@ class Cortex {
|
|
|
371
419
|
};
|
|
372
420
|
try {
|
|
373
421
|
const response = await this.helpers.request(options);
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
422
|
+
const data = Array.isArray(response) ? response : (response.data || response.columns || []);
|
|
423
|
+
return data.map((c) => ({
|
|
424
|
+
name: c.title || c.name || c.id || c.column_id || 'Unknown Column',
|
|
425
|
+
value: c.id || c.column_id
|
|
426
|
+
})).filter(c => c.value);
|
|
378
427
|
}
|
|
379
428
|
catch (error) {
|
|
380
429
|
return [];
|
|
@@ -394,10 +443,11 @@ class Cortex {
|
|
|
394
443
|
};
|
|
395
444
|
try {
|
|
396
445
|
const response = await this.helpers.request(options);
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
446
|
+
const data = Array.isArray(response) ? response : (response.data || response.users || []);
|
|
447
|
+
return data.map((u) => ({
|
|
448
|
+
name: u.name || u.email || u.id || u.user_id || 'Unknown User',
|
|
449
|
+
value: u.id || u.user_id
|
|
450
|
+
})).filter(u => u.value);
|
|
401
451
|
}
|
|
402
452
|
catch (error) {
|
|
403
453
|
return [];
|
|
@@ -428,16 +478,42 @@ class Cortex {
|
|
|
428
478
|
const conversationId = this.getNodeParameter('conversationId', i);
|
|
429
479
|
if (operation === 'send') {
|
|
430
480
|
options.uri = `${baseUrl}/messages/send`;
|
|
431
|
-
const content = this.getNodeParameter('content', i);
|
|
432
481
|
const msgType = this.getNodeParameter('msg_type', i);
|
|
433
482
|
const senderId = this.getNodeParameter('sender_id', i);
|
|
434
483
|
const replyTo = this.getNodeParameter('reply_to_message_id', i);
|
|
435
484
|
const reactTo = this.getNodeParameter('react_to_message_id', i);
|
|
485
|
+
let content = '';
|
|
486
|
+
let caption = '';
|
|
487
|
+
if (['text', 'internal_note', 'reaction'].includes(msgType)) {
|
|
488
|
+
content = this.getNodeParameter('content_text', i);
|
|
489
|
+
}
|
|
490
|
+
else if (['image', 'video', 'audio', 'voice', 'document'].includes(msgType)) {
|
|
491
|
+
content = this.getNodeParameter('content_media', i);
|
|
492
|
+
if (['image', 'video', 'document'].includes(msgType)) {
|
|
493
|
+
caption = this.getNodeParameter('caption', i);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else if (msgType === 'template') {
|
|
497
|
+
const templateJson = this.getNodeParameter('template_json', i);
|
|
498
|
+
if (typeof templateJson === 'string') {
|
|
499
|
+
try {
|
|
500
|
+
content = JSON.parse(templateJson);
|
|
501
|
+
}
|
|
502
|
+
catch (e) {
|
|
503
|
+
throw new Error('Invalid JSON in Template JSON field');
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
content = templateJson;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
436
510
|
const body = {
|
|
437
511
|
conversation_id: conversationId,
|
|
438
512
|
content: content,
|
|
439
513
|
type: msgType,
|
|
440
514
|
};
|
|
515
|
+
if (caption)
|
|
516
|
+
body.caption = caption;
|
|
441
517
|
if (senderId)
|
|
442
518
|
body.sender_id = senderId;
|
|
443
519
|
if (replyTo)
|