@kichat/n8n-nodes-kirimchat 1.3.5 → 1.3.6
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.
|
@@ -815,6 +815,92 @@ class KirimChat {
|
|
|
815
815
|
description: 'Match the variable count shown in template name (e.g., [12 var] = select 12)',
|
|
816
816
|
},
|
|
817
817
|
...templateVariableFields,
|
|
818
|
+
// ============================================
|
|
819
|
+
// HEADER MEDIA FIELDS (for templates with IMAGE/VIDEO/DOCUMENT headers)
|
|
820
|
+
// ============================================
|
|
821
|
+
{
|
|
822
|
+
displayName: 'Header Media',
|
|
823
|
+
name: 'templateHeaderMedia',
|
|
824
|
+
type: 'collection',
|
|
825
|
+
placeholder: 'Add Header Media',
|
|
826
|
+
displayOptions: {
|
|
827
|
+
show: {
|
|
828
|
+
operation: ['sendMessage'],
|
|
829
|
+
messageType: ['template'],
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
default: {},
|
|
833
|
+
description: 'If your template has an IMAGE, VIDEO, or DOCUMENT header, provide the media URL or ID here',
|
|
834
|
+
options: [
|
|
835
|
+
{
|
|
836
|
+
displayName: 'Header Image URL',
|
|
837
|
+
name: 'header_image',
|
|
838
|
+
type: 'string',
|
|
839
|
+
default: '',
|
|
840
|
+
description: 'Public URL (https://...) or WhatsApp Media ID for IMAGE header',
|
|
841
|
+
placeholder: 'https://example.com/image.jpg',
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
displayName: 'Header Video URL',
|
|
845
|
+
name: 'header_video',
|
|
846
|
+
type: 'string',
|
|
847
|
+
default: '',
|
|
848
|
+
description: 'Public URL (https://...) or WhatsApp Media ID for VIDEO header',
|
|
849
|
+
placeholder: 'https://example.com/video.mp4',
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
displayName: 'Header Document URL',
|
|
853
|
+
name: 'header_document',
|
|
854
|
+
type: 'string',
|
|
855
|
+
default: '',
|
|
856
|
+
description: 'Public URL (https://...) or WhatsApp Media ID for DOCUMENT header',
|
|
857
|
+
placeholder: 'https://example.com/document.pdf',
|
|
858
|
+
},
|
|
859
|
+
],
|
|
860
|
+
},
|
|
861
|
+
// ============================================
|
|
862
|
+
// DYNAMIC URL BUTTON FIELDS (for templates with URL buttons containing {{1}})
|
|
863
|
+
// ============================================
|
|
864
|
+
{
|
|
865
|
+
displayName: 'Button URL Variables',
|
|
866
|
+
name: 'templateButtonUrls',
|
|
867
|
+
type: 'collection',
|
|
868
|
+
placeholder: 'Add Button URL Suffix',
|
|
869
|
+
displayOptions: {
|
|
870
|
+
show: {
|
|
871
|
+
operation: ['sendMessage'],
|
|
872
|
+
messageType: ['template'],
|
|
873
|
+
},
|
|
874
|
+
},
|
|
875
|
+
default: {},
|
|
876
|
+
description: 'If your template has URL buttons with dynamic suffix ({{1}}), provide the values here. Button index is 0-based.',
|
|
877
|
+
options: [
|
|
878
|
+
{
|
|
879
|
+
displayName: 'Button 0 URL Suffix',
|
|
880
|
+
name: 'button_0',
|
|
881
|
+
type: 'string',
|
|
882
|
+
default: '',
|
|
883
|
+
description: 'URL suffix for the first URL button (index 0)',
|
|
884
|
+
placeholder: 'order123',
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
displayName: 'Button 1 URL Suffix',
|
|
888
|
+
name: 'button_1',
|
|
889
|
+
type: 'string',
|
|
890
|
+
default: '',
|
|
891
|
+
description: 'URL suffix for the second URL button (index 1)',
|
|
892
|
+
placeholder: 'tracking456',
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
displayName: 'Button 2 URL Suffix',
|
|
896
|
+
name: 'button_2',
|
|
897
|
+
type: 'string',
|
|
898
|
+
default: '',
|
|
899
|
+
description: 'URL suffix for the third URL button (index 2)',
|
|
900
|
+
placeholder: 'promo789',
|
|
901
|
+
},
|
|
902
|
+
],
|
|
903
|
+
},
|
|
818
904
|
{
|
|
819
905
|
displayName: 'Advanced: Template Components (JSON)',
|
|
820
906
|
name: 'templateComponents',
|
|
@@ -827,7 +913,7 @@ class KirimChat {
|
|
|
827
913
|
},
|
|
828
914
|
},
|
|
829
915
|
default: '',
|
|
830
|
-
description: 'For advanced use: Full template components JSON
|
|
916
|
+
description: 'For advanced use: Full template components JSON. Overrides all fields above if provided.',
|
|
831
917
|
},
|
|
832
918
|
// Auto-create customer options for template messages
|
|
833
919
|
{
|
|
@@ -1596,8 +1682,21 @@ class KirimChat {
|
|
|
1596
1682
|
var _a;
|
|
1597
1683
|
const varCount = countAllVariables(t);
|
|
1598
1684
|
const varInfo = varCount > 0 ? ` [${varCount} var]` : '';
|
|
1685
|
+
// Add header type indicator
|
|
1686
|
+
let headerInfo = '';
|
|
1687
|
+
if (t.header_type && ['IMAGE', 'VIDEO', 'DOCUMENT'].includes(t.header_type.toUpperCase())) {
|
|
1688
|
+
headerInfo = ` [${t.header_type.toUpperCase()}]`;
|
|
1689
|
+
}
|
|
1690
|
+
// Add button info
|
|
1691
|
+
let buttonInfo = '';
|
|
1692
|
+
if (t.buttons && Array.isArray(t.buttons)) {
|
|
1693
|
+
const dynamicUrlCount = t.buttons.filter((btn) => { var _a; return btn.type === 'URL' && ((_a = btn.url) === null || _a === void 0 ? void 0 : _a.includes('{{1}}')); }).length;
|
|
1694
|
+
if (dynamicUrlCount > 0) {
|
|
1695
|
+
buttonInfo = ` [${dynamicUrlCount} URL btn]`;
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1599
1698
|
return {
|
|
1600
|
-
name: `${t.template_name} (${t.language})${varInfo}`,
|
|
1699
|
+
name: `${t.template_name} (${t.language})${varInfo}${headerInfo}${buttonInfo}`,
|
|
1601
1700
|
value: JSON.stringify({
|
|
1602
1701
|
name: t.template_name,
|
|
1603
1702
|
language: t.language,
|
|
@@ -1840,21 +1939,81 @@ class KirimChat {
|
|
|
1840
1939
|
const val = this.getNodeParameter(`templateVar${v}`, i, '');
|
|
1841
1940
|
templateVariables.push(val);
|
|
1842
1941
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1942
|
+
// Get header media values
|
|
1943
|
+
const headerMedia = this.getNodeParameter('templateHeaderMedia', i, {});
|
|
1944
|
+
// Get button URL suffix values
|
|
1945
|
+
const buttonUrls = this.getNodeParameter('templateButtonUrls', i, {});
|
|
1946
|
+
// Build components array if not using advanced JSON mode
|
|
1947
|
+
if (!Array.isArray(templateComponents) || templateComponents.length === 0) {
|
|
1948
|
+
const builtComponents = [];
|
|
1949
|
+
// 1. Add header component if media is provided
|
|
1950
|
+
if (headerMedia.header_image) {
|
|
1951
|
+
const isMediaId = !headerMedia.header_image.startsWith('http://') && !headerMedia.header_image.startsWith('https://');
|
|
1952
|
+
builtComponents.push({
|
|
1953
|
+
type: 'header',
|
|
1954
|
+
parameters: [{
|
|
1955
|
+
type: 'image',
|
|
1956
|
+
image: isMediaId ? { id: headerMedia.header_image } : { link: headerMedia.header_image },
|
|
1957
|
+
}],
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
else if (headerMedia.header_video) {
|
|
1961
|
+
const isMediaId = !headerMedia.header_video.startsWith('http://') && !headerMedia.header_video.startsWith('https://');
|
|
1962
|
+
builtComponents.push({
|
|
1963
|
+
type: 'header',
|
|
1964
|
+
parameters: [{
|
|
1965
|
+
type: 'video',
|
|
1966
|
+
video: isMediaId ? { id: headerMedia.header_video } : { link: headerMedia.header_video },
|
|
1967
|
+
}],
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
else if (headerMedia.header_document) {
|
|
1971
|
+
const isMediaId = !headerMedia.header_document.startsWith('http://') && !headerMedia.header_document.startsWith('https://');
|
|
1972
|
+
builtComponents.push({
|
|
1973
|
+
type: 'header',
|
|
1974
|
+
parameters: [{
|
|
1975
|
+
type: 'document',
|
|
1976
|
+
document: isMediaId ? { id: headerMedia.header_document } : { link: headerMedia.header_document },
|
|
1977
|
+
}],
|
|
1978
|
+
});
|
|
1979
|
+
}
|
|
1980
|
+
// 2. Add body component if variables are provided
|
|
1981
|
+
if (templateVariables.length > 0) {
|
|
1982
|
+
const bodyParameters = templateVariables.map((v) => ({
|
|
1983
|
+
type: 'text',
|
|
1984
|
+
text: v,
|
|
1985
|
+
}));
|
|
1986
|
+
builtComponents.push({
|
|
1987
|
+
type: 'body',
|
|
1988
|
+
parameters: bodyParameters,
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
// 3. Add button components if URL suffixes are provided
|
|
1992
|
+
if (buttonUrls.button_0) {
|
|
1993
|
+
builtComponents.push({
|
|
1994
|
+
type: 'button',
|
|
1995
|
+
sub_type: 'url',
|
|
1996
|
+
index: 0,
|
|
1997
|
+
parameters: [{ type: 'text', text: buttonUrls.button_0 }],
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
if (buttonUrls.button_1) {
|
|
2001
|
+
builtComponents.push({
|
|
2002
|
+
type: 'button',
|
|
2003
|
+
sub_type: 'url',
|
|
2004
|
+
index: 1,
|
|
2005
|
+
parameters: [{ type: 'text', text: buttonUrls.button_1 }],
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
if (buttonUrls.button_2) {
|
|
2009
|
+
builtComponents.push({
|
|
2010
|
+
type: 'button',
|
|
2011
|
+
sub_type: 'url',
|
|
2012
|
+
index: 2,
|
|
2013
|
+
parameters: [{ type: 'text', text: buttonUrls.button_2 }],
|
|
2014
|
+
});
|
|
1857
2015
|
}
|
|
2016
|
+
templateComponents = builtComponents;
|
|
1858
2017
|
}
|
|
1859
2018
|
body.template = {
|
|
1860
2019
|
name: templateName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kichat/n8n-nodes-kirimchat",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
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",
|