n8n-nodes-tukimate 1.0.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.
|
@@ -0,0 +1,1251 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TukiMate = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const BASE_URL = 'https://app.tukimate.com/api';
|
|
6
|
+
// Resource definitions
|
|
7
|
+
const RESOURCES = {
|
|
8
|
+
CONVERSATION: 'conversation',
|
|
9
|
+
CONTACT: 'contact',
|
|
10
|
+
TEAM: 'team',
|
|
11
|
+
PROJECT: 'project',
|
|
12
|
+
CLIENT: 'client',
|
|
13
|
+
SOURCE: 'source',
|
|
14
|
+
CONVERSATION_TYPE: 'conversationType',
|
|
15
|
+
};
|
|
16
|
+
// Operation definitions
|
|
17
|
+
const OPERATIONS = {
|
|
18
|
+
LIST: 'list',
|
|
19
|
+
GET: 'get',
|
|
20
|
+
CREATE: 'create',
|
|
21
|
+
UPDATE: 'update',
|
|
22
|
+
};
|
|
23
|
+
// Helper to make API requests
|
|
24
|
+
async function tukiMateRequest(method, endpoint, body, query) {
|
|
25
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
26
|
+
const apiKey = credentials.apiKey;
|
|
27
|
+
const url = new URL(`${BASE_URL}${endpoint}`);
|
|
28
|
+
if (query) {
|
|
29
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
30
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
31
|
+
url.searchParams.append(key, String(value));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const options = {
|
|
36
|
+
method,
|
|
37
|
+
headers: {
|
|
38
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
if (body && (method === 'POST' || method === 'PUT')) {
|
|
43
|
+
options.body = JSON.stringify(body);
|
|
44
|
+
}
|
|
45
|
+
const response = await this.helpers.request(url.toString(), options);
|
|
46
|
+
// Handle JSON response
|
|
47
|
+
if (typeof response === 'string') {
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(response);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
// Load options helpers
|
|
58
|
+
async function getTeamOptions() {
|
|
59
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
60
|
+
const apiKey = credentials.apiKey;
|
|
61
|
+
const response = await this.helpers.request({
|
|
62
|
+
method: 'GET',
|
|
63
|
+
url: `${BASE_URL}/teams`,
|
|
64
|
+
headers: {
|
|
65
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
66
|
+
},
|
|
67
|
+
json: true,
|
|
68
|
+
});
|
|
69
|
+
const teams = Array.isArray(response) ? response : [];
|
|
70
|
+
return teams.map((team) => ({
|
|
71
|
+
name: team.name,
|
|
72
|
+
value: team.id,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
async function getProjectOptions() {
|
|
76
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
77
|
+
const apiKey = credentials.apiKey;
|
|
78
|
+
const response = await this.helpers.request({
|
|
79
|
+
method: 'GET',
|
|
80
|
+
url: `${BASE_URL}/projects`,
|
|
81
|
+
headers: {
|
|
82
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
83
|
+
},
|
|
84
|
+
json: true,
|
|
85
|
+
});
|
|
86
|
+
const projects = Array.isArray(response) ? response : [];
|
|
87
|
+
return projects.map((project) => ({
|
|
88
|
+
name: project.name,
|
|
89
|
+
value: project.id,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
async function getClientOptions() {
|
|
93
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
94
|
+
const apiKey = credentials.apiKey;
|
|
95
|
+
const response = await this.helpers.request({
|
|
96
|
+
method: 'GET',
|
|
97
|
+
url: `${BASE_URL}/clients`,
|
|
98
|
+
headers: {
|
|
99
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
100
|
+
},
|
|
101
|
+
json: true,
|
|
102
|
+
});
|
|
103
|
+
const clients = Array.isArray(response) ? response : [];
|
|
104
|
+
return clients.map((client) => ({
|
|
105
|
+
name: client.name,
|
|
106
|
+
value: client.id,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
async function getSourceOptions() {
|
|
110
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
111
|
+
const apiKey = credentials.apiKey;
|
|
112
|
+
const response = await this.helpers.request({
|
|
113
|
+
method: 'GET',
|
|
114
|
+
url: `${BASE_URL}/sources`,
|
|
115
|
+
headers: {
|
|
116
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
117
|
+
},
|
|
118
|
+
json: true,
|
|
119
|
+
});
|
|
120
|
+
const sources = Array.isArray(response) ? response : [];
|
|
121
|
+
return sources.map((source) => ({
|
|
122
|
+
name: source.label || source.key,
|
|
123
|
+
value: source.key,
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
async function getConversationTypeOptions() {
|
|
127
|
+
const credentials = await this.getCredentials('tukiMateApi');
|
|
128
|
+
const apiKey = credentials.apiKey;
|
|
129
|
+
const response = await this.helpers.request({
|
|
130
|
+
method: 'GET',
|
|
131
|
+
url: `${BASE_URL}/conversation-types`,
|
|
132
|
+
headers: {
|
|
133
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
134
|
+
},
|
|
135
|
+
json: true,
|
|
136
|
+
});
|
|
137
|
+
const types = Array.isArray(response) ? response : [];
|
|
138
|
+
return types.map((type) => ({
|
|
139
|
+
name: type.label || type.key,
|
|
140
|
+
value: type.key,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
class TukiMate {
|
|
144
|
+
description = {
|
|
145
|
+
displayName: 'TukiMate',
|
|
146
|
+
name: 'tukiMate',
|
|
147
|
+
icon: 'file:tukimate.svg',
|
|
148
|
+
group: ['transform'],
|
|
149
|
+
version: 1,
|
|
150
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
151
|
+
description: 'Interact with TukiMate API',
|
|
152
|
+
defaults: {
|
|
153
|
+
name: 'TukiMate',
|
|
154
|
+
},
|
|
155
|
+
inputs: ['main'],
|
|
156
|
+
outputs: ['main'],
|
|
157
|
+
credentials: [
|
|
158
|
+
{
|
|
159
|
+
name: 'tukiMateApi',
|
|
160
|
+
required: true,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
requestDefaults: {
|
|
164
|
+
baseURL: BASE_URL,
|
|
165
|
+
headers: {
|
|
166
|
+
Accept: 'application/json',
|
|
167
|
+
'Content-Type': 'application/json',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
properties: [
|
|
171
|
+
// Resource selector
|
|
172
|
+
{
|
|
173
|
+
displayName: 'Resource',
|
|
174
|
+
name: 'resource',
|
|
175
|
+
type: 'options',
|
|
176
|
+
noDataExpression: true,
|
|
177
|
+
options: [
|
|
178
|
+
{ name: 'Conversation', value: RESOURCES.CONVERSATION },
|
|
179
|
+
{ name: 'Contact', value: RESOURCES.CONTACT },
|
|
180
|
+
{ name: 'Team', value: RESOURCES.TEAM },
|
|
181
|
+
{ name: 'Project', value: RESOURCES.PROJECT },
|
|
182
|
+
{ name: 'Client', value: RESOURCES.CLIENT },
|
|
183
|
+
{ name: 'Source', value: RESOURCES.SOURCE },
|
|
184
|
+
{ name: 'Conversation Type', value: RESOURCES.CONVERSATION_TYPE },
|
|
185
|
+
],
|
|
186
|
+
default: RESOURCES.CONVERSATION,
|
|
187
|
+
},
|
|
188
|
+
// ==================== CONVERSATION ====================
|
|
189
|
+
// Operation selector for Conversation
|
|
190
|
+
{
|
|
191
|
+
displayName: 'Operation',
|
|
192
|
+
name: 'operation',
|
|
193
|
+
type: 'options',
|
|
194
|
+
noDataExpression: true,
|
|
195
|
+
displayOptions: {
|
|
196
|
+
show: {
|
|
197
|
+
resource: [RESOURCES.CONVERSATION],
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
options: [
|
|
201
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of conversations' },
|
|
202
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single conversation' },
|
|
203
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new conversation' },
|
|
204
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a conversation' },
|
|
205
|
+
],
|
|
206
|
+
default: OPERATIONS.LIST,
|
|
207
|
+
},
|
|
208
|
+
// Conversation: List filters
|
|
209
|
+
{
|
|
210
|
+
displayName: 'Search',
|
|
211
|
+
name: 'search',
|
|
212
|
+
type: 'string',
|
|
213
|
+
displayOptions: {
|
|
214
|
+
show: {
|
|
215
|
+
resource: [RESOURCES.CONVERSATION],
|
|
216
|
+
operation: [OPERATIONS.LIST],
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
default: '',
|
|
220
|
+
description: 'Search term to filter conversations',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
displayName: 'Team',
|
|
224
|
+
name: 'teamId',
|
|
225
|
+
type: 'options',
|
|
226
|
+
typeOptions: {
|
|
227
|
+
loadOptionsMethod: 'getTeams',
|
|
228
|
+
},
|
|
229
|
+
displayOptions: {
|
|
230
|
+
show: {
|
|
231
|
+
resource: [RESOURCES.CONVERSATION],
|
|
232
|
+
operation: [OPERATIONS.LIST, OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
default: '',
|
|
236
|
+
description: 'Filter or set by team',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
displayName: 'Project',
|
|
240
|
+
name: 'projectId',
|
|
241
|
+
type: 'options',
|
|
242
|
+
typeOptions: {
|
|
243
|
+
loadOptionsMethod: 'getProjects',
|
|
244
|
+
},
|
|
245
|
+
displayOptions: {
|
|
246
|
+
show: {
|
|
247
|
+
resource: [RESOURCES.CONVERSATION],
|
|
248
|
+
operation: [OPERATIONS.LIST, OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
default: '',
|
|
252
|
+
description: 'Filter or set by project',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
displayName: 'Limit',
|
|
256
|
+
name: 'limit',
|
|
257
|
+
type: 'number',
|
|
258
|
+
displayOptions: {
|
|
259
|
+
show: {
|
|
260
|
+
resource: [RESOURCES.CONVERSATION],
|
|
261
|
+
operation: [OPERATIONS.LIST],
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
default: 100,
|
|
265
|
+
description: 'Max number of results',
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
displayName: 'Offset',
|
|
269
|
+
name: 'offset',
|
|
270
|
+
type: 'number',
|
|
271
|
+
displayOptions: {
|
|
272
|
+
show: {
|
|
273
|
+
resource: [RESOURCES.CONVERSATION],
|
|
274
|
+
operation: [OPERATIONS.LIST],
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
default: 0,
|
|
278
|
+
description: 'Number of results to skip',
|
|
279
|
+
},
|
|
280
|
+
// Conversation: Get by ID
|
|
281
|
+
{
|
|
282
|
+
displayName: 'Conversation ID',
|
|
283
|
+
name: 'conversationId',
|
|
284
|
+
type: 'string',
|
|
285
|
+
required: true,
|
|
286
|
+
displayOptions: {
|
|
287
|
+
show: {
|
|
288
|
+
resource: [RESOURCES.CONVERSATION],
|
|
289
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
default: '',
|
|
293
|
+
description: 'The ID of the conversation',
|
|
294
|
+
},
|
|
295
|
+
// Conversation: Create/Update fields
|
|
296
|
+
{
|
|
297
|
+
displayName: 'Title',
|
|
298
|
+
name: 'title',
|
|
299
|
+
type: 'string',
|
|
300
|
+
required: true,
|
|
301
|
+
displayOptions: {
|
|
302
|
+
show: {
|
|
303
|
+
resource: [RESOURCES.CONVERSATION],
|
|
304
|
+
operation: [OPERATIONS.CREATE],
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
default: '',
|
|
308
|
+
description: 'Title of the conversation',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
displayName: 'Date Time',
|
|
312
|
+
name: 'dateTime',
|
|
313
|
+
type: 'dateTime',
|
|
314
|
+
required: true,
|
|
315
|
+
displayOptions: {
|
|
316
|
+
show: {
|
|
317
|
+
resource: [RESOURCES.CONVERSATION],
|
|
318
|
+
operation: [OPERATIONS.CREATE],
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
default: '',
|
|
322
|
+
description: 'Date and time of the conversation',
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
displayName: 'Duration (Minutes)',
|
|
326
|
+
name: 'durationMinutes',
|
|
327
|
+
type: 'number',
|
|
328
|
+
displayOptions: {
|
|
329
|
+
show: {
|
|
330
|
+
resource: [RESOURCES.CONVERSATION],
|
|
331
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
default: 0,
|
|
335
|
+
description: 'Duration of the conversation in minutes',
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
displayName: 'Transcript',
|
|
339
|
+
name: 'transcript',
|
|
340
|
+
type: 'string',
|
|
341
|
+
required: true,
|
|
342
|
+
displayOptions: {
|
|
343
|
+
show: {
|
|
344
|
+
resource: [RESOURCES.CONVERSATION],
|
|
345
|
+
operation: [OPERATIONS.CREATE],
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
default: '',
|
|
349
|
+
description: 'Full transcript of the conversation',
|
|
350
|
+
typeOptions: {
|
|
351
|
+
rows: 10,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
displayName: 'Source',
|
|
356
|
+
name: 'sourceKey',
|
|
357
|
+
type: 'options',
|
|
358
|
+
typeOptions: {
|
|
359
|
+
loadOptionsMethod: 'getSources',
|
|
360
|
+
},
|
|
361
|
+
displayOptions: {
|
|
362
|
+
show: {
|
|
363
|
+
resource: [RESOURCES.CONVERSATION],
|
|
364
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
default: '',
|
|
368
|
+
description: 'Source of the conversation',
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
displayName: 'Conversation Type',
|
|
372
|
+
name: 'conversationTypeKey',
|
|
373
|
+
type: 'options',
|
|
374
|
+
typeOptions: {
|
|
375
|
+
loadOptionsMethod: 'getConversationTypes',
|
|
376
|
+
},
|
|
377
|
+
displayOptions: {
|
|
378
|
+
show: {
|
|
379
|
+
resource: [RESOURCES.CONVERSATION],
|
|
380
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
default: 'meeting',
|
|
384
|
+
description: 'Type of conversation',
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
displayName: 'Client',
|
|
388
|
+
name: 'clientId',
|
|
389
|
+
type: 'options',
|
|
390
|
+
typeOptions: {
|
|
391
|
+
loadOptionsMethod: 'getClients',
|
|
392
|
+
},
|
|
393
|
+
displayOptions: {
|
|
394
|
+
show: {
|
|
395
|
+
resource: [RESOURCES.CONVERSATION],
|
|
396
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
default: '',
|
|
400
|
+
description: 'Associated client',
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
displayName: 'Description',
|
|
404
|
+
name: 'description',
|
|
405
|
+
type: 'string',
|
|
406
|
+
displayOptions: {
|
|
407
|
+
show: {
|
|
408
|
+
resource: [RESOURCES.CONVERSATION],
|
|
409
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
default: '',
|
|
413
|
+
description: 'Description of the conversation',
|
|
414
|
+
typeOptions: {
|
|
415
|
+
rows: 4,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
displayName: 'Participants',
|
|
420
|
+
name: 'participants',
|
|
421
|
+
type: 'fixedCollection',
|
|
422
|
+
typeOptions: {
|
|
423
|
+
multipleValues: true,
|
|
424
|
+
},
|
|
425
|
+
displayOptions: {
|
|
426
|
+
show: {
|
|
427
|
+
resource: [RESOURCES.CONVERSATION],
|
|
428
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
default: {},
|
|
432
|
+
options: [
|
|
433
|
+
{
|
|
434
|
+
name: 'participant',
|
|
435
|
+
displayName: 'Participant',
|
|
436
|
+
values: [
|
|
437
|
+
{ displayName: 'Name', name: 'name', type: 'string', default: '' },
|
|
438
|
+
{ displayName: 'Email', name: 'email', type: 'string', default: '' },
|
|
439
|
+
{ displayName: 'Contact ID', name: 'contact_id', type: 'string', default: '' },
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
],
|
|
443
|
+
description: 'Participants in the conversation',
|
|
444
|
+
},
|
|
445
|
+
// ==================== CONTACT ====================
|
|
446
|
+
{
|
|
447
|
+
displayName: 'Operation',
|
|
448
|
+
name: 'operation',
|
|
449
|
+
type: 'options',
|
|
450
|
+
noDataExpression: true,
|
|
451
|
+
displayOptions: {
|
|
452
|
+
show: {
|
|
453
|
+
resource: [RESOURCES.CONTACT],
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
options: [
|
|
457
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of contacts' },
|
|
458
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single contact' },
|
|
459
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new contact' },
|
|
460
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a contact' },
|
|
461
|
+
],
|
|
462
|
+
default: OPERATIONS.LIST,
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
displayName: 'Contact ID',
|
|
466
|
+
name: 'contactId',
|
|
467
|
+
type: 'string',
|
|
468
|
+
required: true,
|
|
469
|
+
displayOptions: {
|
|
470
|
+
show: {
|
|
471
|
+
resource: [RESOURCES.CONTACT],
|
|
472
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
default: '',
|
|
476
|
+
description: 'The ID of the contact',
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
displayName: 'First Name',
|
|
480
|
+
name: 'firstName',
|
|
481
|
+
type: 'string',
|
|
482
|
+
displayOptions: {
|
|
483
|
+
show: {
|
|
484
|
+
resource: [RESOURCES.CONTACT],
|
|
485
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
default: '',
|
|
489
|
+
description: 'First name of the contact',
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
displayName: 'Last Name',
|
|
493
|
+
name: 'lastName',
|
|
494
|
+
type: 'string',
|
|
495
|
+
displayOptions: {
|
|
496
|
+
show: {
|
|
497
|
+
resource: [RESOURCES.CONTACT],
|
|
498
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
default: '',
|
|
502
|
+
description: 'Last name of the contact',
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
displayName: 'Email',
|
|
506
|
+
name: 'email',
|
|
507
|
+
type: 'string',
|
|
508
|
+
displayOptions: {
|
|
509
|
+
show: {
|
|
510
|
+
resource: [RESOURCES.CONTACT],
|
|
511
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
default: '',
|
|
515
|
+
description: 'Email address',
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
displayName: 'Phone',
|
|
519
|
+
name: 'phone',
|
|
520
|
+
type: 'string',
|
|
521
|
+
displayOptions: {
|
|
522
|
+
show: {
|
|
523
|
+
resource: [RESOURCES.CONTACT],
|
|
524
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
525
|
+
},
|
|
526
|
+
},
|
|
527
|
+
default: '',
|
|
528
|
+
description: 'Phone number',
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
displayName: 'Company',
|
|
532
|
+
name: 'company',
|
|
533
|
+
type: 'string',
|
|
534
|
+
displayOptions: {
|
|
535
|
+
show: {
|
|
536
|
+
resource: [RESOURCES.CONTACT],
|
|
537
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
default: '',
|
|
541
|
+
description: 'Company name',
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
displayName: 'Job Title',
|
|
545
|
+
name: 'jobTitle',
|
|
546
|
+
type: 'string',
|
|
547
|
+
displayOptions: {
|
|
548
|
+
show: {
|
|
549
|
+
resource: [RESOURCES.CONTACT],
|
|
550
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
default: '',
|
|
554
|
+
description: 'Job title',
|
|
555
|
+
},
|
|
556
|
+
// ==================== TEAM ====================
|
|
557
|
+
{
|
|
558
|
+
displayName: 'Operation',
|
|
559
|
+
name: 'operation',
|
|
560
|
+
type: 'options',
|
|
561
|
+
noDataExpression: true,
|
|
562
|
+
displayOptions: {
|
|
563
|
+
show: {
|
|
564
|
+
resource: [RESOURCES.TEAM],
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
options: [
|
|
568
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of teams' },
|
|
569
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single team' },
|
|
570
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new team' },
|
|
571
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a team' },
|
|
572
|
+
],
|
|
573
|
+
default: OPERATIONS.LIST,
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
displayName: 'Team ID',
|
|
577
|
+
name: 'teamId',
|
|
578
|
+
type: 'string',
|
|
579
|
+
required: true,
|
|
580
|
+
displayOptions: {
|
|
581
|
+
show: {
|
|
582
|
+
resource: [RESOURCES.TEAM],
|
|
583
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
default: '',
|
|
587
|
+
description: 'The ID of the team',
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
displayName: 'Name',
|
|
591
|
+
name: 'name',
|
|
592
|
+
type: 'string',
|
|
593
|
+
displayOptions: {
|
|
594
|
+
show: {
|
|
595
|
+
resource: [RESOURCES.TEAM],
|
|
596
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
default: '',
|
|
600
|
+
description: 'Name of the team',
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
displayName: 'Description',
|
|
604
|
+
name: 'description',
|
|
605
|
+
type: 'string',
|
|
606
|
+
displayOptions: {
|
|
607
|
+
show: {
|
|
608
|
+
resource: [RESOURCES.TEAM],
|
|
609
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
default: '',
|
|
613
|
+
description: 'Description of the team',
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
displayName: 'Color',
|
|
617
|
+
name: 'color',
|
|
618
|
+
type: 'string',
|
|
619
|
+
displayOptions: {
|
|
620
|
+
show: {
|
|
621
|
+
resource: [RESOURCES.TEAM],
|
|
622
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
default: '#3b82f6',
|
|
626
|
+
description: 'Color hex code (e.g., #3b82f6)',
|
|
627
|
+
},
|
|
628
|
+
// ==================== PROJECT ====================
|
|
629
|
+
{
|
|
630
|
+
displayName: 'Operation',
|
|
631
|
+
name: 'operation',
|
|
632
|
+
type: 'options',
|
|
633
|
+
noDataExpression: true,
|
|
634
|
+
displayOptions: {
|
|
635
|
+
show: {
|
|
636
|
+
resource: [RESOURCES.PROJECT],
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
options: [
|
|
640
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of projects' },
|
|
641
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single project' },
|
|
642
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new project' },
|
|
643
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a project' },
|
|
644
|
+
],
|
|
645
|
+
default: OPERATIONS.LIST,
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
displayName: 'Project ID',
|
|
649
|
+
name: 'projectId',
|
|
650
|
+
type: 'string',
|
|
651
|
+
required: true,
|
|
652
|
+
displayOptions: {
|
|
653
|
+
show: {
|
|
654
|
+
resource: [RESOURCES.PROJECT],
|
|
655
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
default: '',
|
|
659
|
+
description: 'The ID of the project',
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
displayName: 'Name',
|
|
663
|
+
name: 'name',
|
|
664
|
+
type: 'string',
|
|
665
|
+
displayOptions: {
|
|
666
|
+
show: {
|
|
667
|
+
resource: [RESOURCES.PROJECT],
|
|
668
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
default: '',
|
|
672
|
+
description: 'Name of the project',
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
displayName: 'Description',
|
|
676
|
+
name: 'description',
|
|
677
|
+
type: 'string',
|
|
678
|
+
displayOptions: {
|
|
679
|
+
show: {
|
|
680
|
+
resource: [RESOURCES.PROJECT],
|
|
681
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
default: '',
|
|
685
|
+
description: 'Description of the project',
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
displayName: 'Status',
|
|
689
|
+
name: 'status',
|
|
690
|
+
type: 'options',
|
|
691
|
+
displayOptions: {
|
|
692
|
+
show: {
|
|
693
|
+
resource: [RESOURCES.PROJECT],
|
|
694
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
options: [
|
|
698
|
+
{ name: 'Active', value: 'active' },
|
|
699
|
+
{ name: 'Archived', value: 'archived' },
|
|
700
|
+
{ name: 'Completed', value: 'completed' },
|
|
701
|
+
],
|
|
702
|
+
default: 'active',
|
|
703
|
+
description: 'Status of the project',
|
|
704
|
+
},
|
|
705
|
+
// ==================== CLIENT ====================
|
|
706
|
+
{
|
|
707
|
+
displayName: 'Operation',
|
|
708
|
+
name: 'operation',
|
|
709
|
+
type: 'options',
|
|
710
|
+
noDataExpression: true,
|
|
711
|
+
displayOptions: {
|
|
712
|
+
show: {
|
|
713
|
+
resource: [RESOURCES.CLIENT],
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
options: [
|
|
717
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of clients' },
|
|
718
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single client' },
|
|
719
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new client' },
|
|
720
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a client' },
|
|
721
|
+
],
|
|
722
|
+
default: OPERATIONS.LIST,
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
displayName: 'Client ID',
|
|
726
|
+
name: 'clientId',
|
|
727
|
+
type: 'string',
|
|
728
|
+
required: true,
|
|
729
|
+
displayOptions: {
|
|
730
|
+
show: {
|
|
731
|
+
resource: [RESOURCES.CLIENT],
|
|
732
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
733
|
+
},
|
|
734
|
+
},
|
|
735
|
+
default: '',
|
|
736
|
+
description: 'The ID of the client',
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
displayName: 'Name',
|
|
740
|
+
name: 'name',
|
|
741
|
+
type: 'string',
|
|
742
|
+
displayOptions: {
|
|
743
|
+
show: {
|
|
744
|
+
resource: [RESOURCES.CLIENT],
|
|
745
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
default: '',
|
|
749
|
+
description: 'Name of the client',
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
displayName: 'Code',
|
|
753
|
+
name: 'code',
|
|
754
|
+
type: 'string',
|
|
755
|
+
displayOptions: {
|
|
756
|
+
show: {
|
|
757
|
+
resource: [RESOURCES.CLIENT],
|
|
758
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
default: '',
|
|
762
|
+
description: 'Unique client code (uppercase alphanumeric)',
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
displayName: 'Industry',
|
|
766
|
+
name: 'industry',
|
|
767
|
+
type: 'string',
|
|
768
|
+
displayOptions: {
|
|
769
|
+
show: {
|
|
770
|
+
resource: [RESOURCES.CLIENT],
|
|
771
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
default: '',
|
|
775
|
+
description: 'Industry of the client',
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
displayName: 'Website',
|
|
779
|
+
name: 'website',
|
|
780
|
+
type: 'string',
|
|
781
|
+
displayOptions: {
|
|
782
|
+
show: {
|
|
783
|
+
resource: [RESOURCES.CLIENT],
|
|
784
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
default: '',
|
|
788
|
+
description: 'Website URL',
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
displayName: 'Type',
|
|
792
|
+
name: 'type',
|
|
793
|
+
type: 'options',
|
|
794
|
+
displayOptions: {
|
|
795
|
+
show: {
|
|
796
|
+
resource: [RESOURCES.CLIENT],
|
|
797
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
options: [
|
|
801
|
+
{ name: 'Corporate', value: 'corporate' },
|
|
802
|
+
{ name: 'Individual', value: 'individual' },
|
|
803
|
+
{ name: 'Partner', value: 'partner' },
|
|
804
|
+
],
|
|
805
|
+
default: 'corporate',
|
|
806
|
+
description: 'Type of client',
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
displayName: 'Status',
|
|
810
|
+
name: 'status',
|
|
811
|
+
type: 'options',
|
|
812
|
+
displayOptions: {
|
|
813
|
+
show: {
|
|
814
|
+
resource: [RESOURCES.CLIENT],
|
|
815
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
options: [
|
|
819
|
+
{ name: 'Active', value: 'active' },
|
|
820
|
+
{ name: 'Inactive', value: 'inactive' },
|
|
821
|
+
{ name: 'Prospect', value: 'prospect' },
|
|
822
|
+
],
|
|
823
|
+
default: 'active',
|
|
824
|
+
description: 'Status of the client',
|
|
825
|
+
},
|
|
826
|
+
// ==================== SOURCE ====================
|
|
827
|
+
{
|
|
828
|
+
displayName: 'Operation',
|
|
829
|
+
name: 'operation',
|
|
830
|
+
type: 'options',
|
|
831
|
+
noDataExpression: true,
|
|
832
|
+
displayOptions: {
|
|
833
|
+
show: {
|
|
834
|
+
resource: [RESOURCES.SOURCE],
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
options: [
|
|
838
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of sources' },
|
|
839
|
+
{ name: 'Get', value: OPERATIONS.GET, description: 'Get a single source' },
|
|
840
|
+
{ name: 'Create', value: OPERATIONS.CREATE, description: 'Create a new source' },
|
|
841
|
+
{ name: 'Update', value: OPERATIONS.UPDATE, description: 'Update a source' },
|
|
842
|
+
],
|
|
843
|
+
default: OPERATIONS.LIST,
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
displayName: 'Source ID',
|
|
847
|
+
name: 'sourceId',
|
|
848
|
+
type: 'string',
|
|
849
|
+
required: true,
|
|
850
|
+
displayOptions: {
|
|
851
|
+
show: {
|
|
852
|
+
resource: [RESOURCES.SOURCE],
|
|
853
|
+
operation: [OPERATIONS.GET, OPERATIONS.UPDATE],
|
|
854
|
+
},
|
|
855
|
+
},
|
|
856
|
+
default: '',
|
|
857
|
+
description: 'The ID of the source',
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
displayName: 'Key',
|
|
861
|
+
name: 'key',
|
|
862
|
+
type: 'string',
|
|
863
|
+
displayOptions: {
|
|
864
|
+
show: {
|
|
865
|
+
resource: [RESOURCES.SOURCE],
|
|
866
|
+
operation: [OPERATIONS.CREATE],
|
|
867
|
+
},
|
|
868
|
+
},
|
|
869
|
+
default: '',
|
|
870
|
+
description: 'Unique key for the source (lowercase alphanumeric with underscores)',
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
displayName: 'Label',
|
|
874
|
+
name: 'label',
|
|
875
|
+
type: 'string',
|
|
876
|
+
displayOptions: {
|
|
877
|
+
show: {
|
|
878
|
+
resource: [RESOURCES.SOURCE],
|
|
879
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
default: '',
|
|
883
|
+
description: 'Display label for the source',
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
displayName: 'Active',
|
|
887
|
+
name: 'active',
|
|
888
|
+
type: 'boolean',
|
|
889
|
+
displayOptions: {
|
|
890
|
+
show: {
|
|
891
|
+
resource: [RESOURCES.SOURCE],
|
|
892
|
+
operation: [OPERATIONS.CREATE, OPERATIONS.UPDATE],
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
default: true,
|
|
896
|
+
description: 'Whether the source is active',
|
|
897
|
+
},
|
|
898
|
+
// ==================== CONVERSATION TYPE ====================
|
|
899
|
+
{
|
|
900
|
+
displayName: 'Operation',
|
|
901
|
+
name: 'operation',
|
|
902
|
+
type: 'options',
|
|
903
|
+
noDataExpression: true,
|
|
904
|
+
displayOptions: {
|
|
905
|
+
show: {
|
|
906
|
+
resource: [RESOURCES.CONVERSATION_TYPE],
|
|
907
|
+
},
|
|
908
|
+
},
|
|
909
|
+
options: [
|
|
910
|
+
{ name: 'List', value: OPERATIONS.LIST, description: 'Get a list of conversation types' },
|
|
911
|
+
],
|
|
912
|
+
default: OPERATIONS.LIST,
|
|
913
|
+
},
|
|
914
|
+
],
|
|
915
|
+
};
|
|
916
|
+
methods = {
|
|
917
|
+
loadOptions: {
|
|
918
|
+
getTeams: getTeamOptions,
|
|
919
|
+
getProjects: getProjectOptions,
|
|
920
|
+
getClients: getClientOptions,
|
|
921
|
+
getSources: getSourceOptions,
|
|
922
|
+
getConversationTypes: getConversationTypeOptions,
|
|
923
|
+
},
|
|
924
|
+
};
|
|
925
|
+
async execute() {
|
|
926
|
+
const items = this.getInputData();
|
|
927
|
+
const returnData = [];
|
|
928
|
+
for (let i = 0; i < items.length; i++) {
|
|
929
|
+
const resource = this.getNodeParameter('resource', i);
|
|
930
|
+
const operation = this.getNodeParameter('operation', i);
|
|
931
|
+
let responseData;
|
|
932
|
+
try {
|
|
933
|
+
// ==================== CONVERSATION ====================
|
|
934
|
+
if (resource === RESOURCES.CONVERSATION) {
|
|
935
|
+
if (operation === OPERATIONS.LIST) {
|
|
936
|
+
const search = this.getNodeParameter('search', i, '');
|
|
937
|
+
const teamId = this.getNodeParameter('teamId', i, '');
|
|
938
|
+
const projectId = this.getNodeParameter('projectId', i, '');
|
|
939
|
+
const limit = this.getNodeParameter('limit', i, 100);
|
|
940
|
+
const offset = this.getNodeParameter('offset', i, 0);
|
|
941
|
+
const query = { limit, offset };
|
|
942
|
+
if (search)
|
|
943
|
+
query.q = search;
|
|
944
|
+
if (teamId)
|
|
945
|
+
query.team = teamId;
|
|
946
|
+
if (projectId)
|
|
947
|
+
query.project = projectId;
|
|
948
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/conversations', undefined, query);
|
|
949
|
+
}
|
|
950
|
+
else if (operation === OPERATIONS.GET) {
|
|
951
|
+
const conversationId = this.getNodeParameter('conversationId', i);
|
|
952
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/conversations/${conversationId}`);
|
|
953
|
+
}
|
|
954
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
955
|
+
const title = this.getNodeParameter('title', i);
|
|
956
|
+
const dateTime = this.getNodeParameter('dateTime', i);
|
|
957
|
+
const durationMinutes = this.getNodeParameter('durationMinutes', i, 0);
|
|
958
|
+
const transcript = this.getNodeParameter('transcript', i);
|
|
959
|
+
const sourceKey = this.getNodeParameter('sourceKey', i, '');
|
|
960
|
+
const conversationTypeKey = this.getNodeParameter('conversationTypeKey', i, 'meeting');
|
|
961
|
+
const teamId = this.getNodeParameter('teamId', i, '');
|
|
962
|
+
const projectId = this.getNodeParameter('projectId', i, '');
|
|
963
|
+
const clientId = this.getNodeParameter('clientId', i, '');
|
|
964
|
+
const description = this.getNodeParameter('description', i, '');
|
|
965
|
+
const participantsData = this.getNodeParameter('participants', i, {});
|
|
966
|
+
const body = {
|
|
967
|
+
title,
|
|
968
|
+
dateTime,
|
|
969
|
+
durationMinutes,
|
|
970
|
+
transcript,
|
|
971
|
+
sourceKey: sourceKey || 'api',
|
|
972
|
+
conversationTypeKey,
|
|
973
|
+
};
|
|
974
|
+
if (teamId)
|
|
975
|
+
body.team_id = teamId;
|
|
976
|
+
if (projectId)
|
|
977
|
+
body.project_id = projectId;
|
|
978
|
+
if (clientId)
|
|
979
|
+
body.client_id = clientId;
|
|
980
|
+
if (description)
|
|
981
|
+
body.description = description;
|
|
982
|
+
if (participantsData.participant) {
|
|
983
|
+
body.participants = participantsData.participant;
|
|
984
|
+
}
|
|
985
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/conversations', body);
|
|
986
|
+
}
|
|
987
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
988
|
+
const conversationId = this.getNodeParameter('conversationId', i);
|
|
989
|
+
const title = this.getNodeParameter('title', i, '');
|
|
990
|
+
const durationMinutes = this.getNodeParameter('durationMinutes', i, undefined);
|
|
991
|
+
const transcript = this.getNodeParameter('transcript', i, '');
|
|
992
|
+
const sourceKey = this.getNodeParameter('sourceKey', i, '');
|
|
993
|
+
const conversationTypeKey = this.getNodeParameter('conversationTypeKey', i, '');
|
|
994
|
+
const teamId = this.getNodeParameter('teamId', i, '');
|
|
995
|
+
const projectId = this.getNodeParameter('projectId', i, '');
|
|
996
|
+
const clientId = this.getNodeParameter('clientId', i, '');
|
|
997
|
+
const description = this.getNodeParameter('description', i, '');
|
|
998
|
+
const participantsData = this.getNodeParameter('participants', i, {});
|
|
999
|
+
const body = {};
|
|
1000
|
+
if (title)
|
|
1001
|
+
body.title = title;
|
|
1002
|
+
if (durationMinutes !== undefined)
|
|
1003
|
+
body.durationMinutes = durationMinutes;
|
|
1004
|
+
if (transcript)
|
|
1005
|
+
body.transcript = transcript;
|
|
1006
|
+
if (sourceKey)
|
|
1007
|
+
body.sourceKey = sourceKey;
|
|
1008
|
+
if (conversationTypeKey)
|
|
1009
|
+
body.conversationTypeKey = conversationTypeKey;
|
|
1010
|
+
if (teamId)
|
|
1011
|
+
body.team_id = teamId;
|
|
1012
|
+
if (projectId)
|
|
1013
|
+
body.project_id = projectId;
|
|
1014
|
+
if (clientId)
|
|
1015
|
+
body.client_id = clientId;
|
|
1016
|
+
if (description)
|
|
1017
|
+
body.description = description;
|
|
1018
|
+
if (participantsData.participant) {
|
|
1019
|
+
body.participants = participantsData.participant;
|
|
1020
|
+
}
|
|
1021
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/conversations/${conversationId}`, body);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
// ==================== CONTACT ====================
|
|
1025
|
+
else if (resource === RESOURCES.CONTACT) {
|
|
1026
|
+
if (operation === OPERATIONS.LIST) {
|
|
1027
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/contacts');
|
|
1028
|
+
}
|
|
1029
|
+
else if (operation === OPERATIONS.GET) {
|
|
1030
|
+
const contactId = this.getNodeParameter('contactId', i);
|
|
1031
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/contacts/${contactId}`);
|
|
1032
|
+
}
|
|
1033
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
1034
|
+
const firstName = this.getNodeParameter('firstName', i);
|
|
1035
|
+
const lastName = this.getNodeParameter('lastName', i);
|
|
1036
|
+
const email = this.getNodeParameter('email', i, '');
|
|
1037
|
+
const phone = this.getNodeParameter('phone', i, '');
|
|
1038
|
+
const company = this.getNodeParameter('company', i, '');
|
|
1039
|
+
const jobTitle = this.getNodeParameter('jobTitle', i, '');
|
|
1040
|
+
const body = { firstName, lastName };
|
|
1041
|
+
if (email)
|
|
1042
|
+
body.email = email;
|
|
1043
|
+
if (phone)
|
|
1044
|
+
body.phone = phone;
|
|
1045
|
+
if (company)
|
|
1046
|
+
body.company = company;
|
|
1047
|
+
if (jobTitle)
|
|
1048
|
+
body.job_title = jobTitle;
|
|
1049
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/contacts', body);
|
|
1050
|
+
}
|
|
1051
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
1052
|
+
const contactId = this.getNodeParameter('contactId', i);
|
|
1053
|
+
const firstName = this.getNodeParameter('firstName', i, '');
|
|
1054
|
+
const lastName = this.getNodeParameter('lastName', i, '');
|
|
1055
|
+
const email = this.getNodeParameter('email', i, '');
|
|
1056
|
+
const phone = this.getNodeParameter('phone', i, '');
|
|
1057
|
+
const company = this.getNodeParameter('company', i, '');
|
|
1058
|
+
const jobTitle = this.getNodeParameter('jobTitle', i, '');
|
|
1059
|
+
const body = {};
|
|
1060
|
+
if (firstName)
|
|
1061
|
+
body.firstName = firstName;
|
|
1062
|
+
if (lastName)
|
|
1063
|
+
body.lastName = lastName;
|
|
1064
|
+
if (email)
|
|
1065
|
+
body.email = email;
|
|
1066
|
+
if (phone)
|
|
1067
|
+
body.phone = phone;
|
|
1068
|
+
if (company)
|
|
1069
|
+
body.company = company;
|
|
1070
|
+
if (jobTitle)
|
|
1071
|
+
body.job_title = jobTitle;
|
|
1072
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
// ==================== TEAM ====================
|
|
1076
|
+
else if (resource === RESOURCES.TEAM) {
|
|
1077
|
+
if (operation === OPERATIONS.LIST) {
|
|
1078
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/teams');
|
|
1079
|
+
}
|
|
1080
|
+
else if (operation === OPERATIONS.GET) {
|
|
1081
|
+
const teamId = this.getNodeParameter('teamId', i);
|
|
1082
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/teams/${teamId}`);
|
|
1083
|
+
}
|
|
1084
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
1085
|
+
const name = this.getNodeParameter('name', i);
|
|
1086
|
+
const description = this.getNodeParameter('description', i, '');
|
|
1087
|
+
const color = this.getNodeParameter('color', i, '#3b82f6');
|
|
1088
|
+
const body = { name };
|
|
1089
|
+
if (description)
|
|
1090
|
+
body.description = description;
|
|
1091
|
+
if (color)
|
|
1092
|
+
body.color = color;
|
|
1093
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/teams', body);
|
|
1094
|
+
}
|
|
1095
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
1096
|
+
const teamId = this.getNodeParameter('teamId', i);
|
|
1097
|
+
const name = this.getNodeParameter('name', i, '');
|
|
1098
|
+
const description = this.getNodeParameter('description', i, '');
|
|
1099
|
+
const color = this.getNodeParameter('color', i, '');
|
|
1100
|
+
const body = {};
|
|
1101
|
+
if (name)
|
|
1102
|
+
body.name = name;
|
|
1103
|
+
if (description)
|
|
1104
|
+
body.description = description;
|
|
1105
|
+
if (color)
|
|
1106
|
+
body.color = color;
|
|
1107
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/teams/${teamId}`, body);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
// ==================== PROJECT ====================
|
|
1111
|
+
else if (resource === RESOURCES.PROJECT) {
|
|
1112
|
+
if (operation === OPERATIONS.LIST) {
|
|
1113
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/projects');
|
|
1114
|
+
}
|
|
1115
|
+
else if (operation === OPERATIONS.GET) {
|
|
1116
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
1117
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/projects/${projectId}`);
|
|
1118
|
+
}
|
|
1119
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
1120
|
+
const name = this.getNodeParameter('name', i);
|
|
1121
|
+
const description = this.getNodeParameter('description', i, '');
|
|
1122
|
+
const status = this.getNodeParameter('status', i, 'active');
|
|
1123
|
+
const body = { name };
|
|
1124
|
+
if (description)
|
|
1125
|
+
body.description = description;
|
|
1126
|
+
if (status)
|
|
1127
|
+
body.status = status;
|
|
1128
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/projects', body);
|
|
1129
|
+
}
|
|
1130
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
1131
|
+
const projectId = this.getNodeParameter('projectId', i);
|
|
1132
|
+
const name = this.getNodeParameter('name', i, '');
|
|
1133
|
+
const description = this.getNodeParameter('description', i, '');
|
|
1134
|
+
const status = this.getNodeParameter('status', i, '');
|
|
1135
|
+
const body = {};
|
|
1136
|
+
if (name)
|
|
1137
|
+
body.name = name;
|
|
1138
|
+
if (description)
|
|
1139
|
+
body.description = description;
|
|
1140
|
+
if (status)
|
|
1141
|
+
body.status = status;
|
|
1142
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/projects/${projectId}`, body);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
// ==================== CLIENT ====================
|
|
1146
|
+
else if (resource === RESOURCES.CLIENT) {
|
|
1147
|
+
if (operation === OPERATIONS.LIST) {
|
|
1148
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/clients');
|
|
1149
|
+
}
|
|
1150
|
+
else if (operation === OPERATIONS.GET) {
|
|
1151
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
1152
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/clients/${clientId}`);
|
|
1153
|
+
}
|
|
1154
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
1155
|
+
const name = this.getNodeParameter('name', i);
|
|
1156
|
+
const code = this.getNodeParameter('code', i, '');
|
|
1157
|
+
const industry = this.getNodeParameter('industry', i, '');
|
|
1158
|
+
const website = this.getNodeParameter('website', i, '');
|
|
1159
|
+
const type = this.getNodeParameter('type', i, 'corporate');
|
|
1160
|
+
const status = this.getNodeParameter('status', i, 'active');
|
|
1161
|
+
const body = { name };
|
|
1162
|
+
if (code)
|
|
1163
|
+
body.code = code;
|
|
1164
|
+
if (industry)
|
|
1165
|
+
body.industry = industry;
|
|
1166
|
+
if (website)
|
|
1167
|
+
body.website = website;
|
|
1168
|
+
if (type)
|
|
1169
|
+
body.type = type;
|
|
1170
|
+
if (status)
|
|
1171
|
+
body.status = status;
|
|
1172
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/clients', body);
|
|
1173
|
+
}
|
|
1174
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
1175
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
1176
|
+
const name = this.getNodeParameter('name', i, '');
|
|
1177
|
+
const code = this.getNodeParameter('code', i, '');
|
|
1178
|
+
const industry = this.getNodeParameter('industry', i, '');
|
|
1179
|
+
const website = this.getNodeParameter('website', i, '');
|
|
1180
|
+
const type = this.getNodeParameter('type', i, '');
|
|
1181
|
+
const status = this.getNodeParameter('status', i, '');
|
|
1182
|
+
const body = {};
|
|
1183
|
+
if (name)
|
|
1184
|
+
body.name = name;
|
|
1185
|
+
if (code)
|
|
1186
|
+
body.code = code;
|
|
1187
|
+
if (industry)
|
|
1188
|
+
body.industry = industry;
|
|
1189
|
+
if (website)
|
|
1190
|
+
body.website = website;
|
|
1191
|
+
if (type)
|
|
1192
|
+
body.type = type;
|
|
1193
|
+
if (status)
|
|
1194
|
+
body.status = status;
|
|
1195
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/clients/${clientId}`, body);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
// ==================== SOURCE ====================
|
|
1199
|
+
else if (resource === RESOURCES.SOURCE) {
|
|
1200
|
+
if (operation === OPERATIONS.LIST) {
|
|
1201
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/sources');
|
|
1202
|
+
}
|
|
1203
|
+
else if (operation === OPERATIONS.GET) {
|
|
1204
|
+
const sourceId = this.getNodeParameter('sourceId', i);
|
|
1205
|
+
responseData = await tukiMateRequest.call(this, 'GET', `/sources/${sourceId}`);
|
|
1206
|
+
}
|
|
1207
|
+
else if (operation === OPERATIONS.CREATE) {
|
|
1208
|
+
const key = this.getNodeParameter('key', i);
|
|
1209
|
+
const label = this.getNodeParameter('label', i);
|
|
1210
|
+
const active = this.getNodeParameter('active', i, true);
|
|
1211
|
+
const body = { key, label, active };
|
|
1212
|
+
responseData = await tukiMateRequest.call(this, 'POST', '/sources', body);
|
|
1213
|
+
}
|
|
1214
|
+
else if (operation === OPERATIONS.UPDATE) {
|
|
1215
|
+
const sourceId = this.getNodeParameter('sourceId', i);
|
|
1216
|
+
const label = this.getNodeParameter('label', i, '');
|
|
1217
|
+
const active = this.getNodeParameter('active', i, undefined);
|
|
1218
|
+
const body = {};
|
|
1219
|
+
if (label)
|
|
1220
|
+
body.label = label;
|
|
1221
|
+
if (active !== undefined)
|
|
1222
|
+
body.active = active;
|
|
1223
|
+
responseData = await tukiMateRequest.call(this, 'PUT', `/sources/${sourceId}`, body);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
// ==================== CONVERSATION TYPE ====================
|
|
1227
|
+
else if (resource === RESOURCES.CONVERSATION_TYPE) {
|
|
1228
|
+
if (operation === OPERATIONS.LIST) {
|
|
1229
|
+
responseData = await tukiMateRequest.call(this, 'GET', '/conversation-types');
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
// Handle response data
|
|
1233
|
+
if (Array.isArray(responseData)) {
|
|
1234
|
+
returnData.push(...responseData.map((item) => ({ json: item })));
|
|
1235
|
+
}
|
|
1236
|
+
else if (responseData) {
|
|
1237
|
+
returnData.push({ json: responseData });
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
catch (error) {
|
|
1241
|
+
if (this.continueOnFail()) {
|
|
1242
|
+
returnData.push({ json: { error: error.message } });
|
|
1243
|
+
continue;
|
|
1244
|
+
}
|
|
1245
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error.message, { itemIndex: i });
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return [returnData];
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
exports.TukiMate = TukiMate;
|