@kichat/n8n-nodes-kirimchat 1.2.1 → 1.2.2

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/README.md CHANGED
@@ -70,23 +70,25 @@ Templates can be selected from a dropdown (loaded from your KirimChat account) o
70
70
  **Dropdown Mode (Recommended):**
71
71
  | Parameter | Description |
72
72
  |-----------|-------------|
73
- | Template | Select from your approved templates (auto-loads from API) |
74
- | Template Variables | Add values for {{1}}, {{2}}, etc. in order |
73
+ | Template | Select from approved templates. Shows variable count e.g. `[2 var]` |
74
+ | Variable 1-5 | Values for {{1}}, {{2}}, etc. Leave empty if not needed |
75
75
 
76
76
  **Manual Mode:**
77
77
  | Parameter | Description |
78
78
  |-----------|-------------|
79
+ | Enter Template Manually | Enable this toggle |
79
80
  | Template Name | Name of the approved template |
80
81
  | Template Language | Language code (e.g., `en`, `id`) |
81
- | Template Components | JSON array for advanced use cases |
82
+ | Variable 1-5 | Values for {{1}}, {{2}}, etc. |
83
+ | Template Components (JSON) | Advanced: For header media, buttons |
82
84
 
83
- **Simple Variables Example:**
85
+ **Example:**
84
86
 
85
87
  If your template is: `Hello {{1}}, your order {{2}} is ready!`
86
88
 
87
- Just add two variables in order:
88
- 1. `John` (replaces {{1}})
89
- 2. `ORD-123` (replaces {{2}})
89
+ Fill in:
90
+ - Variable 1: `John` replaces {{1}}
91
+ - Variable 2: `ORD-123` replaces {{2}}
90
92
 
91
93
  **Advanced Template Components (Manual Mode):**
92
94
  ```json
@@ -390,21 +390,21 @@ class KirimChat {
390
390
  displayName: 'Template',
391
391
  name: 'templateSelect',
392
392
  type: 'options',
393
- required: true,
394
393
  displayOptions: {
395
394
  show: {
396
395
  operation: ['sendMessage'],
397
396
  messageType: ['template'],
397
+ templateManualEntry: [false],
398
398
  },
399
399
  },
400
400
  typeOptions: {
401
401
  loadOptionsMethod: 'getTemplates',
402
402
  },
403
403
  default: '',
404
- description: 'Select an approved WhatsApp template. Templates are loaded from your KirimChat account.',
404
+ description: 'Select an approved WhatsApp template. Number in brackets shows variable count (e.g. [2 var] means 2 variables).',
405
405
  },
406
406
  {
407
- displayName: 'Or Enter Template Name Manually',
407
+ displayName: 'Enter Template Manually',
408
408
  name: 'templateManualEntry',
409
409
  type: 'boolean',
410
410
  displayOptions: {
@@ -414,7 +414,7 @@ class KirimChat {
414
414
  },
415
415
  },
416
416
  default: false,
417
- description: 'Enable to manually enter template name and language instead of selecting from dropdown',
417
+ description: 'Enable to manually enter template name and language',
418
418
  },
419
419
  {
420
420
  displayName: 'Template Name',
@@ -449,39 +449,72 @@ class KirimChat {
449
449
  placeholder: 'en',
450
450
  },
451
451
  {
452
- displayName: 'Template Variables',
453
- name: 'templateVariables',
454
- type: 'fixedCollection',
452
+ displayName: 'Variable 1',
453
+ name: 'templateVar1',
454
+ type: 'string',
455
455
  displayOptions: {
456
456
  show: {
457
457
  operation: ['sendMessage'],
458
458
  messageType: ['template'],
459
459
  },
460
460
  },
461
- default: {},
462
- placeholder: 'Add Variable',
463
- description: 'Variables to replace {{1}}, {{2}}, etc. in your template. Add them in order.',
464
- typeOptions: {
465
- multipleValues: true,
461
+ default: '',
462
+ description: 'Value for {{1}} in template. Leave empty if template has no variables.',
463
+ },
464
+ {
465
+ displayName: 'Variable 2',
466
+ name: 'templateVar2',
467
+ type: 'string',
468
+ displayOptions: {
469
+ show: {
470
+ operation: ['sendMessage'],
471
+ messageType: ['template'],
472
+ },
466
473
  },
467
- options: [
468
- {
469
- name: 'variables',
470
- displayName: 'Variables',
471
- values: [
472
- {
473
- displayName: 'Value',
474
- name: 'value',
475
- type: 'string',
476
- default: '',
477
- description: 'Value for this variable (replaces {{1}}, {{2}}, etc. in order)',
478
- },
479
- ],
474
+ default: '',
475
+ description: 'Value for {{2}} in template (optional)',
476
+ },
477
+ {
478
+ displayName: 'Variable 3',
479
+ name: 'templateVar3',
480
+ type: 'string',
481
+ displayOptions: {
482
+ show: {
483
+ operation: ['sendMessage'],
484
+ messageType: ['template'],
480
485
  },
481
- ],
486
+ },
487
+ default: '',
488
+ description: 'Value for {{3}} in template (optional)',
482
489
  },
483
490
  {
484
- displayName: 'Template Components (JSON)',
491
+ displayName: 'Variable 4',
492
+ name: 'templateVar4',
493
+ type: 'string',
494
+ displayOptions: {
495
+ show: {
496
+ operation: ['sendMessage'],
497
+ messageType: ['template'],
498
+ },
499
+ },
500
+ default: '',
501
+ description: 'Value for {{4}} in template (optional)',
502
+ },
503
+ {
504
+ displayName: 'Variable 5',
505
+ name: 'templateVar5',
506
+ type: 'string',
507
+ displayOptions: {
508
+ show: {
509
+ operation: ['sendMessage'],
510
+ messageType: ['template'],
511
+ },
512
+ },
513
+ default: '',
514
+ description: 'Value for {{5}} in template (optional)',
515
+ },
516
+ {
517
+ displayName: 'Advanced: Template Components (JSON)',
485
518
  name: 'templateComponents',
486
519
  type: 'json',
487
520
  displayOptions: {
@@ -491,8 +524,8 @@ class KirimChat {
491
524
  templateManualEntry: [true],
492
525
  },
493
526
  },
494
- default: '[]',
495
- description: 'Advanced: Full template components JSON (for header media, buttons, etc.). Leave empty to use simple variables above.',
527
+ default: '',
528
+ description: 'For advanced use: Full template components JSON (header media, buttons). Overrides variable fields above if provided.',
496
529
  },
497
530
  // ============================================
498
531
  // INTERACTIVE MESSAGE FIELDS (WhatsApp only)
@@ -854,33 +887,42 @@ class KirimChat {
854
887
  method: 'GET',
855
888
  url: `${baseUrl}/templates?status=APPROVED&limit=500`,
856
889
  headers: {
857
- 'X-API-Key': credentials.apiKey,
890
+ 'Authorization': `Bearer ${credentials.apiKey}`,
858
891
  'Content-Type': 'application/json',
859
892
  },
860
893
  });
861
894
  if (!response.success || !response.data) {
862
- return [{ name: 'No templates found', value: '' }];
895
+ return [{ name: '-- No templates found --', value: '' }];
863
896
  }
864
897
  const templates = response.data;
865
898
  if (templates.length === 0) {
866
- return [{ name: 'No approved templates', value: '' }];
899
+ return [{ name: '-- No approved templates --', value: '' }];
867
900
  }
901
+ // Count variables in content
902
+ const countVariables = (content) => {
903
+ const matches = content === null || content === void 0 ? void 0 : content.match(/\{\{\d+\}\}/g);
904
+ return matches ? matches.length : 0;
905
+ };
868
906
  return templates.map((t) => {
869
907
  var _a;
870
- return ({
871
- name: `${t.template_name} (${t.language}) - ${t.category}`,
908
+ const varCount = countVariables(t.content);
909
+ const varInfo = varCount > 0 ? ` [${varCount} var]` : '';
910
+ return {
911
+ name: `${t.template_name} (${t.language})${varInfo}`,
872
912
  value: JSON.stringify({
873
913
  name: t.template_name,
874
914
  language: t.language,
875
- has_variables: t.has_variables,
915
+ has_variables: varCount > 0,
916
+ variable_count: varCount,
876
917
  content: t.content,
877
918
  }),
878
- description: ((_a = t.content) === null || _a === void 0 ? void 0 : _a.substring(0, 100)) || '',
879
- });
919
+ description: ((_a = t.content) === null || _a === void 0 ? void 0 : _a.substring(0, 80)) || '',
920
+ };
880
921
  });
881
922
  }
882
923
  catch (error) {
883
- return [{ name: 'Error loading templates', value: '' }];
924
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
925
+ return [{ name: `-- Error: ${errorMessage.substring(0, 50)} --`, value: '' }];
884
926
  }
885
927
  },
886
928
  },
@@ -961,12 +1003,22 @@ class KirimChat {
961
1003
  }
962
1004
  }
963
1005
  // Handle simple variables (from fixedCollection)
964
- const templateVariablesData = this.getNodeParameter('templateVariables', i, {});
965
- if (templateVariablesData.variables && templateVariablesData.variables.length > 0) {
1006
+ const templateVariables = [];
1007
+ for (let varNum = 1; varNum <= 5; varNum++) {
1008
+ const varValue = this.getNodeParameter(`templateVar${varNum}`, i, '');
1009
+ if (varValue) {
1010
+ templateVariables.push(varValue);
1011
+ }
1012
+ else {
1013
+ // Stop at first empty variable
1014
+ break;
1015
+ }
1016
+ }
1017
+ if (templateVariables.length > 0) {
966
1018
  // Build body component with parameters
967
- const bodyParameters = templateVariablesData.variables.map((v) => ({
1019
+ const bodyParameters = templateVariables.map((v) => ({
968
1020
  type: 'text',
969
- text: v.value,
1021
+ text: v,
970
1022
  }));
971
1023
  // If no components provided, create body component with variables
972
1024
  if (!Array.isArray(templateComponents) || templateComponents.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kichat/n8n-nodes-kirimchat",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
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",