@renatoascencio/n8n-nodes-chatwoot 0.7.3 → 0.8.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 +121 -44
- 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/contact/create.operation.js +7 -14
- package/dist/nodes/Chatwoot/resources/contact/create.operation.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/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,
|
|
@@ -832,12 +842,13 @@ class Chatwoot {
|
|
|
832
842
|
}
|
|
833
843
|
else if (resource === 'contact') {
|
|
834
844
|
if (operation === 'create') {
|
|
835
|
-
const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
|
|
836
845
|
const name = this.getNodeParameter('name', i);
|
|
837
846
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
838
|
-
const body = {
|
|
847
|
+
const body = {};
|
|
839
848
|
if (name)
|
|
840
849
|
body.name = name;
|
|
850
|
+
if (additionalFields.inbox_id)
|
|
851
|
+
body.inbox_id = additionalFields.inbox_id;
|
|
841
852
|
if (additionalFields.email)
|
|
842
853
|
body.email = additionalFields.email;
|
|
843
854
|
if (additionalFields.phone_number)
|
|
@@ -1119,56 +1130,88 @@ class Chatwoot {
|
|
|
1119
1130
|
}
|
|
1120
1131
|
}
|
|
1121
1132
|
else if (resource === 'report') {
|
|
1122
|
-
const
|
|
1133
|
+
const toUnix = (val) => Math.floor(new Date(val).getTime() / 1000);
|
|
1134
|
+
const buildQs = (extra = {}) => {
|
|
1135
|
+
const qs = { ...extra };
|
|
1136
|
+
const sinceVal = this.getNodeParameter('since', i, '');
|
|
1137
|
+
const untilVal = this.getNodeParameter('until', i, '');
|
|
1138
|
+
if (sinceVal)
|
|
1139
|
+
qs.since = toUnix(sinceVal);
|
|
1140
|
+
if (untilVal)
|
|
1141
|
+
qs.until = toUnix(untilVal);
|
|
1142
|
+
const opts = this.getNodeParameter('options', i, {});
|
|
1143
|
+
if (opts.id)
|
|
1144
|
+
qs.id = opts.id;
|
|
1145
|
+
if (opts.group_by)
|
|
1146
|
+
qs.group_by = opts.group_by;
|
|
1147
|
+
if (opts.timezone_offset !== undefined)
|
|
1148
|
+
qs.timezone_offset = opts.timezone_offset;
|
|
1149
|
+
if (opts.business_hours !== undefined)
|
|
1150
|
+
qs.business_hours = opts.business_hours;
|
|
1151
|
+
if (opts.days_before)
|
|
1152
|
+
qs.days_before = opts.days_before;
|
|
1153
|
+
if (opts.user_id)
|
|
1154
|
+
qs.user_id = opts.user_id;
|
|
1155
|
+
if (opts.inbox_ids)
|
|
1156
|
+
qs['inbox_ids[]'] = opts.inbox_ids.split(',').map((v) => parseInt(v.trim(), 10));
|
|
1157
|
+
if (opts.label_ids)
|
|
1158
|
+
qs['label_ids[]'] = opts.label_ids.split(',').map((v) => parseInt(v.trim(), 10));
|
|
1159
|
+
return qs;
|
|
1160
|
+
};
|
|
1123
1161
|
if (operation === 'accountSummary') {
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1162
|
+
const type = this.getNodeParameter('type', i);
|
|
1163
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/summary', {}, buildQs({ type }));
|
|
1164
|
+
}
|
|
1165
|
+
else if (operation === 'timeseries') {
|
|
1166
|
+
const type = this.getNodeParameter('type', i);
|
|
1126
1167
|
const metric = this.getNodeParameter('metric', i);
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
if (options.timezone_offset)
|
|
1136
|
-
qs.timezone_offset = options.timezone_offset;
|
|
1137
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/summary', {}, qs);
|
|
1168
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports', {}, buildQs({ type, metric }));
|
|
1169
|
+
}
|
|
1170
|
+
else if (operation === 'botSummary') {
|
|
1171
|
+
const type = this.getNodeParameter('type', i);
|
|
1172
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/bot_summary', {}, buildQs({ type }));
|
|
1173
|
+
}
|
|
1174
|
+
else if (operation === 'botMetrics') {
|
|
1175
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/bot_metrics', {}, buildQs());
|
|
1138
1176
|
}
|
|
1139
1177
|
else if (operation === 'agentStatistics') {
|
|
1140
|
-
|
|
1141
|
-
const until = new Date(this.getNodeParameter('until', i)).getTime() / 1000;
|
|
1142
|
-
const options = this.getNodeParameter('options', i);
|
|
1143
|
-
qs.since = since;
|
|
1144
|
-
qs.until = until;
|
|
1145
|
-
if (options.timezone_offset)
|
|
1146
|
-
qs.timezone_offset = options.timezone_offset;
|
|
1147
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/agents', {}, qs);
|
|
1178
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/agents', {}, buildQs());
|
|
1148
1179
|
}
|
|
1149
|
-
else if (operation === '
|
|
1150
|
-
responseData = await GenericFunctions_1.
|
|
1180
|
+
else if (operation === 'inboxStatistics') {
|
|
1181
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/inboxes', {}, buildQs());
|
|
1182
|
+
}
|
|
1183
|
+
else if (operation === 'labelStatistics') {
|
|
1184
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/labels', {}, buildQs());
|
|
1185
|
+
}
|
|
1186
|
+
else if (operation === 'teamStatistics') {
|
|
1187
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/teams', {}, buildQs());
|
|
1151
1188
|
}
|
|
1152
1189
|
else if (operation === 'conversationStatistics') {
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1190
|
+
const conversationType = this.getNodeParameter('conversationType', i);
|
|
1191
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversations', {}, buildQs({ type: conversationType }));
|
|
1192
|
+
}
|
|
1193
|
+
else if (operation === 'conversationsSummary') {
|
|
1194
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversations_summary', {}, buildQs());
|
|
1195
|
+
}
|
|
1196
|
+
else if (operation === 'conversationTraffic') {
|
|
1197
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/conversation_traffic', {}, buildQs());
|
|
1198
|
+
}
|
|
1199
|
+
else if (operation === 'inboxLabelMatrix') {
|
|
1200
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/inbox_label_matrix', {}, buildQs());
|
|
1201
|
+
}
|
|
1202
|
+
else if (operation === 'firstResponseTimeDistribution') {
|
|
1203
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/first_response_time_distribution', {}, buildQs());
|
|
1204
|
+
}
|
|
1205
|
+
else if (operation === 'outgoingMessagesCount') {
|
|
1155
1206
|
const groupBy = this.getNodeParameter('groupBy', i);
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
else if (groupBy === 'inbox')
|
|
1165
|
-
endpoint = '/reports/inboxes';
|
|
1166
|
-
else if (groupBy === 'team')
|
|
1167
|
-
endpoint = '/reports/teams';
|
|
1168
|
-
else if (groupBy === 'channel_type')
|
|
1169
|
-
endpoint = '/reports/conversations';
|
|
1170
|
-
qs.type = groupBy;
|
|
1171
|
-
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', endpoint, {}, qs);
|
|
1207
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/reports/outgoing_messages_count', {}, buildQs({ group_by: groupBy }));
|
|
1208
|
+
}
|
|
1209
|
+
else if (operation === 'yearInReview') {
|
|
1210
|
+
const year = this.getNodeParameter('year', i);
|
|
1211
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/year_in_review', {}, { year });
|
|
1212
|
+
}
|
|
1213
|
+
else if (operation === 'conversationCounts') {
|
|
1214
|
+
responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/meta');
|
|
1172
1215
|
}
|
|
1173
1216
|
else {
|
|
1174
1217
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
@@ -1778,6 +1821,40 @@ class Chatwoot {
|
|
|
1778
1821
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1779
1822
|
}
|
|
1780
1823
|
}
|
|
1824
|
+
else if (resource === 'liveReport') {
|
|
1825
|
+
if (operation === 'conversationMetrics') {
|
|
1826
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1827
|
+
const qs = {};
|
|
1828
|
+
if (options.team_id)
|
|
1829
|
+
qs.team_id = options.team_id;
|
|
1830
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/live_reports/conversation_metrics', {}, qs);
|
|
1831
|
+
}
|
|
1832
|
+
else if (operation === 'groupedConversationMetrics') {
|
|
1833
|
+
const groupBy = this.getNodeParameter('groupBy', i);
|
|
1834
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1835
|
+
const qs = { group_by: groupBy };
|
|
1836
|
+
if (options.team_id)
|
|
1837
|
+
qs.team_id = options.team_id;
|
|
1838
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', '/live_reports/grouped_conversation_metrics', {}, qs);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
else if (resource === 'summaryReport') {
|
|
1845
|
+
const since = Math.floor(new Date(this.getNodeParameter('since', i)).getTime() / 1000);
|
|
1846
|
+
const until = Math.floor(new Date(this.getNodeParameter('until', i)).getTime() / 1000);
|
|
1847
|
+
const options = this.getNodeParameter('options', i, {});
|
|
1848
|
+
const qs = { since, until };
|
|
1849
|
+
if (options.business_hours !== undefined)
|
|
1850
|
+
qs.business_hours = options.business_hours;
|
|
1851
|
+
if (['agent', 'team', 'inbox', 'label', 'channel'].includes(operation)) {
|
|
1852
|
+
responseData = await GenericFunctions_1.chatwootApiV2Request.call(this, 'GET', `/summary_reports/${operation}`, {}, qs);
|
|
1853
|
+
}
|
|
1854
|
+
else {
|
|
1855
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1781
1858
|
else if (resource === 'platformAccount') {
|
|
1782
1859
|
if (operation === 'create') {
|
|
1783
1860
|
const name = this.getNodeParameter('name', i);
|