@renatoascencio/n8n-nodes-chatwoot 0.7.4 → 0.8.1
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 +124 -42
- package/dist/nodes/Chatwoot/Chatwoot.node.js.map +1 -1
- package/dist/nodes/Chatwoot/GenericFunctions.d.ts +1 -0
- package/dist/nodes/Chatwoot/GenericFunctions.js +31 -0
- package/dist/nodes/Chatwoot/GenericFunctions.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/liveReport/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/liveReport/index.js +72 -0
- package/dist/nodes/Chatwoot/resources/liveReport/index.js.map +1 -0
- package/dist/nodes/Chatwoot/resources/message/create.operation.js +7 -0
- package/dist/nodes/Chatwoot/resources/message/create.operation.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/report/index.js +234 -29
- package/dist/nodes/Chatwoot/resources/report/index.js.map +1 -1
- package/dist/nodes/Chatwoot/resources/summaryReport/index.d.ts +3 -0
- package/dist/nodes/Chatwoot/resources/summaryReport/index.js +97 -0
- package/dist/nodes/Chatwoot/resources/summaryReport/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -32,6 +32,8 @@ const company_1 = require("./resources/company");
|
|
|
32
32
|
const search_1 = require("./resources/search");
|
|
33
33
|
const slaPolicy_1 = require("./resources/slaPolicy");
|
|
34
34
|
const appliedSla_1 = require("./resources/appliedSla");
|
|
35
|
+
const liveReport_1 = require("./resources/liveReport");
|
|
36
|
+
const summaryReport_1 = require("./resources/summaryReport");
|
|
35
37
|
const platformAccount_1 = require("./resources/platformAccount");
|
|
36
38
|
const platformUser_1 = require("./resources/platformUser");
|
|
37
39
|
const accountUser_1 = require("./resources/accountUser");
|
|
@@ -90,6 +92,8 @@ class Chatwoot {
|
|
|
90
92
|
'search',
|
|
91
93
|
'slaPolicy',
|
|
92
94
|
'appliedSla',
|
|
95
|
+
'liveReport',
|
|
96
|
+
'summaryReport',
|
|
93
97
|
],
|
|
94
98
|
},
|
|
95
99
|
},
|
|
@@ -140,6 +144,7 @@ class Chatwoot {
|
|
|
140
144
|
{ name: 'Inbox', value: 'inbox' },
|
|
141
145
|
{ name: 'Integration', value: 'integration' },
|
|
142
146
|
{ name: 'Label', value: 'label' },
|
|
147
|
+
{ name: 'Live Report', value: 'liveReport' },
|
|
143
148
|
{ name: 'Macro', value: 'macro' },
|
|
144
149
|
{ name: 'Message', value: 'message' },
|
|
145
150
|
{ name: 'Notification', value: 'notification' },
|
|
@@ -147,6 +152,7 @@ class Chatwoot {
|
|
|
147
152
|
{ name: 'Report', value: 'report' },
|
|
148
153
|
{ name: 'Search', value: 'search' },
|
|
149
154
|
{ name: 'SLA Policy (Enterprise)', value: 'slaPolicy' },
|
|
155
|
+
{ name: 'Summary Report', value: 'summaryReport' },
|
|
150
156
|
{ name: 'Team', value: 'team' },
|
|
151
157
|
{ name: 'Webhook', value: 'webhook' },
|
|
152
158
|
{ name: '[Platform] Account', value: 'platformAccount' },
|
|
@@ -188,6 +194,8 @@ class Chatwoot {
|
|
|
188
194
|
search_1.searchOperations,
|
|
189
195
|
slaPolicy_1.slaPolicyOperations,
|
|
190
196
|
appliedSla_1.appliedSlaOperations,
|
|
197
|
+
liveReport_1.liveReportOperations,
|
|
198
|
+
summaryReport_1.summaryReportOperations,
|
|
191
199
|
platformAccount_1.platformAccountOperations,
|
|
192
200
|
platformUser_1.platformUserOperations,
|
|
193
201
|
accountUser_1.accountUserOperations,
|
|
@@ -224,6 +232,8 @@ class Chatwoot {
|
|
|
224
232
|
...search_1.searchFields,
|
|
225
233
|
...slaPolicy_1.slaPolicyFields,
|
|
226
234
|
...appliedSla_1.appliedSlaFields,
|
|
235
|
+
...liveReport_1.liveReportFields,
|
|
236
|
+
...summaryReport_1.summaryReportFields,
|
|
227
237
|
...platformAccount_1.platformAccountFields,
|
|
228
238
|
...platformUser_1.platformUserFields,
|
|
229
239
|
...accountUser_1.accountUserFields,
|
|
@@ -800,6 +810,12 @@ class Chatwoot {
|
|
|
800
810
|
body.content_attributes = options.content_attributes;
|
|
801
811
|
}
|
|
802
812
|
}
|
|
813
|
+
if (options.template_params) {
|
|
814
|
+
const tp = (0, GenericFunctions_1.parseJsonSafe)(options.template_params, 'template_params');
|
|
815
|
+
if (tp && typeof tp === 'object' && Object.keys(tp).length > 0) {
|
|
816
|
+
body.template_params = tp;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
803
819
|
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/messages`, body);
|
|
804
820
|
}
|
|
805
821
|
else if (operation === 'getAll') {
|
|
@@ -1120,56 +1136,88 @@ class Chatwoot {
|
|
|
1120
1136
|
}
|
|
1121
1137
|
}
|
|
1122
1138
|
else if (resource === 'report') {
|
|
1123
|
-
const
|
|
1139
|
+
const toUnix = (val) => Math.floor(new Date(val).getTime() / 1000);
|
|
1140
|
+
const buildQs = (extra = {}) => {
|
|
1141
|
+
const qs = { ...extra };
|
|
1142
|
+
const sinceVal = this.getNodeParameter('since', i, '');
|
|
1143
|
+
const untilVal = this.getNodeParameter('until', i, '');
|
|
1144
|
+
if (sinceVal)
|
|
1145
|
+
qs.since = toUnix(sinceVal);
|
|
1146
|
+
if (untilVal)
|
|
1147
|
+
qs.until = toUnix(untilVal);
|
|
1148
|
+
const opts = this.getNodeParameter('options', i, {});
|
|
1149
|
+
if (opts.id)
|
|
1150
|
+
qs.id = opts.id;
|
|
1151
|
+
if (opts.group_by)
|
|
1152
|
+
qs.group_by = opts.group_by;
|
|
1153
|
+
if (opts.timezone_offset !== undefined)
|
|
1154
|
+
qs.timezone_offset = opts.timezone_offset;
|
|
1155
|
+
if (opts.business_hours !== undefined)
|
|
1156
|
+
qs.business_hours = opts.business_hours;
|
|
1157
|
+
if (opts.days_before)
|
|
1158
|
+
qs.days_before = opts.days_before;
|
|
1159
|
+
if (opts.user_id)
|
|
1160
|
+
qs.user_id = opts.user_id;
|
|
1161
|
+
if (opts.inbox_ids)
|
|
1162
|
+
qs['inbox_ids[]'] = opts.inbox_ids.split(',').map((v) => parseInt(v.trim(), 10));
|
|
1163
|
+
if (opts.label_ids)
|
|
1164
|
+
qs['label_ids[]'] = opts.label_ids.split(',').map((v) => parseInt(v.trim(), 10));
|
|
1165
|
+
return qs;
|
|
1166
|
+
};
|
|
1124
1167
|
if (operation === 'accountSummary') {
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1168
|
+
const type = this.getNodeParameter('type', i);
|
|
1169
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/summary', {}, buildQs({ type }));
|
|
1170
|
+
}
|
|
1171
|
+
else if (operation === 'timeseries') {
|
|
1172
|
+
const type = this.getNodeParameter('type', i);
|
|
1127
1173
|
const metric = this.getNodeParameter('metric', i);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
if (options.timezone_offset)
|
|
1137
|
-
qs.timezone_offset = options.timezone_offset;
|
|
1138
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/summary', {}, qs);
|
|
1174
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports', {}, buildQs({ type, metric }));
|
|
1175
|
+
}
|
|
1176
|
+
else if (operation === 'botSummary') {
|
|
1177
|
+
const type = this.getNodeParameter('type', i);
|
|
1178
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/bot_summary', {}, buildQs({ type }));
|
|
1179
|
+
}
|
|
1180
|
+
else if (operation === 'botMetrics') {
|
|
1181
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/bot_metrics', {}, buildQs());
|
|
1139
1182
|
}
|
|
1140
1183
|
else if (operation === 'agentStatistics') {
|
|
1141
|
-
|
|
1142
|
-
const until = new Date(this.getNodeParameter('until', i)).getTime() / 1000;
|
|
1143
|
-
const options = this.getNodeParameter('options', i);
|
|
1144
|
-
qs.since = since;
|
|
1145
|
-
qs.until = until;
|
|
1146
|
-
if (options.timezone_offset)
|
|
1147
|
-
qs.timezone_offset = options.timezone_offset;
|
|
1148
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/agents', {}, qs);
|
|
1184
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/agents', {}, buildQs());
|
|
1149
1185
|
}
|
|
1150
|
-
else if (operation === '
|
|
1151
|
-
responseData = await GenericFunctions_1.
|
|
1186
|
+
else if (operation === 'inboxStatistics') {
|
|
1187
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/inboxes', {}, buildQs());
|
|
1188
|
+
}
|
|
1189
|
+
else if (operation === 'labelStatistics') {
|
|
1190
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/labels', {}, buildQs());
|
|
1191
|
+
}
|
|
1192
|
+
else if (operation === 'teamStatistics') {
|
|
1193
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/teams', {}, buildQs());
|
|
1152
1194
|
}
|
|
1153
1195
|
else if (operation === 'conversationStatistics') {
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1196
|
+
const conversationType = this.getNodeParameter('conversationType', i);
|
|
1197
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversations', {}, buildQs({ type: conversationType }));
|
|
1198
|
+
}
|
|
1199
|
+
else if (operation === 'conversationsSummary') {
|
|
1200
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversations_summary', {}, buildQs());
|
|
1201
|
+
}
|
|
1202
|
+
else if (operation === 'conversationTraffic') {
|
|
1203
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversation_traffic', {}, buildQs());
|
|
1204
|
+
}
|
|
1205
|
+
else if (operation === 'inboxLabelMatrix') {
|
|
1206
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/inbox_label_matrix', {}, buildQs());
|
|
1207
|
+
}
|
|
1208
|
+
else if (operation === 'firstResponseTimeDistribution') {
|
|
1209
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/first_response_time_distribution', {}, buildQs());
|
|
1210
|
+
}
|
|
1211
|
+
else if (operation === 'outgoingMessagesCount') {
|
|
1156
1212
|
const groupBy = this.getNodeParameter('groupBy', i);
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
else if (groupBy === 'inbox')
|
|
1166
|
-
endpoint = '/reports/inboxes';
|
|
1167
|
-
else if (groupBy === 'team')
|
|
1168
|
-
endpoint = '/reports/teams';
|
|
1169
|
-
else if (groupBy === 'channel_type')
|
|
1170
|
-
endpoint = '/reports/conversations';
|
|
1171
|
-
qs.type = groupBy;
|
|
1172
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1213
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/outgoing_messages_count', {}, buildQs({ group_by: groupBy }));
|
|
1214
|
+
}
|
|
1215
|
+
else if (operation === 'yearInReview') {
|
|
1216
|
+
const year = this.getNodeParameter('year', i);
|
|
1217
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/year_in_review', {}, { year });
|
|
1218
|
+
}
|
|
1219
|
+
else if (operation === 'conversationCounts') {
|
|
1220
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/meta');
|
|
1173
1221
|
}
|
|
1174
1222
|
else {
|
|
1175
1223
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
@@ -1779,6 +1827,40 @@ class Chatwoot {
|
|
|
1779
1827
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1780
1828
|
}
|
|
1781
1829
|
}
|
|
1830
|
+
else if (resource === 'liveReport') {
|
|
1831
|
+
if (operation === 'conversationMetrics') {
|
|
1832
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1833
|
+
const qs = {};
|
|
1834
|
+
if (options.team_id)
|
|
1835
|
+
qs.team_id = options.team_id;
|
|
1836
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/live_reports/conversation_metrics', {}, qs);
|
|
1837
|
+
}
|
|
1838
|
+
else if (operation === 'groupedConversationMetrics') {
|
|
1839
|
+
const groupBy = this.getNodeParameter('groupBy', i);
|
|
1840
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1841
|
+
const qs = { group_by: groupBy };
|
|
1842
|
+
if (options.team_id)
|
|
1843
|
+
qs.team_id = options.team_id;
|
|
1844
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/live_reports/grouped_conversation_metrics', {}, qs);
|
|
1845
|
+
}
|
|
1846
|
+
else {
|
|
1847
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
else if (resource === 'summaryReport') {
|
|
1851
|
+
const since = Math.floor(new Date(this.getNodeParameter('since', i)).getTime() / 1000);
|
|
1852
|
+
const until = Math.floor(new Date(this.getNodeParameter('until', i)).getTime() / 1000);
|
|
1853
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1854
|
+
const qs = { since, until };
|
|
1855
|
+
if (options.business_hours !== undefined)
|
|
1856
|
+
qs.business_hours = options.business_hours;
|
|
1857
|
+
if (['agent', 'team', 'inbox', 'label', 'channel'].includes(operation)) {
|
|
1858
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', `/summary_reports/${operation}`, {}, qs);
|
|
1859
|
+
}
|
|
1860
|
+
else {
|
|
1861
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1782
1864
|
else if (resource === 'platformAccount') {
|
|
1783
1865
|
if (operation === 'create') {
|
|
1784
1866
|
const name = this.getNodeParameter('name', i);
|