@renatoascencio/n8n-nodes-chatwoot 0.4.3 → 0.5.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.
- package/dist/nodes/Chatwoot/Chatwoot.node.js +273 -0
- package/dist/nodes/Chatwoot/Chatwoot.node.js.map +1 -1
- package/dist/nodes/Chatwoot/ChatwootTrigger.node.js +10 -0
- package/dist/nodes/Chatwoot/ChatwootTrigger.node.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/campaign/create.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/campaign/create.operation.js +56 -0
- package/dist/nodes/Chatwoot/resources/campaign/create.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/campaign/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/campaign/delete.operation.js +15 -0
- package/dist/nodes/Chatwoot/resources/campaign/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/campaign/get.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/campaign/get.operation.js +15 -0
- package/dist/nodes/Chatwoot/resources/campaign/get.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/campaign/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/campaign/getAll.operation.js +5 -0
- package/dist/nodes/Chatwoot/resources/campaign/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/campaign/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/campaign/index.js +31 -0
- package/dist/nodes/Chatwoot/resources/campaign/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/campaign/update.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/campaign/update.operation.js +46 -0
- package/dist/nodes/Chatwoot/resources/campaign/update.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contactNote/create.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contactNote/create.operation.js +25 -0
- package/dist/nodes/Chatwoot/resources/contactNote/create.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contactNote/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contactNote/delete.operation.js +24 -0
- package/dist/nodes/Chatwoot/resources/contactNote/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contactNote/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contactNote/getAll.operation.js +15 -0
- package/dist/nodes/Chatwoot/resources/contactNote/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contactNote/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/contactNote/index.js +28 -0
- package/dist/nodes/Chatwoot/resources/contactNote/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/contactNote/update.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/contactNote/update.operation.js +34 -0
- package/dist/nodes/Chatwoot/resources/contactNote/update.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/delete.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/conversation/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/index.js +32 -0
- package/dist/nodes/Chatwoot/resources/conversation/index.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/conversation/mute.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/mute.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/conversation/mute.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/search.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/search.operation.js +48 -0
- package/dist/nodes/Chatwoot/resources/conversation/search.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversation/unmute.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversation/unmute.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/conversation/unmute.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/add.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/add.operation.js +24 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/add.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/getAll.operation.js +15 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/index.js +25 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/remove.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/remove.operation.js +24 -0
- package/dist/nodes/Chatwoot/resources/conversationParticipant/remove.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/create.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/create.operation.js +60 -0
- package/dist/nodes/Chatwoot/resources/macro/create.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/delete.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/macro/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/execute.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/execute.operation.js +34 -0
- package/dist/nodes/Chatwoot/resources/macro/execute.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/get.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/get.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/macro/get.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/getAll.operation.js +5 -0
- package/dist/nodes/Chatwoot/resources/macro/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/macro/index.js +68 -0
- package/dist/nodes/Chatwoot/resources/macro/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/macro/update.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/macro/update.operation.js +60 -0
- package/dist/nodes/Chatwoot/resources/macro/update.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/delete.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/delete.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/notification/delete.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/getAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/getAll.operation.js +74 -0
- package/dist/nodes/Chatwoot/resources/notification/getAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/notification/index.js +68 -0
- package/dist/nodes/Chatwoot/resources/notification/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/markRead.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/markRead.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/notification/markRead.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/markUnread.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/markUnread.operation.js +20 -0
- package/dist/nodes/Chatwoot/resources/notification/markUnread.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/readAll.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/readAll.operation.js +5 -0
- package/dist/nodes/Chatwoot/resources/notification/readAll.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/notification/unreadCount.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/notification/unreadCount.operation.js +5 -0
- package/dist/nodes/Chatwoot/resources/notification/unreadCount.operation.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/profile/index.js +8 -1
- package/dist/nodes/Chatwoot/resources/profile/index.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/profile/update.operation.d.ts +2 -0
- package/dist/nodes/Chatwoot/resources/profile/update.operation.js +54 -0
- package/dist/nodes/Chatwoot/resources/profile/update.operation.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -23,6 +23,11 @@ const helpCenter_1 = require("./resources/helpCenter");
|
|
|
23
23
|
const integration_1 = require("./resources/integration");
|
|
24
24
|
const auditLog_1 = require("./resources/auditLog");
|
|
25
25
|
const csatSurvey_1 = require("./resources/csatSurvey");
|
|
26
|
+
const macro_1 = require("./resources/macro");
|
|
27
|
+
const notification_1 = require("./resources/notification");
|
|
28
|
+
const campaign_1 = require("./resources/campaign");
|
|
29
|
+
const contactNote_1 = require("./resources/contactNote");
|
|
30
|
+
const conversationParticipant_1 = require("./resources/conversationParticipant");
|
|
26
31
|
const platformAccount_1 = require("./resources/platformAccount");
|
|
27
32
|
const platformUser_1 = require("./resources/platformUser");
|
|
28
33
|
const accountUser_1 = require("./resources/accountUser");
|
|
@@ -72,6 +77,11 @@ class Chatwoot {
|
|
|
72
77
|
'integration',
|
|
73
78
|
'auditLog',
|
|
74
79
|
'csatSurvey',
|
|
80
|
+
'macro',
|
|
81
|
+
'notification',
|
|
82
|
+
'campaign',
|
|
83
|
+
'contactNote',
|
|
84
|
+
'conversationParticipant',
|
|
75
85
|
],
|
|
76
86
|
},
|
|
77
87
|
},
|
|
@@ -107,9 +117,12 @@ class Chatwoot {
|
|
|
107
117
|
{ name: 'Agent Bot', value: 'agentBot' },
|
|
108
118
|
{ name: 'Audit Log', value: 'auditLog' },
|
|
109
119
|
{ name: 'Automation Rule', value: 'automationRule' },
|
|
120
|
+
{ name: 'Campaign', value: 'campaign' },
|
|
110
121
|
{ name: 'Canned Response', value: 'cannedResponse' },
|
|
111
122
|
{ name: 'Contact', value: 'contact' },
|
|
123
|
+
{ name: 'Contact Note', value: 'contactNote' },
|
|
112
124
|
{ name: 'Conversation', value: 'conversation' },
|
|
125
|
+
{ name: 'Conversation Participant', value: 'conversationParticipant' },
|
|
113
126
|
{ name: 'CSAT Survey', value: 'csatSurvey' },
|
|
114
127
|
{ name: 'Custom Attribute', value: 'customAttribute' },
|
|
115
128
|
{ name: 'Custom Filter', value: 'customFilter' },
|
|
@@ -117,7 +130,9 @@ class Chatwoot {
|
|
|
117
130
|
{ name: 'Inbox', value: 'inbox' },
|
|
118
131
|
{ name: 'Integration', value: 'integration' },
|
|
119
132
|
{ name: 'Label', value: 'label' },
|
|
133
|
+
{ name: 'Macro', value: 'macro' },
|
|
120
134
|
{ name: 'Message', value: 'message' },
|
|
135
|
+
{ name: 'Notification', value: 'notification' },
|
|
121
136
|
{ name: 'Profile', value: 'profile' },
|
|
122
137
|
{ name: 'Report', value: 'report' },
|
|
123
138
|
{ name: 'Team', value: 'team' },
|
|
@@ -152,6 +167,11 @@ class Chatwoot {
|
|
|
152
167
|
integration_1.integrationOperations,
|
|
153
168
|
auditLog_1.auditLogOperations,
|
|
154
169
|
csatSurvey_1.csatSurveyOperations,
|
|
170
|
+
macro_1.macroOperations,
|
|
171
|
+
notification_1.notificationOperations,
|
|
172
|
+
campaign_1.campaignOperations,
|
|
173
|
+
contactNote_1.contactNoteOperations,
|
|
174
|
+
conversationParticipant_1.conversationParticipantOperations,
|
|
155
175
|
platformAccount_1.platformAccountOperations,
|
|
156
176
|
platformUser_1.platformUserOperations,
|
|
157
177
|
accountUser_1.accountUserOperations,
|
|
@@ -179,6 +199,11 @@ class Chatwoot {
|
|
|
179
199
|
...integration_1.integrationFields,
|
|
180
200
|
...auditLog_1.auditLogFields,
|
|
181
201
|
...csatSurvey_1.csatSurveyFields,
|
|
202
|
+
...macro_1.macroFields,
|
|
203
|
+
...notification_1.notificationFields,
|
|
204
|
+
...campaign_1.campaignFields,
|
|
205
|
+
...contactNote_1.contactNoteFields,
|
|
206
|
+
...conversationParticipant_1.conversationParticipantFields,
|
|
182
207
|
...platformAccount_1.platformAccountFields,
|
|
183
208
|
...platformUser_1.platformUserFields,
|
|
184
209
|
...accountUser_1.accountUserFields,
|
|
@@ -691,6 +716,34 @@ class Chatwoot {
|
|
|
691
716
|
qs.assignee_type = filters.assignee_type;
|
|
692
717
|
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/meta', {}, qs);
|
|
693
718
|
}
|
|
719
|
+
else if (operation === 'mute') {
|
|
720
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
721
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/mute`);
|
|
722
|
+
}
|
|
723
|
+
else if (operation === 'unmute') {
|
|
724
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
725
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/unmute`);
|
|
726
|
+
}
|
|
727
|
+
else if (operation === 'delete') {
|
|
728
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
729
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/conversations/${conversationId}`);
|
|
730
|
+
responseData = { success: true, id: conversationId };
|
|
731
|
+
}
|
|
732
|
+
else if (operation === 'search') {
|
|
733
|
+
const query = this.getNodeParameter('query', i);
|
|
734
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
735
|
+
const qs2 = { q: query };
|
|
736
|
+
if (returnAll) {
|
|
737
|
+
responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/conversations/search', {}, qs2, 'payload');
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
const limit = this.getNodeParameter('limit', i);
|
|
741
|
+
qs2.page = 1;
|
|
742
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/search', {}, qs2));
|
|
743
|
+
const payload = (result.payload || []);
|
|
744
|
+
responseData = payload.slice(0, limit);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
694
747
|
else {
|
|
695
748
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
696
749
|
}
|
|
@@ -1062,6 +1115,19 @@ class Chatwoot {
|
|
|
1062
1115
|
if (operation === 'fetch') {
|
|
1063
1116
|
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/profile');
|
|
1064
1117
|
}
|
|
1118
|
+
else if (operation === 'update') {
|
|
1119
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
1120
|
+
const body = {};
|
|
1121
|
+
if (updateFields.name)
|
|
1122
|
+
body.name = updateFields.name;
|
|
1123
|
+
if (updateFields.email)
|
|
1124
|
+
body.email = updateFields.email;
|
|
1125
|
+
if (updateFields.availability)
|
|
1126
|
+
body.availability = updateFields.availability;
|
|
1127
|
+
if (updateFields.auto_offline !== undefined)
|
|
1128
|
+
body.auto_offline = updateFields.auto_offline;
|
|
1129
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PUT', '/profile', body);
|
|
1130
|
+
}
|
|
1065
1131
|
else {
|
|
1066
1132
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1067
1133
|
}
|
|
@@ -1163,6 +1229,213 @@ class Chatwoot {
|
|
|
1163
1229
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1164
1230
|
}
|
|
1165
1231
|
}
|
|
1232
|
+
else if (resource === 'macro') {
|
|
1233
|
+
if (operation === 'getAll') {
|
|
1234
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/macros');
|
|
1235
|
+
}
|
|
1236
|
+
else if (operation === 'get') {
|
|
1237
|
+
const macroId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('macroId', i), 'Macro ID');
|
|
1238
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/macros/${macroId}`);
|
|
1239
|
+
}
|
|
1240
|
+
else if (operation === 'create') {
|
|
1241
|
+
const name = this.getNodeParameter('name', i);
|
|
1242
|
+
const actions = this.getNodeParameter('actions', i);
|
|
1243
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1244
|
+
const body = {
|
|
1245
|
+
name,
|
|
1246
|
+
actions: typeof actions === 'string' ? JSON.parse(actions) : actions,
|
|
1247
|
+
};
|
|
1248
|
+
if (additionalFields.visibility)
|
|
1249
|
+
body.visibility = additionalFields.visibility;
|
|
1250
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/macros', body);
|
|
1251
|
+
}
|
|
1252
|
+
else if (operation === 'update') {
|
|
1253
|
+
const macroId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('macroId', i), 'Macro ID');
|
|
1254
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
1255
|
+
const body = {};
|
|
1256
|
+
if (updateFields.name)
|
|
1257
|
+
body.name = updateFields.name;
|
|
1258
|
+
if (updateFields.visibility)
|
|
1259
|
+
body.visibility = updateFields.visibility;
|
|
1260
|
+
if (updateFields.actions) {
|
|
1261
|
+
body.actions = typeof updateFields.actions === 'string'
|
|
1262
|
+
? JSON.parse(updateFields.actions)
|
|
1263
|
+
: updateFields.actions;
|
|
1264
|
+
}
|
|
1265
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/macros/${macroId}`, body);
|
|
1266
|
+
}
|
|
1267
|
+
else if (operation === 'delete') {
|
|
1268
|
+
const macroId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('macroId', i), 'Macro ID');
|
|
1269
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/macros/${macroId}`);
|
|
1270
|
+
responseData = { success: true, id: macroId };
|
|
1271
|
+
}
|
|
1272
|
+
else if (operation === 'execute') {
|
|
1273
|
+
const macroId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('macroId', i), 'Macro ID');
|
|
1274
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
1275
|
+
const body = { conversation_ids: [conversationId] };
|
|
1276
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/macros/${macroId}/execute`, body);
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
else if (resource === 'notification') {
|
|
1283
|
+
if (operation === 'getAll') {
|
|
1284
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
1285
|
+
const options = this.getNodeParameter('options', i);
|
|
1286
|
+
const qs = {};
|
|
1287
|
+
const includes = [];
|
|
1288
|
+
if (options.includes_read)
|
|
1289
|
+
includes.push('read');
|
|
1290
|
+
if (options.includes_snoozed)
|
|
1291
|
+
includes.push('snoozed');
|
|
1292
|
+
if (includes.length > 0)
|
|
1293
|
+
qs['includes[]'] = includes;
|
|
1294
|
+
if (options.sort_order)
|
|
1295
|
+
qs.sort_order = options.sort_order;
|
|
1296
|
+
if (returnAll) {
|
|
1297
|
+
const allItems = [];
|
|
1298
|
+
let page = 1;
|
|
1299
|
+
let hasMore = true;
|
|
1300
|
+
while (hasMore) {
|
|
1301
|
+
qs.page = page;
|
|
1302
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/notifications', {}, qs));
|
|
1303
|
+
const data = result.data;
|
|
1304
|
+
const payload = ((data === null || data === void 0 ? void 0 : data.payload) || []);
|
|
1305
|
+
allItems.push(...payload);
|
|
1306
|
+
const meta = data === null || data === void 0 ? void 0 : data.meta;
|
|
1307
|
+
const count = (meta === null || meta === void 0 ? void 0 : meta.count) || 0;
|
|
1308
|
+
hasMore = payload.length > 0 && allItems.length < count;
|
|
1309
|
+
page += 1;
|
|
1310
|
+
if (page > 100)
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
responseData = allItems;
|
|
1314
|
+
}
|
|
1315
|
+
else {
|
|
1316
|
+
const limit = this.getNodeParameter('limit', i);
|
|
1317
|
+
qs.page = 1;
|
|
1318
|
+
const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/notifications', {}, qs));
|
|
1319
|
+
const data = result.data;
|
|
1320
|
+
const payload = ((data === null || data === void 0 ? void 0 : data.payload) || []);
|
|
1321
|
+
responseData = payload.slice(0, limit);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
else if (operation === 'markRead') {
|
|
1325
|
+
const notificationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('notificationId', i), 'Notification ID');
|
|
1326
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/notifications/${notificationId}`);
|
|
1327
|
+
}
|
|
1328
|
+
else if (operation === 'delete') {
|
|
1329
|
+
const notificationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('notificationId', i), 'Notification ID');
|
|
1330
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/notifications/${notificationId}`);
|
|
1331
|
+
responseData = { success: true, id: notificationId };
|
|
1332
|
+
}
|
|
1333
|
+
else if (operation === 'readAll') {
|
|
1334
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/notifications/read_all');
|
|
1335
|
+
}
|
|
1336
|
+
else if (operation === 'unreadCount') {
|
|
1337
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/notifications/unread_count');
|
|
1338
|
+
}
|
|
1339
|
+
else if (operation === 'markUnread') {
|
|
1340
|
+
const notificationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('notificationId', i), 'Notification ID');
|
|
1341
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/notifications/${notificationId}/unread`);
|
|
1342
|
+
}
|
|
1343
|
+
else {
|
|
1344
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
else if (resource === 'campaign') {
|
|
1348
|
+
if (operation === 'getAll') {
|
|
1349
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/campaigns');
|
|
1350
|
+
}
|
|
1351
|
+
else if (operation === 'get') {
|
|
1352
|
+
const campaignId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('campaignId', i), 'Campaign ID');
|
|
1353
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/campaigns/${campaignId}`);
|
|
1354
|
+
}
|
|
1355
|
+
else if (operation === 'create') {
|
|
1356
|
+
const title = this.getNodeParameter('title', i);
|
|
1357
|
+
const message = this.getNodeParameter('message', i);
|
|
1358
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1359
|
+
const body = { title, message };
|
|
1360
|
+
if (additionalFields.inbox_id)
|
|
1361
|
+
body.inbox_id = additionalFields.inbox_id;
|
|
1362
|
+
if (additionalFields.scheduled_at)
|
|
1363
|
+
body.scheduled_at = additionalFields.scheduled_at;
|
|
1364
|
+
if (additionalFields.audience) {
|
|
1365
|
+
body.audience = typeof additionalFields.audience === 'string'
|
|
1366
|
+
? JSON.parse(additionalFields.audience)
|
|
1367
|
+
: additionalFields.audience;
|
|
1368
|
+
}
|
|
1369
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/campaigns', body);
|
|
1370
|
+
}
|
|
1371
|
+
else if (operation === 'update') {
|
|
1372
|
+
const campaignId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('campaignId', i), 'Campaign ID');
|
|
1373
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
1374
|
+
const body = {};
|
|
1375
|
+
if (updateFields.title)
|
|
1376
|
+
body.title = updateFields.title;
|
|
1377
|
+
if (updateFields.message)
|
|
1378
|
+
body.message = updateFields.message;
|
|
1379
|
+
if (updateFields.scheduled_at)
|
|
1380
|
+
body.scheduled_at = updateFields.scheduled_at;
|
|
1381
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/campaigns/${campaignId}`, body);
|
|
1382
|
+
}
|
|
1383
|
+
else if (operation === 'delete') {
|
|
1384
|
+
const campaignId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('campaignId', i), 'Campaign ID');
|
|
1385
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/campaigns/${campaignId}`);
|
|
1386
|
+
responseData = { success: true, id: campaignId };
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
else if (resource === 'contactNote') {
|
|
1393
|
+
if (operation === 'getAll') {
|
|
1394
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
1395
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/contacts/${contactId}/notes`);
|
|
1396
|
+
}
|
|
1397
|
+
else if (operation === 'create') {
|
|
1398
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
1399
|
+
const content = this.getNodeParameter('content', i);
|
|
1400
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/contacts/${contactId}/notes`, { content });
|
|
1401
|
+
}
|
|
1402
|
+
else if (operation === 'update') {
|
|
1403
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
1404
|
+
const noteId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('noteId', i), 'Note ID');
|
|
1405
|
+
const content = this.getNodeParameter('content', i);
|
|
1406
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/contacts/${contactId}/notes/${noteId}`, { content });
|
|
1407
|
+
}
|
|
1408
|
+
else if (operation === 'delete') {
|
|
1409
|
+
const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
|
|
1410
|
+
const noteId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('noteId', i), 'Note ID');
|
|
1411
|
+
await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/contacts/${contactId}/notes/${noteId}`);
|
|
1412
|
+
responseData = { success: true, id: noteId };
|
|
1413
|
+
}
|
|
1414
|
+
else {
|
|
1415
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
else if (resource === 'conversationParticipant') {
|
|
1419
|
+
if (operation === 'getAll') {
|
|
1420
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
1421
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/conversations/${conversationId}/participants`);
|
|
1422
|
+
}
|
|
1423
|
+
else if (operation === 'add') {
|
|
1424
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
1425
|
+
const userIdsStr = this.getNodeParameter('userIds', i);
|
|
1426
|
+
const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
|
|
1427
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/participants`, { user_ids: userIds });
|
|
1428
|
+
}
|
|
1429
|
+
else if (operation === 'remove') {
|
|
1430
|
+
const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
|
|
1431
|
+
const userIdsStr = this.getNodeParameter('userIds', i);
|
|
1432
|
+
const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
|
|
1433
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/conversations/${conversationId}/participants`, { user_ids: userIds });
|
|
1434
|
+
}
|
|
1435
|
+
else {
|
|
1436
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1166
1439
|
else if (resource === 'platformAccount') {
|
|
1167
1440
|
if (operation === 'create') {
|
|
1168
1441
|
const name = this.getNodeParameter('name', i);
|