@kichat/n8n-nodes-kirimchat 1.2.6 → 1.2.7

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.
@@ -653,6 +653,89 @@ class KirimChat {
653
653
  description: 'Text displayed on the button to open the list (max 20 characters)',
654
654
  placeholder: 'View Options',
655
655
  },
656
+ {
657
+ displayName: 'Use Advanced Mode (JSON)',
658
+ name: 'listAdvancedMode',
659
+ type: 'boolean',
660
+ displayOptions: {
661
+ show: {
662
+ operation: ['sendMessage'],
663
+ messageType: ['interactive'],
664
+ interactiveType: ['list'],
665
+ },
666
+ },
667
+ default: false,
668
+ description: 'Enable to enter sections as JSON (for multiple sections). Disable for simple form input.',
669
+ },
670
+ // Simple mode fields
671
+ {
672
+ displayName: 'Section Title',
673
+ name: 'listSectionTitle',
674
+ type: 'string',
675
+ displayOptions: {
676
+ show: {
677
+ operation: ['sendMessage'],
678
+ messageType: ['interactive'],
679
+ interactiveType: ['list'],
680
+ listAdvancedMode: [false],
681
+ },
682
+ },
683
+ default: '',
684
+ description: 'Optional title for the section (max 24 characters)',
685
+ placeholder: 'Choose an option',
686
+ },
687
+ {
688
+ displayName: 'List Items',
689
+ name: 'listItems',
690
+ type: 'fixedCollection',
691
+ typeOptions: {
692
+ multipleValues: true,
693
+ maxValue: 10,
694
+ },
695
+ displayOptions: {
696
+ show: {
697
+ operation: ['sendMessage'],
698
+ messageType: ['interactive'],
699
+ interactiveType: ['list'],
700
+ listAdvancedMode: [false],
701
+ },
702
+ },
703
+ default: { items: [] },
704
+ description: 'Add up to 10 items to the list',
705
+ options: [
706
+ {
707
+ name: 'items',
708
+ displayName: 'Items',
709
+ values: [
710
+ {
711
+ displayName: 'ID',
712
+ name: 'id',
713
+ type: 'string',
714
+ default: '',
715
+ description: 'Unique identifier for this item (max 200 chars)',
716
+ placeholder: 'item-1',
717
+ },
718
+ {
719
+ displayName: 'Title',
720
+ name: 'title',
721
+ type: 'string',
722
+ default: '',
723
+ description: 'Display title for this item (max 24 chars)',
724
+ placeholder: 'Option 1',
725
+ },
726
+ {
727
+ displayName: 'Description',
728
+ name: 'description',
729
+ type: 'string',
730
+ default: '',
731
+ description: 'Optional description (max 72 chars)',
732
+ placeholder: 'Description of option 1',
733
+ },
734
+ ],
735
+ },
736
+ ],
737
+ },
738
+ // Advanced mode (JSON)
656
739
  {
657
740
  displayName: 'Sections (JSON)',
658
741
  name: 'listSections',
@@ -663,6 +746,7 @@ class KirimChat {
663
746
  operation: ['sendMessage'],
664
747
  messageType: ['interactive'],
665
748
  interactiveType: ['list'],
749
+ listAdvancedMode: [true],
666
750
  },
667
751
  },
668
752
  default: '[{"title": "Category 1", "rows": [{"id": "item1", "title": "Option 1", "description": "Description 1"}]}]',
@@ -1255,7 +1339,7 @@ class KirimChat {
1255
1339
  }
1256
1340
  else if (interactiveType === 'list') {
1257
1341
  const listButtonText = this.getNodeParameter('listButtonText', i);
1258
- const listSectionsJson = this.getNodeParameter('listSections', i);
1342
+ const advancedMode = this.getNodeParameter('listAdvancedMode', i, false);
1259
1343
  if (!listButtonText) {
1260
1344
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'List Button Text is required for list interactive messages', { itemIndex: i });
1261
1345
  }
@@ -1263,23 +1347,67 @@ class KirimChat {
1263
1347
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `List Button Text exceeds maximum length of 20 characters (current: ${listButtonText.length})`, { itemIndex: i });
1264
1348
  }
1265
1349
  let listSections;
1266
- try {
1267
- listSections = JSON.parse(listSectionsJson);
1268
- }
1269
- catch (error) {
1270
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON in List Sections: ${error instanceof Error ? error.message : 'Parse failed'}`, { itemIndex: i });
1271
- }
1272
- if (!Array.isArray(listSections) || listSections.length === 0 || listSections.length > 10) {
1273
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'List Sections must be a JSON array with 1-10 sections. Example: [{"title": "Category", "rows": [{"id": "1", "title": "Option 1"}]}]', { itemIndex: i });
1350
+ if (advancedMode) {
1351
+ // Advanced mode: parse JSON
1352
+ const listSectionsJson = this.getNodeParameter('listSections', i);
1353
+ try {
1354
+ listSections = JSON.parse(listSectionsJson);
1355
+ }
1356
+ catch (error) {
1357
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON in List Sections: ${error instanceof Error ? error.message : 'Parse failed'}`, { itemIndex: i });
1358
+ }
1359
+ if (!Array.isArray(listSections) || listSections.length === 0 || listSections.length > 10) {
1360
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'List Sections must be a JSON array with 1-10 sections. Example: [{"title": "Category", "rows": [{"id": "1", "title": "Option 1"}]}]', { itemIndex: i });
1361
+ }
1362
+ // Validate sections structure
1363
+ for (const section of listSections) {
1364
+ if (!section.rows || !Array.isArray(section.rows) || section.rows.length === 0) {
1365
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Each section must have a "rows" array with at least 1 row', { itemIndex: i });
1366
+ }
1367
+ if (section.rows.length > 10) {
1368
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Each section can have maximum 10 rows', { itemIndex: i });
1369
+ }
1370
+ }
1274
1371
  }
1275
- // Validate sections structure
1276
- for (const section of listSections) {
1277
- if (!section.rows || !Array.isArray(section.rows) || section.rows.length === 0) {
1278
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Each section must have a "rows" array with at least 1 row', { itemIndex: i });
1372
+ else {
1373
+ // Simple mode: build from form fields
1374
+ const sectionTitle = this.getNodeParameter('listSectionTitle', i, '');
1375
+ const listItemsData = this.getNodeParameter('listItems', i, { items: [] });
1376
+ if (!listItemsData.items || listItemsData.items.length === 0) {
1377
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one list item is required', { itemIndex: i });
1279
1378
  }
1280
- if (section.rows.length > 10) {
1281
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Each section can have maximum 10 rows', { itemIndex: i });
1379
+ // Validate and build rows
1380
+ const rows = listItemsData.items.map((item, index) => {
1381
+ if (!item.id || !item.title) {
1382
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `List item ${index + 1}: ID and Title are required`, { itemIndex: i });
1383
+ }
1384
+ if (item.id.length > 200) {
1385
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `List item ${index + 1}: ID exceeds maximum length of 200 characters`, { itemIndex: i });
1386
+ }
1387
+ if (item.title.length > 24) {
1388
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `List item ${index + 1}: Title exceeds maximum length of 24 characters`, { itemIndex: i });
1389
+ }
1390
+ if (item.description && item.description.length > 72) {
1391
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `List item ${index + 1}: Description exceeds maximum length of 72 characters`, { itemIndex: i });
1392
+ }
1393
+ const row = {
1394
+ id: item.id,
1395
+ title: item.title,
1396
+ };
1397
+ if (item.description) {
1398
+ row.description = item.description;
1399
+ }
1400
+ return row;
1401
+ });
1402
+ // Build single section
1403
+ const section = { rows };
1404
+ if (sectionTitle) {
1405
+ if (sectionTitle.length > 24) {
1406
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Section Title exceeds maximum length of 24 characters`, { itemIndex: i });
1407
+ }
1408
+ section.title = sectionTitle;
1282
1409
  }
1410
+ listSections = [section];
1283
1411
  }
1284
1412
  interactive.action = {
1285
1413
  button: listButtonText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kichat/n8n-nodes-kirimchat",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "n8n community node for KirimChat - Send WhatsApp, Instagram & Messenger messages with interactive buttons, flexible customer lookup, and typing indicators",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",