n8n-nodes-whaapy 0.3.2 → 0.3.3
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/Whaapy/Whaapy.node.js +39 -81
- package/package.json +1 -1
|
@@ -17,10 +17,6 @@ function slugify(text) {
|
|
|
17
17
|
}
|
|
18
18
|
// Build interactive message payload from structured fields
|
|
19
19
|
function buildInteractivePayload(params) {
|
|
20
|
-
// If using raw JSON, return it directly
|
|
21
|
-
if (params.useRawJson && params.rawJson) {
|
|
22
|
-
return params.rawJson;
|
|
23
|
-
}
|
|
24
20
|
const interactive = {
|
|
25
21
|
type: params.interactiveType,
|
|
26
22
|
body: {
|
|
@@ -318,7 +314,7 @@ class Whaapy {
|
|
|
318
314
|
default: 'button',
|
|
319
315
|
description: 'Type of interactive message. Buttons show up to 3 options, Lists show a menu with sections.',
|
|
320
316
|
displayOptions: {
|
|
321
|
-
show: { resource: ['message'], operation: ['send'], messageType: ['interactive']
|
|
317
|
+
show: { resource: ['message'], operation: ['send'], messageType: ['interactive'] },
|
|
322
318
|
},
|
|
323
319
|
},
|
|
324
320
|
// Interactive: Body text (required)
|
|
@@ -332,7 +328,7 @@ class Whaapy {
|
|
|
332
328
|
placeholder: '¿Cómo podemos ayudarte hoy?',
|
|
333
329
|
description: 'Main text of the message. Max 1024 characters.',
|
|
334
330
|
displayOptions: {
|
|
335
|
-
show: { resource: ['message'], operation: ['send'], messageType: ['interactive']
|
|
331
|
+
show: { resource: ['message'], operation: ['send'], messageType: ['interactive'] },
|
|
336
332
|
},
|
|
337
333
|
},
|
|
338
334
|
// Interactive: Header type (optional)
|
|
@@ -350,7 +346,7 @@ class Whaapy {
|
|
|
350
346
|
],
|
|
351
347
|
description: 'Optional header for the message',
|
|
352
348
|
displayOptions: {
|
|
353
|
-
show: { resource: ['message'], operation: ['send'], messageType: ['interactive']
|
|
349
|
+
show: { resource: ['message'], operation: ['send'], messageType: ['interactive'] },
|
|
354
350
|
},
|
|
355
351
|
},
|
|
356
352
|
// Interactive: Header text (if type=text)
|
|
@@ -367,7 +363,6 @@ class Whaapy {
|
|
|
367
363
|
operation: ['send'],
|
|
368
364
|
messageType: ['interactive'],
|
|
369
365
|
interactiveHeaderType: ['text'],
|
|
370
|
-
interactiveUseRawJson: [false],
|
|
371
366
|
},
|
|
372
367
|
},
|
|
373
368
|
},
|
|
@@ -385,7 +380,6 @@ class Whaapy {
|
|
|
385
380
|
operation: ['send'],
|
|
386
381
|
messageType: ['interactive'],
|
|
387
382
|
interactiveHeaderType: ['image', 'video', 'document'],
|
|
388
|
-
interactiveUseRawJson: [false],
|
|
389
383
|
},
|
|
390
384
|
},
|
|
391
385
|
},
|
|
@@ -398,7 +392,7 @@ class Whaapy {
|
|
|
398
392
|
placeholder: 'Responde con una opción',
|
|
399
393
|
description: 'Optional footer text in gray. Max 60 characters. Leave empty to omit.',
|
|
400
394
|
displayOptions: {
|
|
401
|
-
show: { resource: ['message'], operation: ['send'], messageType: ['interactive']
|
|
395
|
+
show: { resource: ['message'], operation: ['send'], messageType: ['interactive'] },
|
|
402
396
|
},
|
|
403
397
|
},
|
|
404
398
|
// Interactive: Buttons (if type=button)
|
|
@@ -418,7 +412,6 @@ class Whaapy {
|
|
|
418
412
|
operation: ['send'],
|
|
419
413
|
messageType: ['interactive'],
|
|
420
414
|
interactiveType: ['button'],
|
|
421
|
-
interactiveUseRawJson: [false],
|
|
422
415
|
},
|
|
423
416
|
},
|
|
424
417
|
options: [
|
|
@@ -462,7 +455,6 @@ class Whaapy {
|
|
|
462
455
|
operation: ['send'],
|
|
463
456
|
messageType: ['interactive'],
|
|
464
457
|
interactiveType: ['list'],
|
|
465
|
-
interactiveUseRawJson: [false],
|
|
466
458
|
},
|
|
467
459
|
},
|
|
468
460
|
},
|
|
@@ -483,7 +475,6 @@ class Whaapy {
|
|
|
483
475
|
operation: ['send'],
|
|
484
476
|
messageType: ['interactive'],
|
|
485
477
|
interactiveType: ['list'],
|
|
486
|
-
interactiveUseRawJson: [false],
|
|
487
478
|
},
|
|
488
479
|
},
|
|
489
480
|
options: [
|
|
@@ -547,32 +538,6 @@ class Whaapy {
|
|
|
547
538
|
},
|
|
548
539
|
],
|
|
549
540
|
},
|
|
550
|
-
// Interactive: Advanced JSON (fallback for complex cases)
|
|
551
|
-
{
|
|
552
|
-
displayName: 'Use Raw JSON',
|
|
553
|
-
name: 'interactiveUseRawJson',
|
|
554
|
-
type: 'boolean',
|
|
555
|
-
default: false,
|
|
556
|
-
description: 'Use raw JSON instead of structured fields (for advanced use cases)',
|
|
557
|
-
displayOptions: {
|
|
558
|
-
show: { resource: ['message'], operation: ['send'], messageType: ['interactive'] },
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
displayName: 'Interactive JSON',
|
|
563
|
-
name: 'interactiveRawJson',
|
|
564
|
-
type: 'json',
|
|
565
|
-
default: '{}',
|
|
566
|
-
description: 'Raw interactive content JSON. See docs.whaapy.com for structure.',
|
|
567
|
-
displayOptions: {
|
|
568
|
-
show: {
|
|
569
|
-
resource: ['message'],
|
|
570
|
-
operation: ['send'],
|
|
571
|
-
messageType: ['interactive'],
|
|
572
|
-
interactiveUseRawJson: [true],
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
541
|
// Message: Send - Location
|
|
577
542
|
{
|
|
578
543
|
displayName: 'Latitude',
|
|
@@ -1713,52 +1678,45 @@ class Whaapy {
|
|
|
1713
1678
|
}
|
|
1714
1679
|
else if (messageType === 'interactive') {
|
|
1715
1680
|
// Build interactive message from structured fields
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1681
|
+
const interactiveType = this.getNodeParameter('interactiveType', i);
|
|
1682
|
+
const bodyText = this.getNodeParameter('interactiveBodyText', i);
|
|
1683
|
+
const headerType = this.getNodeParameter('interactiveHeaderType', i, 'none');
|
|
1684
|
+
const headerText = this.getNodeParameter('interactiveHeaderText', i, '');
|
|
1685
|
+
const headerMediaUrl = this.getNodeParameter('interactiveHeaderMediaUrl', i, '');
|
|
1686
|
+
const footerText = this.getNodeParameter('interactiveFooterText', i, '');
|
|
1687
|
+
// Build buttons array
|
|
1688
|
+
let buttons = [];
|
|
1689
|
+
if (interactiveType === 'button') {
|
|
1690
|
+
const buttonsData = this.getNodeParameter('interactiveButtons', i, { buttonValues: [] });
|
|
1691
|
+
buttons = buttonsData.buttonValues || [];
|
|
1720
1692
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
}
|
|
1734
|
-
// Build sections array
|
|
1735
|
-
let sections = [];
|
|
1736
|
-
let listButtonText = '';
|
|
1737
|
-
if (interactiveType === 'list') {
|
|
1738
|
-
listButtonText = this.getNodeParameter('interactiveListButtonText', i, 'Ver Opciones');
|
|
1739
|
-
const sectionsData = this.getNodeParameter('interactiveSections', i, { sectionValues: [] });
|
|
1740
|
-
if (sectionsData.sectionValues) {
|
|
1741
|
-
sections = sectionsData.sectionValues.map((section) => {
|
|
1742
|
-
var _a;
|
|
1743
|
-
return ({
|
|
1744
|
-
title: section.title,
|
|
1745
|
-
rows: ((_a = section.rows) === null || _a === void 0 ? void 0 : _a.rowValues) || [],
|
|
1746
|
-
});
|
|
1693
|
+
// Build sections array
|
|
1694
|
+
let sections = [];
|
|
1695
|
+
let listButtonText = '';
|
|
1696
|
+
if (interactiveType === 'list') {
|
|
1697
|
+
listButtonText = this.getNodeParameter('interactiveListButtonText', i, 'Ver Opciones');
|
|
1698
|
+
const sectionsData = this.getNodeParameter('interactiveSections', i, { sectionValues: [] });
|
|
1699
|
+
if (sectionsData.sectionValues) {
|
|
1700
|
+
sections = sectionsData.sectionValues.map((section) => {
|
|
1701
|
+
var _a;
|
|
1702
|
+
return ({
|
|
1703
|
+
title: section.title,
|
|
1704
|
+
rows: ((_a = section.rows) === null || _a === void 0 ? void 0 : _a.rowValues) || [],
|
|
1747
1705
|
});
|
|
1748
|
-
}
|
|
1706
|
+
});
|
|
1749
1707
|
}
|
|
1750
|
-
body.interactive = buildInteractivePayload({
|
|
1751
|
-
interactiveType,
|
|
1752
|
-
bodyText,
|
|
1753
|
-
headerType,
|
|
1754
|
-
headerText,
|
|
1755
|
-
headerMediaUrl,
|
|
1756
|
-
footerText,
|
|
1757
|
-
buttons,
|
|
1758
|
-
listButtonText,
|
|
1759
|
-
sections,
|
|
1760
|
-
});
|
|
1761
1708
|
}
|
|
1709
|
+
body.interactive = buildInteractivePayload({
|
|
1710
|
+
interactiveType,
|
|
1711
|
+
bodyText,
|
|
1712
|
+
headerType,
|
|
1713
|
+
headerText,
|
|
1714
|
+
headerMediaUrl,
|
|
1715
|
+
footerText,
|
|
1716
|
+
buttons,
|
|
1717
|
+
listButtonText,
|
|
1718
|
+
sections,
|
|
1719
|
+
});
|
|
1762
1720
|
}
|
|
1763
1721
|
else if (messageType === 'location') {
|
|
1764
1722
|
body.location = {
|