n8n-nodes-typebot 1.0.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/LICENSE.md +21 -0
- package/README.md +220 -0
- package/dist/credentials/TypebotApi.credentials.d.ts +9 -0
- package/dist/credentials/TypebotApi.credentials.js +47 -0
- package/dist/nodes/Typebot/Typebot.node.d.ts +5 -0
- package/dist/nodes/Typebot/Typebot.node.js +1115 -0
- package/dist/nodes/Typebot/typebot.svg +9 -0
- package/index.js +2 -0
- package/package.json +51 -0
|
@@ -0,0 +1,1115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Typebot = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
class Typebot {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.description = {
|
|
8
|
+
displayName: 'Typebot',
|
|
9
|
+
name: 'typebot',
|
|
10
|
+
icon: 'file:typebot.svg',
|
|
11
|
+
group: ['transform'],
|
|
12
|
+
version: 1,
|
|
13
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
14
|
+
description: 'Interact with Typebot API',
|
|
15
|
+
defaults: {
|
|
16
|
+
name: 'Typebot',
|
|
17
|
+
},
|
|
18
|
+
inputs: ['main'],
|
|
19
|
+
outputs: ['main'],
|
|
20
|
+
credentials: [
|
|
21
|
+
{
|
|
22
|
+
name: 'typebotApi',
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
properties: [
|
|
27
|
+
// Resource
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Resource',
|
|
30
|
+
name: 'resource',
|
|
31
|
+
type: 'options',
|
|
32
|
+
noDataExpression: true,
|
|
33
|
+
options: [
|
|
34
|
+
{
|
|
35
|
+
name: 'Chat',
|
|
36
|
+
value: 'chat',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Typebot',
|
|
40
|
+
value: 'typebot',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Result',
|
|
44
|
+
value: 'result',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Workspace',
|
|
48
|
+
value: 'workspace',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'Folder',
|
|
52
|
+
value: 'folder',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
default: 'chat',
|
|
56
|
+
},
|
|
57
|
+
// =====================================
|
|
58
|
+
// Chat Operations
|
|
59
|
+
// =====================================
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Operation',
|
|
62
|
+
name: 'operation',
|
|
63
|
+
type: 'options',
|
|
64
|
+
noDataExpression: true,
|
|
65
|
+
displayOptions: {
|
|
66
|
+
show: {
|
|
67
|
+
resource: ['chat'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
name: 'Start Chat',
|
|
73
|
+
value: 'startChat',
|
|
74
|
+
description: 'Start a new chat session',
|
|
75
|
+
action: 'Start a chat session',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Continue Chat',
|
|
79
|
+
value: 'continueChat',
|
|
80
|
+
description: 'Continue an existing chat session',
|
|
81
|
+
action: 'Continue a chat session',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'Start Preview Chat',
|
|
85
|
+
value: 'startPreviewChat',
|
|
86
|
+
description: 'Start a preview chat session',
|
|
87
|
+
action: 'Start a preview chat session',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
default: 'startChat',
|
|
91
|
+
},
|
|
92
|
+
// Start Chat fields
|
|
93
|
+
{
|
|
94
|
+
displayName: 'Public ID',
|
|
95
|
+
name: 'publicId',
|
|
96
|
+
type: 'string',
|
|
97
|
+
required: true,
|
|
98
|
+
displayOptions: {
|
|
99
|
+
show: {
|
|
100
|
+
resource: ['chat'],
|
|
101
|
+
operation: ['startChat'],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
default: '',
|
|
105
|
+
description: 'The public ID of your typebot',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
displayName: 'Additional Fields',
|
|
109
|
+
name: 'additionalFields',
|
|
110
|
+
type: 'collection',
|
|
111
|
+
placeholder: 'Add Field',
|
|
112
|
+
default: {},
|
|
113
|
+
displayOptions: {
|
|
114
|
+
show: {
|
|
115
|
+
resource: ['chat'],
|
|
116
|
+
operation: ['startChat'],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
displayName: 'Message',
|
|
122
|
+
name: 'message',
|
|
123
|
+
type: 'string',
|
|
124
|
+
default: '',
|
|
125
|
+
description: 'Message to send with the chat start',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
displayName: 'Result ID',
|
|
129
|
+
name: 'resultId',
|
|
130
|
+
type: 'string',
|
|
131
|
+
default: '',
|
|
132
|
+
description: 'Result ID to overwrite an existing result',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
displayName: 'Is Stream Enabled',
|
|
136
|
+
name: 'isStreamEnabled',
|
|
137
|
+
type: 'boolean',
|
|
138
|
+
default: false,
|
|
139
|
+
description: 'Whether to enable streaming for OpenAI blocks',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
displayName: 'Is Only Registering',
|
|
143
|
+
name: 'isOnlyRegistering',
|
|
144
|
+
type: 'boolean',
|
|
145
|
+
default: false,
|
|
146
|
+
description: 'Whether to only register the session without starting the bot',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
displayName: 'Prefilled Variables',
|
|
150
|
+
name: 'prefilledVariables',
|
|
151
|
+
type: 'json',
|
|
152
|
+
default: '{}',
|
|
153
|
+
description: 'Prefilled variables as JSON object',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
displayName: 'Text Bubble Content Format',
|
|
157
|
+
name: 'textBubbleContentFormat',
|
|
158
|
+
type: 'options',
|
|
159
|
+
options: [
|
|
160
|
+
{
|
|
161
|
+
name: 'Rich Text',
|
|
162
|
+
value: 'richText',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'Markdown',
|
|
166
|
+
value: 'markdown',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
default: 'richText',
|
|
170
|
+
description: 'Format for text bubble content',
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
// Continue Chat fields
|
|
175
|
+
{
|
|
176
|
+
displayName: 'Session ID',
|
|
177
|
+
name: 'sessionId',
|
|
178
|
+
type: 'string',
|
|
179
|
+
required: true,
|
|
180
|
+
displayOptions: {
|
|
181
|
+
show: {
|
|
182
|
+
resource: ['chat'],
|
|
183
|
+
operation: ['continueChat'],
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
default: '',
|
|
187
|
+
description: 'The session ID from a previous chat start',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
displayName: 'Message',
|
|
191
|
+
name: 'message',
|
|
192
|
+
type: 'string',
|
|
193
|
+
displayOptions: {
|
|
194
|
+
show: {
|
|
195
|
+
resource: ['chat'],
|
|
196
|
+
operation: ['continueChat'],
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
default: '',
|
|
200
|
+
description: 'The message to send',
|
|
201
|
+
},
|
|
202
|
+
// Start Preview Chat fields
|
|
203
|
+
{
|
|
204
|
+
displayName: 'Typebot ID',
|
|
205
|
+
name: 'typebotId',
|
|
206
|
+
type: 'string',
|
|
207
|
+
required: true,
|
|
208
|
+
displayOptions: {
|
|
209
|
+
show: {
|
|
210
|
+
resource: ['chat'],
|
|
211
|
+
operation: ['startPreviewChat'],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
default: '',
|
|
215
|
+
description: 'The ID of your typebot',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
displayName: 'Additional Fields',
|
|
219
|
+
name: 'additionalFields',
|
|
220
|
+
type: 'collection',
|
|
221
|
+
placeholder: 'Add Field',
|
|
222
|
+
default: {},
|
|
223
|
+
displayOptions: {
|
|
224
|
+
show: {
|
|
225
|
+
resource: ['chat'],
|
|
226
|
+
operation: ['startPreviewChat'],
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
options: [
|
|
230
|
+
{
|
|
231
|
+
displayName: 'Message',
|
|
232
|
+
name: 'message',
|
|
233
|
+
type: 'string',
|
|
234
|
+
default: '',
|
|
235
|
+
description: 'Message to send with the preview chat start',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
displayName: 'Is Stream Enabled',
|
|
239
|
+
name: 'isStreamEnabled',
|
|
240
|
+
type: 'boolean',
|
|
241
|
+
default: false,
|
|
242
|
+
description: 'Whether to enable streaming',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
displayName: 'Prefilled Variables',
|
|
246
|
+
name: 'prefilledVariables',
|
|
247
|
+
type: 'json',
|
|
248
|
+
default: '{}',
|
|
249
|
+
description: 'Prefilled variables as JSON object',
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
// =====================================
|
|
254
|
+
// Typebot Operations
|
|
255
|
+
// =====================================
|
|
256
|
+
{
|
|
257
|
+
displayName: 'Operation',
|
|
258
|
+
name: 'operation',
|
|
259
|
+
type: 'options',
|
|
260
|
+
noDataExpression: true,
|
|
261
|
+
displayOptions: {
|
|
262
|
+
show: {
|
|
263
|
+
resource: ['typebot'],
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
options: [
|
|
267
|
+
{
|
|
268
|
+
name: 'List',
|
|
269
|
+
value: 'list',
|
|
270
|
+
description: 'List all typebots',
|
|
271
|
+
action: 'List all typebots',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: 'Get',
|
|
275
|
+
value: 'get',
|
|
276
|
+
description: 'Get a typebot',
|
|
277
|
+
action: 'Get a typebot',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'Create',
|
|
281
|
+
value: 'create',
|
|
282
|
+
description: 'Create a typebot',
|
|
283
|
+
action: 'Create a typebot',
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: 'Update',
|
|
287
|
+
value: 'update',
|
|
288
|
+
description: 'Update a typebot',
|
|
289
|
+
action: 'Update a typebot',
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: 'Delete',
|
|
293
|
+
value: 'delete',
|
|
294
|
+
description: 'Delete a typebot',
|
|
295
|
+
action: 'Delete a typebot',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'Publish',
|
|
299
|
+
value: 'publish',
|
|
300
|
+
description: 'Publish a typebot',
|
|
301
|
+
action: 'Publish a typebot',
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
name: 'Unpublish',
|
|
305
|
+
value: 'unpublish',
|
|
306
|
+
description: 'Unpublish a typebot',
|
|
307
|
+
action: 'Unpublish a typebot',
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'Get Published',
|
|
311
|
+
value: 'getPublished',
|
|
312
|
+
description: 'Get published typebot',
|
|
313
|
+
action: 'Get published typebot',
|
|
314
|
+
},
|
|
315
|
+
],
|
|
316
|
+
default: 'list',
|
|
317
|
+
},
|
|
318
|
+
// List Typebots fields
|
|
319
|
+
{
|
|
320
|
+
displayName: 'Additional Fields',
|
|
321
|
+
name: 'additionalFields',
|
|
322
|
+
type: 'collection',
|
|
323
|
+
placeholder: 'Add Field',
|
|
324
|
+
default: {},
|
|
325
|
+
displayOptions: {
|
|
326
|
+
show: {
|
|
327
|
+
resource: ['typebot'],
|
|
328
|
+
operation: ['list'],
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
options: [
|
|
332
|
+
{
|
|
333
|
+
displayName: 'Workspace ID',
|
|
334
|
+
name: 'workspaceId',
|
|
335
|
+
type: 'string',
|
|
336
|
+
default: '',
|
|
337
|
+
description: 'Filter by workspace ID',
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
displayName: 'Folder ID',
|
|
341
|
+
name: 'folderId',
|
|
342
|
+
type: 'string',
|
|
343
|
+
default: '',
|
|
344
|
+
description: 'Filter by folder ID',
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
},
|
|
348
|
+
// Get/Update/Delete/Publish/Unpublish Typebot fields
|
|
349
|
+
{
|
|
350
|
+
displayName: 'Typebot ID',
|
|
351
|
+
name: 'typebotId',
|
|
352
|
+
type: 'string',
|
|
353
|
+
required: true,
|
|
354
|
+
displayOptions: {
|
|
355
|
+
show: {
|
|
356
|
+
resource: ['typebot'],
|
|
357
|
+
operation: ['get', 'update', 'delete', 'publish', 'unpublish'],
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
default: '',
|
|
361
|
+
description: 'The ID of the typebot',
|
|
362
|
+
},
|
|
363
|
+
// Get Typebot additional fields
|
|
364
|
+
{
|
|
365
|
+
displayName: 'Migrate to Latest Version',
|
|
366
|
+
name: 'migrateToLatestVersion',
|
|
367
|
+
type: 'boolean',
|
|
368
|
+
displayOptions: {
|
|
369
|
+
show: {
|
|
370
|
+
resource: ['typebot'],
|
|
371
|
+
operation: ['get'],
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
default: false,
|
|
375
|
+
description: 'Whether to migrate the typebot to the latest version',
|
|
376
|
+
},
|
|
377
|
+
// Get Published Typebot field
|
|
378
|
+
{
|
|
379
|
+
displayName: 'Public ID',
|
|
380
|
+
name: 'publicId',
|
|
381
|
+
type: 'string',
|
|
382
|
+
required: true,
|
|
383
|
+
displayOptions: {
|
|
384
|
+
show: {
|
|
385
|
+
resource: ['typebot'],
|
|
386
|
+
operation: ['getPublished'],
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
default: '',
|
|
390
|
+
description: 'The public ID of the typebot',
|
|
391
|
+
},
|
|
392
|
+
// Create Typebot fields
|
|
393
|
+
{
|
|
394
|
+
displayName: 'Workspace ID',
|
|
395
|
+
name: 'workspaceId',
|
|
396
|
+
type: 'string',
|
|
397
|
+
required: true,
|
|
398
|
+
displayOptions: {
|
|
399
|
+
show: {
|
|
400
|
+
resource: ['typebot'],
|
|
401
|
+
operation: ['create'],
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
default: '',
|
|
405
|
+
description: 'The workspace ID where the typebot will be created',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
displayName: 'Typebot Data',
|
|
409
|
+
name: 'typebotData',
|
|
410
|
+
type: 'json',
|
|
411
|
+
required: true,
|
|
412
|
+
displayOptions: {
|
|
413
|
+
show: {
|
|
414
|
+
resource: ['typebot'],
|
|
415
|
+
operation: ['create'],
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
default: '{\n "name": "My Typebot"\n}',
|
|
419
|
+
description: 'The typebot configuration as JSON',
|
|
420
|
+
},
|
|
421
|
+
// Update Typebot fields
|
|
422
|
+
{
|
|
423
|
+
displayName: 'Update Data',
|
|
424
|
+
name: 'updateData',
|
|
425
|
+
type: 'json',
|
|
426
|
+
required: true,
|
|
427
|
+
displayOptions: {
|
|
428
|
+
show: {
|
|
429
|
+
resource: ['typebot'],
|
|
430
|
+
operation: ['update'],
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
default: '{}',
|
|
434
|
+
description: 'The data to update as JSON',
|
|
435
|
+
},
|
|
436
|
+
// =====================================
|
|
437
|
+
// Result Operations
|
|
438
|
+
// =====================================
|
|
439
|
+
{
|
|
440
|
+
displayName: 'Operation',
|
|
441
|
+
name: 'operation',
|
|
442
|
+
type: 'options',
|
|
443
|
+
noDataExpression: true,
|
|
444
|
+
displayOptions: {
|
|
445
|
+
show: {
|
|
446
|
+
resource: ['result'],
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
options: [
|
|
450
|
+
{
|
|
451
|
+
name: 'List',
|
|
452
|
+
value: 'list',
|
|
453
|
+
description: 'List all results',
|
|
454
|
+
action: 'List all results',
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: 'Get',
|
|
458
|
+
value: 'get',
|
|
459
|
+
description: 'Get a result',
|
|
460
|
+
action: 'Get a result',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: 'Delete',
|
|
464
|
+
value: 'delete',
|
|
465
|
+
description: 'Delete results',
|
|
466
|
+
action: 'Delete results',
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
name: 'Get Stats',
|
|
470
|
+
value: 'getStats',
|
|
471
|
+
description: 'Get statistics',
|
|
472
|
+
action: 'Get statistics',
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
default: 'list',
|
|
476
|
+
},
|
|
477
|
+
// List/Delete Results fields
|
|
478
|
+
{
|
|
479
|
+
displayName: 'Typebot ID',
|
|
480
|
+
name: 'typebotId',
|
|
481
|
+
type: 'string',
|
|
482
|
+
required: true,
|
|
483
|
+
displayOptions: {
|
|
484
|
+
show: {
|
|
485
|
+
resource: ['result'],
|
|
486
|
+
operation: ['list', 'delete', 'getStats'],
|
|
487
|
+
},
|
|
488
|
+
},
|
|
489
|
+
default: '',
|
|
490
|
+
description: 'The ID of the typebot',
|
|
491
|
+
},
|
|
492
|
+
// Get Result fields
|
|
493
|
+
{
|
|
494
|
+
displayName: 'Typebot ID',
|
|
495
|
+
name: 'typebotId',
|
|
496
|
+
type: 'string',
|
|
497
|
+
required: true,
|
|
498
|
+
displayOptions: {
|
|
499
|
+
show: {
|
|
500
|
+
resource: ['result'],
|
|
501
|
+
operation: ['get'],
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
default: '',
|
|
505
|
+
description: 'The ID of the typebot',
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
displayName: 'Result ID',
|
|
509
|
+
name: 'resultId',
|
|
510
|
+
type: 'string',
|
|
511
|
+
required: true,
|
|
512
|
+
displayOptions: {
|
|
513
|
+
show: {
|
|
514
|
+
resource: ['result'],
|
|
515
|
+
operation: ['get'],
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
default: '',
|
|
519
|
+
description: 'The ID of the result',
|
|
520
|
+
},
|
|
521
|
+
// Delete Results fields
|
|
522
|
+
{
|
|
523
|
+
displayName: 'Result IDs',
|
|
524
|
+
name: 'resultIds',
|
|
525
|
+
type: 'string',
|
|
526
|
+
displayOptions: {
|
|
527
|
+
show: {
|
|
528
|
+
resource: ['result'],
|
|
529
|
+
operation: ['delete'],
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
default: '',
|
|
533
|
+
description: 'Comma-separated list of result IDs to delete',
|
|
534
|
+
},
|
|
535
|
+
// =====================================
|
|
536
|
+
// Workspace Operations
|
|
537
|
+
// =====================================
|
|
538
|
+
{
|
|
539
|
+
displayName: 'Operation',
|
|
540
|
+
name: 'operation',
|
|
541
|
+
type: 'options',
|
|
542
|
+
noDataExpression: true,
|
|
543
|
+
displayOptions: {
|
|
544
|
+
show: {
|
|
545
|
+
resource: ['workspace'],
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
options: [
|
|
549
|
+
{
|
|
550
|
+
name: 'List',
|
|
551
|
+
value: 'list',
|
|
552
|
+
description: 'List all workspaces',
|
|
553
|
+
action: 'List all workspaces',
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
name: 'Get',
|
|
557
|
+
value: 'get',
|
|
558
|
+
description: 'Get a workspace',
|
|
559
|
+
action: 'Get a workspace',
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
name: 'Create',
|
|
563
|
+
value: 'create',
|
|
564
|
+
description: 'Create a workspace',
|
|
565
|
+
action: 'Create a workspace',
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: 'Update',
|
|
569
|
+
value: 'update',
|
|
570
|
+
description: 'Update a workspace',
|
|
571
|
+
action: 'Update a workspace',
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: 'Delete',
|
|
575
|
+
value: 'delete',
|
|
576
|
+
description: 'Delete a workspace',
|
|
577
|
+
action: 'Delete a workspace',
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
name: 'List Members',
|
|
581
|
+
value: 'listMembers',
|
|
582
|
+
description: 'List workspace members',
|
|
583
|
+
action: 'List workspace members',
|
|
584
|
+
},
|
|
585
|
+
],
|
|
586
|
+
default: 'list',
|
|
587
|
+
},
|
|
588
|
+
// Workspace ID field
|
|
589
|
+
{
|
|
590
|
+
displayName: 'Workspace ID',
|
|
591
|
+
name: 'workspaceId',
|
|
592
|
+
type: 'string',
|
|
593
|
+
required: true,
|
|
594
|
+
displayOptions: {
|
|
595
|
+
show: {
|
|
596
|
+
resource: ['workspace'],
|
|
597
|
+
operation: ['get', 'update', 'delete', 'listMembers'],
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
default: '',
|
|
601
|
+
description: 'The ID of the workspace',
|
|
602
|
+
},
|
|
603
|
+
// Create Workspace fields
|
|
604
|
+
{
|
|
605
|
+
displayName: 'Name',
|
|
606
|
+
name: 'name',
|
|
607
|
+
type: 'string',
|
|
608
|
+
required: true,
|
|
609
|
+
displayOptions: {
|
|
610
|
+
show: {
|
|
611
|
+
resource: ['workspace'],
|
|
612
|
+
operation: ['create'],
|
|
613
|
+
},
|
|
614
|
+
},
|
|
615
|
+
default: '',
|
|
616
|
+
description: 'The name of the workspace',
|
|
617
|
+
},
|
|
618
|
+
// Update Workspace fields
|
|
619
|
+
{
|
|
620
|
+
displayName: 'Update Data',
|
|
621
|
+
name: 'updateData',
|
|
622
|
+
type: 'json',
|
|
623
|
+
required: true,
|
|
624
|
+
displayOptions: {
|
|
625
|
+
show: {
|
|
626
|
+
resource: ['workspace'],
|
|
627
|
+
operation: ['update'],
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
default: '{}',
|
|
631
|
+
description: 'The data to update as JSON',
|
|
632
|
+
},
|
|
633
|
+
// =====================================
|
|
634
|
+
// Folder Operations
|
|
635
|
+
// =====================================
|
|
636
|
+
{
|
|
637
|
+
displayName: 'Operation',
|
|
638
|
+
name: 'operation',
|
|
639
|
+
type: 'options',
|
|
640
|
+
noDataExpression: true,
|
|
641
|
+
displayOptions: {
|
|
642
|
+
show: {
|
|
643
|
+
resource: ['folder'],
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
options: [
|
|
647
|
+
{
|
|
648
|
+
name: 'List',
|
|
649
|
+
value: 'list',
|
|
650
|
+
description: 'List all folders',
|
|
651
|
+
action: 'List all folders',
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: 'Create',
|
|
655
|
+
value: 'create',
|
|
656
|
+
description: 'Create a folder',
|
|
657
|
+
action: 'Create a folder',
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: 'Update',
|
|
661
|
+
value: 'update',
|
|
662
|
+
description: 'Update a folder',
|
|
663
|
+
action: 'Update a folder',
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
name: 'Delete',
|
|
667
|
+
value: 'delete',
|
|
668
|
+
description: 'Delete a folder',
|
|
669
|
+
action: 'Delete a folder',
|
|
670
|
+
},
|
|
671
|
+
],
|
|
672
|
+
default: 'list',
|
|
673
|
+
},
|
|
674
|
+
// List Folders field
|
|
675
|
+
{
|
|
676
|
+
displayName: 'Workspace ID',
|
|
677
|
+
name: 'workspaceId',
|
|
678
|
+
type: 'string',
|
|
679
|
+
required: true,
|
|
680
|
+
displayOptions: {
|
|
681
|
+
show: {
|
|
682
|
+
resource: ['folder'],
|
|
683
|
+
operation: ['list'],
|
|
684
|
+
},
|
|
685
|
+
},
|
|
686
|
+
default: '',
|
|
687
|
+
description: 'The ID of the workspace',
|
|
688
|
+
},
|
|
689
|
+
// Create Folder fields
|
|
690
|
+
{
|
|
691
|
+
displayName: 'Workspace ID',
|
|
692
|
+
name: 'workspaceId',
|
|
693
|
+
type: 'string',
|
|
694
|
+
required: true,
|
|
695
|
+
displayOptions: {
|
|
696
|
+
show: {
|
|
697
|
+
resource: ['folder'],
|
|
698
|
+
operation: ['create'],
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
default: '',
|
|
702
|
+
description: 'The ID of the workspace',
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
displayName: 'Folder Data',
|
|
706
|
+
name: 'folderData',
|
|
707
|
+
type: 'json',
|
|
708
|
+
required: true,
|
|
709
|
+
displayOptions: {
|
|
710
|
+
show: {
|
|
711
|
+
resource: ['folder'],
|
|
712
|
+
operation: ['create'],
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
default: '{\n "name": "My Folder"\n}',
|
|
716
|
+
description: 'The folder data as JSON',
|
|
717
|
+
},
|
|
718
|
+
// Update Folder fields
|
|
719
|
+
{
|
|
720
|
+
displayName: 'Folder ID',
|
|
721
|
+
name: 'folderId',
|
|
722
|
+
type: 'string',
|
|
723
|
+
required: true,
|
|
724
|
+
displayOptions: {
|
|
725
|
+
show: {
|
|
726
|
+
resource: ['folder'],
|
|
727
|
+
operation: ['update', 'delete'],
|
|
728
|
+
},
|
|
729
|
+
},
|
|
730
|
+
default: '',
|
|
731
|
+
description: 'The ID of the folder',
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
displayName: 'Update Data',
|
|
735
|
+
name: 'updateData',
|
|
736
|
+
type: 'json',
|
|
737
|
+
required: true,
|
|
738
|
+
displayOptions: {
|
|
739
|
+
show: {
|
|
740
|
+
resource: ['folder'],
|
|
741
|
+
operation: ['update'],
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
default: '{}',
|
|
745
|
+
description: 'The data to update as JSON',
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
async execute() {
|
|
751
|
+
const items = this.getInputData();
|
|
752
|
+
const returnData = [];
|
|
753
|
+
const credentials = await this.getCredentials('typebotApi');
|
|
754
|
+
const baseUrl = credentials.baseUrl;
|
|
755
|
+
for (let i = 0; i < items.length; i++) {
|
|
756
|
+
try {
|
|
757
|
+
const resource = this.getNodeParameter('resource', i);
|
|
758
|
+
const operation = this.getNodeParameter('operation', i);
|
|
759
|
+
let responseData;
|
|
760
|
+
// =====================================
|
|
761
|
+
// Chat Operations
|
|
762
|
+
// =====================================
|
|
763
|
+
if (resource === 'chat') {
|
|
764
|
+
if (operation === 'startChat') {
|
|
765
|
+
const publicId = this.getNodeParameter('publicId', i);
|
|
766
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
767
|
+
const body = {};
|
|
768
|
+
if (additionalFields.message) {
|
|
769
|
+
body.message = additionalFields.message;
|
|
770
|
+
}
|
|
771
|
+
if (additionalFields.resultId) {
|
|
772
|
+
body.resultId = additionalFields.resultId;
|
|
773
|
+
}
|
|
774
|
+
if (additionalFields.isStreamEnabled !== undefined) {
|
|
775
|
+
body.isStreamEnabled = additionalFields.isStreamEnabled;
|
|
776
|
+
}
|
|
777
|
+
if (additionalFields.isOnlyRegistering !== undefined) {
|
|
778
|
+
body.isOnlyRegistering = additionalFields.isOnlyRegistering;
|
|
779
|
+
}
|
|
780
|
+
if (additionalFields.prefilledVariables) {
|
|
781
|
+
try {
|
|
782
|
+
body.prefilledVariables = JSON.parse(additionalFields.prefilledVariables);
|
|
783
|
+
}
|
|
784
|
+
catch (error) {
|
|
785
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Prefilled Variables must be valid JSON');
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (additionalFields.textBubbleContentFormat) {
|
|
789
|
+
body.textBubbleContentFormat = additionalFields.textBubbleContentFormat;
|
|
790
|
+
}
|
|
791
|
+
responseData = await this.helpers.request({
|
|
792
|
+
method: 'POST',
|
|
793
|
+
url: `https://typebot.io/api/v1/typebots/${publicId}/startChat`,
|
|
794
|
+
body,
|
|
795
|
+
json: true,
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
else if (operation === 'continueChat') {
|
|
799
|
+
const sessionId = this.getNodeParameter('sessionId', i);
|
|
800
|
+
const message = this.getNodeParameter('message', i);
|
|
801
|
+
responseData = await this.helpers.request({
|
|
802
|
+
method: 'POST',
|
|
803
|
+
url: `https://typebot.io/api/v1/sessions/${sessionId}/continueChat`,
|
|
804
|
+
body: { message },
|
|
805
|
+
json: true,
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
else if (operation === 'startPreviewChat') {
|
|
809
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
810
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
811
|
+
const body = {};
|
|
812
|
+
if (additionalFields.message) {
|
|
813
|
+
body.message = additionalFields.message;
|
|
814
|
+
}
|
|
815
|
+
if (additionalFields.isStreamEnabled !== undefined) {
|
|
816
|
+
body.isStreamEnabled = additionalFields.isStreamEnabled;
|
|
817
|
+
}
|
|
818
|
+
if (additionalFields.prefilledVariables) {
|
|
819
|
+
try {
|
|
820
|
+
body.prefilledVariables = JSON.parse(additionalFields.prefilledVariables);
|
|
821
|
+
}
|
|
822
|
+
catch (error) {
|
|
823
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Prefilled Variables must be valid JSON');
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
responseData = await this.helpers.request({
|
|
827
|
+
method: 'POST',
|
|
828
|
+
url: `https://typebot.io/api/v1/typebots/${typebotId}/preview/startChat`,
|
|
829
|
+
body,
|
|
830
|
+
json: true,
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
// =====================================
|
|
835
|
+
// Typebot Operations
|
|
836
|
+
// =====================================
|
|
837
|
+
else if (resource === 'typebot') {
|
|
838
|
+
if (operation === 'list') {
|
|
839
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
840
|
+
const qs = {};
|
|
841
|
+
if (additionalFields.workspaceId) {
|
|
842
|
+
qs.workspaceId = additionalFields.workspaceId;
|
|
843
|
+
}
|
|
844
|
+
if (additionalFields.folderId) {
|
|
845
|
+
qs.folderId = additionalFields.folderId;
|
|
846
|
+
}
|
|
847
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
848
|
+
method: 'GET',
|
|
849
|
+
url: `${baseUrl}/v1/typebots`,
|
|
850
|
+
qs,
|
|
851
|
+
json: true,
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
else if (operation === 'get') {
|
|
855
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
856
|
+
const migrateToLatestVersion = this.getNodeParameter('migrateToLatestVersion', i);
|
|
857
|
+
const qs = {};
|
|
858
|
+
if (migrateToLatestVersion) {
|
|
859
|
+
qs.migrateToLatestVersion = true;
|
|
860
|
+
}
|
|
861
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
862
|
+
method: 'GET',
|
|
863
|
+
url: `${baseUrl}/v1/typebots/${typebotId}`,
|
|
864
|
+
qs,
|
|
865
|
+
json: true,
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
else if (operation === 'create') {
|
|
869
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
870
|
+
const typebotData = this.getNodeParameter('typebotData', i);
|
|
871
|
+
let typebot;
|
|
872
|
+
try {
|
|
873
|
+
typebot = JSON.parse(typebotData);
|
|
874
|
+
}
|
|
875
|
+
catch (error) {
|
|
876
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Typebot Data must be valid JSON');
|
|
877
|
+
}
|
|
878
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
879
|
+
method: 'POST',
|
|
880
|
+
url: `${baseUrl}/v1/typebots`,
|
|
881
|
+
body: {
|
|
882
|
+
workspaceId,
|
|
883
|
+
typebot,
|
|
884
|
+
},
|
|
885
|
+
json: true,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
else if (operation === 'update') {
|
|
889
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
890
|
+
const updateData = this.getNodeParameter('updateData', i);
|
|
891
|
+
let updates;
|
|
892
|
+
try {
|
|
893
|
+
updates = JSON.parse(updateData);
|
|
894
|
+
}
|
|
895
|
+
catch (error) {
|
|
896
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Update Data must be valid JSON');
|
|
897
|
+
}
|
|
898
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
899
|
+
method: 'PATCH',
|
|
900
|
+
url: `${baseUrl}/v1/typebots/${typebotId}`,
|
|
901
|
+
body: updates,
|
|
902
|
+
json: true,
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
else if (operation === 'delete') {
|
|
906
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
907
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
908
|
+
method: 'DELETE',
|
|
909
|
+
url: `${baseUrl}/v1/typebots/${typebotId}`,
|
|
910
|
+
json: true,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
else if (operation === 'publish') {
|
|
914
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
915
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
916
|
+
method: 'POST',
|
|
917
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/publish`,
|
|
918
|
+
json: true,
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
else if (operation === 'unpublish') {
|
|
922
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
923
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
924
|
+
method: 'POST',
|
|
925
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/unpublish`,
|
|
926
|
+
json: true,
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
else if (operation === 'getPublished') {
|
|
930
|
+
const publicId = this.getNodeParameter('publicId', i);
|
|
931
|
+
responseData = await this.helpers.request({
|
|
932
|
+
method: 'GET',
|
|
933
|
+
url: `https://typebot.io/api/v1/publicTypebots/${publicId}`,
|
|
934
|
+
json: true,
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
// =====================================
|
|
939
|
+
// Result Operations
|
|
940
|
+
// =====================================
|
|
941
|
+
else if (resource === 'result') {
|
|
942
|
+
if (operation === 'list') {
|
|
943
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
944
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
945
|
+
method: 'GET',
|
|
946
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/results`,
|
|
947
|
+
json: true,
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
else if (operation === 'get') {
|
|
951
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
952
|
+
const resultId = this.getNodeParameter('resultId', i);
|
|
953
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
954
|
+
method: 'GET',
|
|
955
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/results/${resultId}`,
|
|
956
|
+
json: true,
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
else if (operation === 'delete') {
|
|
960
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
961
|
+
const resultIds = this.getNodeParameter('resultIds', i);
|
|
962
|
+
const ids = resultIds.split(',').map(id => id.trim());
|
|
963
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
964
|
+
method: 'DELETE',
|
|
965
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/results`,
|
|
966
|
+
body: { resultIds: ids },
|
|
967
|
+
json: true,
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
else if (operation === 'getStats') {
|
|
971
|
+
const typebotId = this.getNodeParameter('typebotId', i);
|
|
972
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
973
|
+
method: 'GET',
|
|
974
|
+
url: `${baseUrl}/v1/typebots/${typebotId}/results/stats`,
|
|
975
|
+
json: true,
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
// =====================================
|
|
980
|
+
// Workspace Operations
|
|
981
|
+
// =====================================
|
|
982
|
+
else if (resource === 'workspace') {
|
|
983
|
+
if (operation === 'list') {
|
|
984
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
985
|
+
method: 'GET',
|
|
986
|
+
url: `${baseUrl}/v1/workspaces`,
|
|
987
|
+
json: true,
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
else if (operation === 'get') {
|
|
991
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
992
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
993
|
+
method: 'GET',
|
|
994
|
+
url: `${baseUrl}/v1/workspaces/${workspaceId}`,
|
|
995
|
+
json: true,
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
else if (operation === 'create') {
|
|
999
|
+
const name = this.getNodeParameter('name', i);
|
|
1000
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1001
|
+
method: 'POST',
|
|
1002
|
+
url: `${baseUrl}/v1/workspaces`,
|
|
1003
|
+
body: { name },
|
|
1004
|
+
json: true,
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
else if (operation === 'update') {
|
|
1008
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
1009
|
+
const updateData = this.getNodeParameter('updateData', i);
|
|
1010
|
+
let updates;
|
|
1011
|
+
try {
|
|
1012
|
+
updates = JSON.parse(updateData);
|
|
1013
|
+
}
|
|
1014
|
+
catch (error) {
|
|
1015
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Update Data must be valid JSON');
|
|
1016
|
+
}
|
|
1017
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1018
|
+
method: 'PATCH',
|
|
1019
|
+
url: `${baseUrl}/v1/workspaces/${workspaceId}`,
|
|
1020
|
+
body: updates,
|
|
1021
|
+
json: true,
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
else if (operation === 'delete') {
|
|
1025
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
1026
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1027
|
+
method: 'DELETE',
|
|
1028
|
+
url: `${baseUrl}/v1/workspaces/${workspaceId}`,
|
|
1029
|
+
json: true,
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
else if (operation === 'listMembers') {
|
|
1033
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
1034
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1035
|
+
method: 'GET',
|
|
1036
|
+
url: `${baseUrl}/v1/workspaces/${workspaceId}/members`,
|
|
1037
|
+
json: true,
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
// =====================================
|
|
1042
|
+
// Folder Operations
|
|
1043
|
+
// =====================================
|
|
1044
|
+
else if (resource === 'folder') {
|
|
1045
|
+
if (operation === 'list') {
|
|
1046
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
1047
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1048
|
+
method: 'GET',
|
|
1049
|
+
url: `${baseUrl}/v1/folders`,
|
|
1050
|
+
qs: { workspaceId },
|
|
1051
|
+
json: true,
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
else if (operation === 'create') {
|
|
1055
|
+
const workspaceId = this.getNodeParameter('workspaceId', i);
|
|
1056
|
+
const folderData = this.getNodeParameter('folderData', i);
|
|
1057
|
+
let folder;
|
|
1058
|
+
try {
|
|
1059
|
+
folder = JSON.parse(folderData);
|
|
1060
|
+
}
|
|
1061
|
+
catch (error) {
|
|
1062
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Folder Data must be valid JSON');
|
|
1063
|
+
}
|
|
1064
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1065
|
+
method: 'POST',
|
|
1066
|
+
url: `${baseUrl}/v1/folders`,
|
|
1067
|
+
body: {
|
|
1068
|
+
workspaceId,
|
|
1069
|
+
...folder,
|
|
1070
|
+
},
|
|
1071
|
+
json: true,
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
else if (operation === 'update') {
|
|
1075
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
1076
|
+
const updateData = this.getNodeParameter('updateData', i);
|
|
1077
|
+
let updates;
|
|
1078
|
+
try {
|
|
1079
|
+
updates = JSON.parse(updateData);
|
|
1080
|
+
}
|
|
1081
|
+
catch (error) {
|
|
1082
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Update Data must be valid JSON');
|
|
1083
|
+
}
|
|
1084
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1085
|
+
method: 'PATCH',
|
|
1086
|
+
url: `${baseUrl}/v1/folders/${folderId}`,
|
|
1087
|
+
body: updates,
|
|
1088
|
+
json: true,
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
else if (operation === 'delete') {
|
|
1092
|
+
const folderId = this.getNodeParameter('folderId', i);
|
|
1093
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
|
|
1094
|
+
method: 'DELETE',
|
|
1095
|
+
url: `${baseUrl}/v1/folders/${folderId}`,
|
|
1096
|
+
json: true,
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
|
|
1101
|
+
returnData.push(...executionData);
|
|
1102
|
+
}
|
|
1103
|
+
catch (error) {
|
|
1104
|
+
if (this.continueOnFail()) {
|
|
1105
|
+
const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error instanceof Error ? error.message : String(error) }), { itemData: { item: i } });
|
|
1106
|
+
returnData.push(...executionData);
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
throw error;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return [returnData];
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
exports.Typebot = Typebot;
|