@connectorx/n8n-nodes-cortex 0.1.17 → 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 +89 -15
- 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',
|
|
@@ -430,16 +478,42 @@ class Cortex {
|
|
|
430
478
|
const conversationId = this.getNodeParameter('conversationId', i);
|
|
431
479
|
if (operation === 'send') {
|
|
432
480
|
options.uri = `${baseUrl}/messages/send`;
|
|
433
|
-
const content = this.getNodeParameter('content', i);
|
|
434
481
|
const msgType = this.getNodeParameter('msg_type', i);
|
|
435
482
|
const senderId = this.getNodeParameter('sender_id', i);
|
|
436
483
|
const replyTo = this.getNodeParameter('reply_to_message_id', i);
|
|
437
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
|
+
}
|
|
438
510
|
const body = {
|
|
439
511
|
conversation_id: conversationId,
|
|
440
512
|
content: content,
|
|
441
513
|
type: msgType,
|
|
442
514
|
};
|
|
515
|
+
if (caption)
|
|
516
|
+
body.caption = caption;
|
|
443
517
|
if (senderId)
|
|
444
518
|
body.sender_id = senderId;
|
|
445
519
|
if (replyTo)
|