@renatoascencio/n8n-nodes-chatwoot 0.5.0 → 0.6.0

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.
Files changed (96) hide show
  1. package/dist/nodes/Chatwoot/Chatwoot.node.js +271 -0
  2. package/dist/nodes/Chatwoot/Chatwoot.node.js.map +1 -1
  3. package/dist/nodes/Chatwoot/resources/company/create.operation.d.ts +2 -0
  4. package/dist/nodes/Chatwoot/resources/company/create.operation.js +40 -0
  5. package/dist/nodes/Chatwoot/resources/company/create.operation.js.map +1 -0
  6. package/dist/nodes/Chatwoot/resources/company/delete.operation.d.ts +2 -0
  7. package/dist/nodes/Chatwoot/resources/company/delete.operation.js +15 -0
  8. package/dist/nodes/Chatwoot/resources/company/delete.operation.js.map +1 -0
  9. package/dist/nodes/Chatwoot/resources/company/get.operation.d.ts +2 -0
  10. package/dist/nodes/Chatwoot/resources/company/get.operation.js +15 -0
  11. package/dist/nodes/Chatwoot/resources/company/get.operation.js.map +1 -0
  12. package/dist/nodes/Chatwoot/resources/company/getAll.operation.d.ts +2 -0
  13. package/dist/nodes/Chatwoot/resources/company/getAll.operation.js +46 -0
  14. package/dist/nodes/Chatwoot/resources/company/getAll.operation.js.map +1 -0
  15. package/dist/nodes/Chatwoot/resources/company/index.d.ts +3 -0
  16. package/dist/nodes/Chatwoot/resources/company/index.js +34 -0
  17. package/dist/nodes/Chatwoot/resources/company/index.js.map +1 -0
  18. package/dist/nodes/Chatwoot/resources/company/search.operation.d.ts +2 -0
  19. package/dist/nodes/Chatwoot/resources/company/search.operation.js +32 -0
  20. package/dist/nodes/Chatwoot/resources/company/search.operation.js.map +1 -0
  21. package/dist/nodes/Chatwoot/resources/company/update.operation.d.ts +2 -0
  22. package/dist/nodes/Chatwoot/resources/company/update.operation.js +47 -0
  23. package/dist/nodes/Chatwoot/resources/company/update.operation.js.map +1 -0
  24. package/dist/nodes/Chatwoot/resources/contact/contactableInboxes.operation.d.ts +2 -0
  25. package/dist/nodes/Chatwoot/resources/contact/contactableInboxes.operation.js +20 -0
  26. package/dist/nodes/Chatwoot/resources/contact/contactableInboxes.operation.js.map +1 -0
  27. package/dist/nodes/Chatwoot/resources/contact/exportContacts.operation.d.ts +2 -0
  28. package/dist/nodes/Chatwoot/resources/contact/exportContacts.operation.js +35 -0
  29. package/dist/nodes/Chatwoot/resources/contact/exportContacts.operation.js.map +1 -0
  30. package/dist/nodes/Chatwoot/resources/contact/importContacts.operation.d.ts +2 -0
  31. package/dist/nodes/Chatwoot/resources/contact/importContacts.operation.js +23 -0
  32. package/dist/nodes/Chatwoot/resources/contact/importContacts.operation.js.map +1 -0
  33. package/dist/nodes/Chatwoot/resources/contact/index.js +24 -0
  34. package/dist/nodes/Chatwoot/resources/contact/index.js.map +1 -1
  35. package/dist/nodes/Chatwoot/resources/conversation/index.js +16 -0
  36. package/dist/nodes/Chatwoot/resources/conversation/index.js.map +1 -1
  37. package/dist/nodes/Chatwoot/resources/conversation/toggleTyping.operation.d.ts +2 -0
  38. package/dist/nodes/Chatwoot/resources/conversation/toggleTyping.operation.js +51 -0
  39. package/dist/nodes/Chatwoot/resources/conversation/toggleTyping.operation.js.map +1 -0
  40. package/dist/nodes/Chatwoot/resources/conversation/transcript.operation.d.ts +2 -0
  41. package/dist/nodes/Chatwoot/resources/conversation/transcript.operation.js +34 -0
  42. package/dist/nodes/Chatwoot/resources/conversation/transcript.operation.js.map +1 -0
  43. package/dist/nodes/Chatwoot/resources/csatSurvey/download.operation.d.ts +2 -0
  44. package/dist/nodes/Chatwoot/resources/csatSurvey/download.operation.js +35 -0
  45. package/dist/nodes/Chatwoot/resources/csatSurvey/download.operation.js.map +1 -0
  46. package/dist/nodes/Chatwoot/resources/csatSurvey/index.js +19 -1
  47. package/dist/nodes/Chatwoot/resources/csatSurvey/index.js.map +1 -1
  48. package/dist/nodes/Chatwoot/resources/csatSurvey/metrics.operation.d.ts +2 -0
  49. package/dist/nodes/Chatwoot/resources/csatSurvey/metrics.operation.js +35 -0
  50. package/dist/nodes/Chatwoot/resources/csatSurvey/metrics.operation.js.map +1 -0
  51. package/dist/nodes/Chatwoot/resources/helpCenter/index.js +24 -0
  52. package/dist/nodes/Chatwoot/resources/helpCenter/index.js.map +1 -1
  53. package/dist/nodes/Chatwoot/resources/helpCenter/listArticles.operation.d.ts +2 -0
  54. package/dist/nodes/Chatwoot/resources/helpCenter/listArticles.operation.js +90 -0
  55. package/dist/nodes/Chatwoot/resources/helpCenter/listArticles.operation.js.map +1 -0
  56. package/dist/nodes/Chatwoot/resources/helpCenter/listCategories.operation.d.ts +2 -0
  57. package/dist/nodes/Chatwoot/resources/helpCenter/listCategories.operation.js +33 -0
  58. package/dist/nodes/Chatwoot/resources/helpCenter/listCategories.operation.js.map +1 -0
  59. package/dist/nodes/Chatwoot/resources/helpCenter/listPortals.operation.d.ts +2 -0
  60. package/dist/nodes/Chatwoot/resources/helpCenter/listPortals.operation.js +5 -0
  61. package/dist/nodes/Chatwoot/resources/helpCenter/listPortals.operation.js.map +1 -0
  62. package/dist/nodes/Chatwoot/resources/search/index.d.ts +3 -0
  63. package/dist/nodes/Chatwoot/resources/search/index.js +28 -0
  64. package/dist/nodes/Chatwoot/resources/search/index.js.map +1 -0
  65. package/dist/nodes/Chatwoot/resources/search/searchAll.operation.d.ts +2 -0
  66. package/dist/nodes/Chatwoot/resources/search/searchAll.operation.js +15 -0
  67. package/dist/nodes/Chatwoot/resources/search/searchAll.operation.js.map +1 -0
  68. package/dist/nodes/Chatwoot/resources/search/searchContacts.operation.d.ts +2 -0
  69. package/dist/nodes/Chatwoot/resources/search/searchContacts.operation.js +32 -0
  70. package/dist/nodes/Chatwoot/resources/search/searchContacts.operation.js.map +1 -0
  71. package/dist/nodes/Chatwoot/resources/search/searchConversations.operation.d.ts +2 -0
  72. package/dist/nodes/Chatwoot/resources/search/searchConversations.operation.js +32 -0
  73. package/dist/nodes/Chatwoot/resources/search/searchConversations.operation.js.map +1 -0
  74. package/dist/nodes/Chatwoot/resources/search/searchMessages.operation.d.ts +2 -0
  75. package/dist/nodes/Chatwoot/resources/search/searchMessages.operation.js +32 -0
  76. package/dist/nodes/Chatwoot/resources/search/searchMessages.operation.js.map +1 -0
  77. package/dist/nodes/Chatwoot/resources/slaPolicy/create.operation.d.ts +2 -0
  78. package/dist/nodes/Chatwoot/resources/slaPolicy/create.operation.js +60 -0
  79. package/dist/nodes/Chatwoot/resources/slaPolicy/create.operation.js.map +1 -0
  80. package/dist/nodes/Chatwoot/resources/slaPolicy/delete.operation.d.ts +2 -0
  81. package/dist/nodes/Chatwoot/resources/slaPolicy/delete.operation.js +15 -0
  82. package/dist/nodes/Chatwoot/resources/slaPolicy/delete.operation.js.map +1 -0
  83. package/dist/nodes/Chatwoot/resources/slaPolicy/get.operation.d.ts +2 -0
  84. package/dist/nodes/Chatwoot/resources/slaPolicy/get.operation.js +15 -0
  85. package/dist/nodes/Chatwoot/resources/slaPolicy/get.operation.js.map +1 -0
  86. package/dist/nodes/Chatwoot/resources/slaPolicy/getAll.operation.d.ts +2 -0
  87. package/dist/nodes/Chatwoot/resources/slaPolicy/getAll.operation.js +5 -0
  88. package/dist/nodes/Chatwoot/resources/slaPolicy/getAll.operation.js.map +1 -0
  89. package/dist/nodes/Chatwoot/resources/slaPolicy/index.d.ts +3 -0
  90. package/dist/nodes/Chatwoot/resources/slaPolicy/index.js +31 -0
  91. package/dist/nodes/Chatwoot/resources/slaPolicy/index.js.map +1 -0
  92. package/dist/nodes/Chatwoot/resources/slaPolicy/update.operation.d.ts +2 -0
  93. package/dist/nodes/Chatwoot/resources/slaPolicy/update.operation.js +67 -0
  94. package/dist/nodes/Chatwoot/resources/slaPolicy/update.operation.js.map +1 -0
  95. package/dist/tsconfig.tsbuildinfo +1 -1
  96. package/package.json +1 -1
@@ -28,6 +28,9 @@ const notification_1 = require("./resources/notification");
28
28
  const campaign_1 = require("./resources/campaign");
29
29
  const contactNote_1 = require("./resources/contactNote");
30
30
  const conversationParticipant_1 = require("./resources/conversationParticipant");
31
+ const company_1 = require("./resources/company");
32
+ const search_1 = require("./resources/search");
33
+ const slaPolicy_1 = require("./resources/slaPolicy");
31
34
  const platformAccount_1 = require("./resources/platformAccount");
32
35
  const platformUser_1 = require("./resources/platformUser");
33
36
  const accountUser_1 = require("./resources/accountUser");
@@ -82,6 +85,9 @@ class Chatwoot {
82
85
  'campaign',
83
86
  'contactNote',
84
87
  'conversationParticipant',
88
+ 'company',
89
+ 'search',
90
+ 'slaPolicy',
85
91
  ],
86
92
  },
87
93
  },
@@ -119,6 +125,7 @@ class Chatwoot {
119
125
  { name: 'Automation Rule', value: 'automationRule' },
120
126
  { name: 'Campaign', value: 'campaign' },
121
127
  { name: 'Canned Response', value: 'cannedResponse' },
128
+ { name: 'Company (Enterprise)', value: 'company' },
122
129
  { name: 'Contact', value: 'contact' },
123
130
  { name: 'Contact Note', value: 'contactNote' },
124
131
  { name: 'Conversation', value: 'conversation' },
@@ -135,6 +142,8 @@ class Chatwoot {
135
142
  { name: 'Notification', value: 'notification' },
136
143
  { name: 'Profile', value: 'profile' },
137
144
  { name: 'Report', value: 'report' },
145
+ { name: 'Search', value: 'search' },
146
+ { name: 'SLA Policy (Enterprise)', value: 'slaPolicy' },
138
147
  { name: 'Team', value: 'team' },
139
148
  { name: 'Webhook', value: 'webhook' },
140
149
  { name: '[Platform] Account', value: 'platformAccount' },
@@ -172,6 +181,9 @@ class Chatwoot {
172
181
  campaign_1.campaignOperations,
173
182
  contactNote_1.contactNoteOperations,
174
183
  conversationParticipant_1.conversationParticipantOperations,
184
+ company_1.companyOperations,
185
+ search_1.searchOperations,
186
+ slaPolicy_1.slaPolicyOperations,
175
187
  platformAccount_1.platformAccountOperations,
176
188
  platformUser_1.platformUserOperations,
177
189
  accountUser_1.accountUserOperations,
@@ -204,6 +216,9 @@ class Chatwoot {
204
216
  ...campaign_1.campaignFields,
205
217
  ...contactNote_1.contactNoteFields,
206
218
  ...conversationParticipant_1.conversationParticipantFields,
219
+ ...company_1.companyFields,
220
+ ...search_1.searchFields,
221
+ ...slaPolicy_1.slaPolicyFields,
207
222
  ...platformAccount_1.platformAccountFields,
208
223
  ...platformUser_1.platformUserFields,
209
224
  ...accountUser_1.accountUserFields,
@@ -744,6 +759,20 @@ class Chatwoot {
744
759
  responseData = payload.slice(0, limit);
745
760
  }
746
761
  }
762
+ else if (operation === 'transcript') {
763
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
764
+ const email = this.getNodeParameter('email', i);
765
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/transcript`, { email });
766
+ }
767
+ else if (operation === 'toggleTyping') {
768
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
769
+ const typingStatus = this.getNodeParameter('typingStatus', i);
770
+ const isPrivate = this.getNodeParameter('isPrivate', i);
771
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/toggle_typing_status`, {
772
+ typing_status: typingStatus,
773
+ is_private: isPrivate,
774
+ });
775
+ }
747
776
  else {
748
777
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
749
778
  }
@@ -928,6 +957,24 @@ class Chatwoot {
928
957
  const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
929
958
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/contacts/${contactId}/labels`);
930
959
  }
960
+ else if (operation === 'import') {
961
+ const fileContent = this.getNodeParameter('fileContent', i);
962
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/contacts/import', { import_file: fileContent });
963
+ }
964
+ else if (operation === 'export') {
965
+ const options = this.getNodeParameter('options', i);
966
+ const body = {};
967
+ if (options.tag)
968
+ body.tag = options.tag;
969
+ if (options.column_names) {
970
+ body.column_names = options.column_names.split(',').map((c) => c.trim());
971
+ }
972
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/contacts/export', body);
973
+ }
974
+ else if (operation === 'contactableInboxes') {
975
+ const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
976
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/contacts/${contactId}/contactable_inboxes`);
977
+ }
931
978
  else {
932
979
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
933
980
  }
@@ -1166,6 +1213,39 @@ class Chatwoot {
1166
1213
  const body = { title, content, ...additionalFields };
1167
1214
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/portals/${portalSlug}/articles`, body);
1168
1215
  }
1216
+ else if (operation === 'listPortals') {
1217
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/portals');
1218
+ }
1219
+ else if (operation === 'listCategories') {
1220
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1221
+ const locale = this.getNodeParameter('locale', i, 'en');
1222
+ const qs = {};
1223
+ if (locale)
1224
+ qs.locale = locale;
1225
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/portals/${portalSlug}/categories`, {}, qs);
1226
+ }
1227
+ else if (operation === 'listArticles') {
1228
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1229
+ const returnAll = this.getNodeParameter('returnAll', i);
1230
+ const options = this.getNodeParameter('options', i);
1231
+ const qs = {};
1232
+ if (options.locale)
1233
+ qs.locale = options.locale;
1234
+ if (options.category_slug)
1235
+ qs.category_slug = options.category_slug;
1236
+ if (options.status)
1237
+ qs.status = options.status;
1238
+ if (returnAll) {
1239
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', `/portals/${portalSlug}/articles`, {}, qs, 'payload');
1240
+ }
1241
+ else {
1242
+ const limit = this.getNodeParameter('limit', i);
1243
+ qs.page = 1;
1244
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/portals/${portalSlug}/articles`, {}, qs));
1245
+ const payload = (result.payload || []);
1246
+ responseData = payload.slice(0, limit);
1247
+ }
1248
+ }
1169
1249
  else {
1170
1250
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1171
1251
  }
@@ -1225,6 +1305,24 @@ class Chatwoot {
1225
1305
  const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1226
1306
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/csat_survey/${conversationId}`);
1227
1307
  }
1308
+ else if (operation === 'metrics') {
1309
+ const options = this.getNodeParameter('options', i);
1310
+ const qs = {};
1311
+ if (options.since)
1312
+ qs.since = new Date(options.since).getTime() / 1000;
1313
+ if (options.until)
1314
+ qs.until = new Date(options.until).getTime() / 1000;
1315
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/csat_survey_responses/metrics', {}, qs);
1316
+ }
1317
+ else if (operation === 'download') {
1318
+ const options = this.getNodeParameter('options', i);
1319
+ const qs = {};
1320
+ if (options.since)
1321
+ qs.since = new Date(options.since).getTime() / 1000;
1322
+ if (options.until)
1323
+ qs.until = new Date(options.until).getTime() / 1000;
1324
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/csat_survey_responses/download', {}, qs);
1325
+ }
1228
1326
  else {
1229
1327
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1230
1328
  }
@@ -1436,6 +1534,179 @@ class Chatwoot {
1436
1534
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1437
1535
  }
1438
1536
  }
1537
+ else if (resource === 'company') {
1538
+ if (operation === 'getAll') {
1539
+ const returnAll = this.getNodeParameter('returnAll', i);
1540
+ const options = this.getNodeParameter('options', i);
1541
+ const qs = {};
1542
+ if (options.sort)
1543
+ qs.sort = options.sort;
1544
+ if (returnAll) {
1545
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/companies', {}, qs, 'payload');
1546
+ }
1547
+ else {
1548
+ const limit = this.getNodeParameter('limit', i);
1549
+ qs.page = 1;
1550
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/companies', {}, qs));
1551
+ const payload = (result.payload || []);
1552
+ responseData = payload.slice(0, limit);
1553
+ }
1554
+ }
1555
+ else if (operation === 'get') {
1556
+ const companyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('companyId', i), 'Company ID');
1557
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/companies/${companyId}`);
1558
+ }
1559
+ else if (operation === 'create') {
1560
+ const name = this.getNodeParameter('name', i);
1561
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1562
+ const body = { name };
1563
+ if (additionalFields.domain)
1564
+ body.domain = additionalFields.domain;
1565
+ if (additionalFields.description)
1566
+ body.description = additionalFields.description;
1567
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/companies', body);
1568
+ }
1569
+ else if (operation === 'update') {
1570
+ const companyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('companyId', i), 'Company ID');
1571
+ const updateFields = this.getNodeParameter('updateFields', i);
1572
+ const body = {};
1573
+ if (updateFields.name)
1574
+ body.name = updateFields.name;
1575
+ if (updateFields.domain)
1576
+ body.domain = updateFields.domain;
1577
+ if (updateFields.description)
1578
+ body.description = updateFields.description;
1579
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/companies/${companyId}`, body);
1580
+ }
1581
+ else if (operation === 'delete') {
1582
+ const companyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('companyId', i), 'Company ID');
1583
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/companies/${companyId}`);
1584
+ responseData = { success: true, id: companyId };
1585
+ }
1586
+ else if (operation === 'search') {
1587
+ const query = this.getNodeParameter('query', i);
1588
+ const returnAll = this.getNodeParameter('returnAll', i);
1589
+ const qs = { q: query };
1590
+ if (returnAll) {
1591
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/companies/search', {}, qs, 'payload');
1592
+ }
1593
+ else {
1594
+ const limit = this.getNodeParameter('limit', i);
1595
+ qs.page = 1;
1596
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/companies/search', {}, qs));
1597
+ const payload = (result.payload || []);
1598
+ responseData = payload.slice(0, limit);
1599
+ }
1600
+ }
1601
+ else {
1602
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1603
+ }
1604
+ }
1605
+ else if (resource === 'search') {
1606
+ if (operation === 'searchAll') {
1607
+ const query = this.getNodeParameter('query', i);
1608
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/search', {}, { q: query });
1609
+ }
1610
+ else if (operation === 'searchConversations') {
1611
+ const query = this.getNodeParameter('query', i);
1612
+ const returnAll = this.getNodeParameter('returnAll', i);
1613
+ const qs = { q: query };
1614
+ if (returnAll) {
1615
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/search/conversations', {}, qs, 'payload');
1616
+ }
1617
+ else {
1618
+ const limit = this.getNodeParameter('limit', i);
1619
+ qs.page = 1;
1620
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/search/conversations', {}, qs));
1621
+ const payload = (result.payload || []);
1622
+ responseData = payload.slice(0, limit);
1623
+ }
1624
+ }
1625
+ else if (operation === 'searchContacts') {
1626
+ const query = this.getNodeParameter('query', i);
1627
+ const returnAll = this.getNodeParameter('returnAll', i);
1628
+ const qs = { q: query };
1629
+ if (returnAll) {
1630
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/search/contacts', {}, qs, 'payload');
1631
+ }
1632
+ else {
1633
+ const limit = this.getNodeParameter('limit', i);
1634
+ qs.page = 1;
1635
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/search/contacts', {}, qs));
1636
+ const payload = (result.payload || []);
1637
+ responseData = payload.slice(0, limit);
1638
+ }
1639
+ }
1640
+ else if (operation === 'searchMessages') {
1641
+ const query = this.getNodeParameter('query', i);
1642
+ const returnAll = this.getNodeParameter('returnAll', i);
1643
+ const qs = { q: query };
1644
+ if (returnAll) {
1645
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/search/messages', {}, qs, 'payload');
1646
+ }
1647
+ else {
1648
+ const limit = this.getNodeParameter('limit', i);
1649
+ qs.page = 1;
1650
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/search/messages', {}, qs));
1651
+ const payload = (result.payload || []);
1652
+ responseData = payload.slice(0, limit);
1653
+ }
1654
+ }
1655
+ else {
1656
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1657
+ }
1658
+ }
1659
+ else if (resource === 'slaPolicy') {
1660
+ if (operation === 'getAll') {
1661
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/sla_policies');
1662
+ }
1663
+ else if (operation === 'get') {
1664
+ const slaPolicyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('slaPolicyId', i), 'SLA Policy ID');
1665
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/sla_policies/${slaPolicyId}`);
1666
+ }
1667
+ else if (operation === 'create') {
1668
+ const name = this.getNodeParameter('name', i);
1669
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1670
+ const body = { name };
1671
+ if (additionalFields.description)
1672
+ body.description = additionalFields.description;
1673
+ if (additionalFields.first_response_time_threshold)
1674
+ body.first_response_time_threshold = additionalFields.first_response_time_threshold;
1675
+ if (additionalFields.next_response_time_threshold)
1676
+ body.next_response_time_threshold = additionalFields.next_response_time_threshold;
1677
+ if (additionalFields.resolution_time_threshold)
1678
+ body.resolution_time_threshold = additionalFields.resolution_time_threshold;
1679
+ if (additionalFields.only_during_business_hours !== undefined)
1680
+ body.only_during_business_hours = additionalFields.only_during_business_hours;
1681
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/sla_policies', body);
1682
+ }
1683
+ else if (operation === 'update') {
1684
+ const slaPolicyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('slaPolicyId', i), 'SLA Policy ID');
1685
+ const updateFields = this.getNodeParameter('updateFields', i);
1686
+ const body = {};
1687
+ if (updateFields.name)
1688
+ body.name = updateFields.name;
1689
+ if (updateFields.description)
1690
+ body.description = updateFields.description;
1691
+ if (updateFields.first_response_time_threshold)
1692
+ body.first_response_time_threshold = updateFields.first_response_time_threshold;
1693
+ if (updateFields.next_response_time_threshold)
1694
+ body.next_response_time_threshold = updateFields.next_response_time_threshold;
1695
+ if (updateFields.resolution_time_threshold)
1696
+ body.resolution_time_threshold = updateFields.resolution_time_threshold;
1697
+ if (updateFields.only_during_business_hours !== undefined)
1698
+ body.only_during_business_hours = updateFields.only_during_business_hours;
1699
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/sla_policies/${slaPolicyId}`, body);
1700
+ }
1701
+ else if (operation === 'delete') {
1702
+ const slaPolicyId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('slaPolicyId', i), 'SLA Policy ID');
1703
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/sla_policies/${slaPolicyId}`);
1704
+ responseData = { success: true, id: slaPolicyId };
1705
+ }
1706
+ else {
1707
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1708
+ }
1709
+ }
1439
1710
  else if (resource === 'platformAccount') {
1440
1711
  if (operation === 'create') {
1441
1712
  const name = this.getNodeParameter('name', i);