n8n-nodes-typebot 1.0.4 → 1.1.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.
@@ -1,9 +1,8 @@
1
- import { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
1
+ import { IAuthenticateGeneric, ICredentialType, INodeProperties } from 'n8n-workflow';
2
2
  export declare class TypebotApi implements ICredentialType {
3
3
  name: string;
4
4
  displayName: string;
5
5
  documentationUrl: string;
6
6
  properties: INodeProperties[];
7
7
  authenticate: IAuthenticateGeneric;
8
- test: ICredentialTestRequest;
9
8
  }
@@ -43,13 +43,6 @@ class TypebotApi {
43
43
  },
44
44
  },
45
45
  };
46
- this.test = {
47
- request: {
48
- baseURL: '={{$credentials.baseUrl}}',
49
- url: '/v1/typebots',
50
- method: 'GET',
51
- },
52
- };
53
46
  }
54
47
  }
55
48
  exports.TypebotApi = TypebotApi;
@@ -7,7 +7,7 @@ class Typebot {
7
7
  this.description = {
8
8
  displayName: 'Typebot',
9
9
  name: 'typebot',
10
- icon: 'file:typebot.svg',
10
+ icon: 'file:typebot.png',
11
11
  group: ['transform'],
12
12
  version: 1,
13
13
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
@@ -86,6 +86,24 @@ class Typebot {
86
86
  description: 'Start a preview chat session',
87
87
  action: 'Start a preview chat session',
88
88
  },
89
+ {
90
+ name: 'Update Typebot in Session',
91
+ value: 'updateTypebotInSession',
92
+ description: 'Update typebot configuration in an active session',
93
+ action: 'Update typebot in session',
94
+ },
95
+ {
96
+ name: 'Save Logs',
97
+ value: 'saveLogs',
98
+ description: 'Save client logs for a session',
99
+ action: 'Save logs',
100
+ },
101
+ {
102
+ name: 'Generate Upload URL',
103
+ value: 'generateUploadUrl',
104
+ description: 'Generate a presigned URL for file upload',
105
+ action: 'Generate upload URL',
106
+ },
89
107
  ],
90
108
  default: 'startChat',
91
109
  },
@@ -250,6 +268,92 @@ class Typebot {
250
268
  },
251
269
  ],
252
270
  },
271
+ // Update Typebot in Session fields
272
+ {
273
+ displayName: 'Session ID',
274
+ name: 'sessionId',
275
+ type: 'string',
276
+ required: true,
277
+ displayOptions: {
278
+ show: {
279
+ resource: ['chat'],
280
+ operation: ['updateTypebotInSession'],
281
+ },
282
+ },
283
+ default: '',
284
+ description: 'The session ID to update',
285
+ },
286
+ // Save Logs fields
287
+ {
288
+ displayName: 'Session ID',
289
+ name: 'sessionId',
290
+ type: 'string',
291
+ required: true,
292
+ displayOptions: {
293
+ show: {
294
+ resource: ['chat'],
295
+ operation: ['saveLogs'],
296
+ },
297
+ },
298
+ default: '',
299
+ description: 'The session ID for the logs',
300
+ },
301
+ {
302
+ displayName: 'Client Logs',
303
+ name: 'clientLogs',
304
+ type: 'json',
305
+ required: true,
306
+ displayOptions: {
307
+ show: {
308
+ resource: ['chat'],
309
+ operation: ['saveLogs'],
310
+ },
311
+ },
312
+ default: '[{"description": "Log entry", "status": "info"}]',
313
+ description: 'Array of log entries with description, status, details, and context',
314
+ },
315
+ // Generate Upload URL fields
316
+ {
317
+ displayName: 'Session ID',
318
+ name: 'sessionId',
319
+ type: 'string',
320
+ required: true,
321
+ displayOptions: {
322
+ show: {
323
+ resource: ['chat'],
324
+ operation: ['generateUploadUrl'],
325
+ },
326
+ },
327
+ default: '',
328
+ description: 'The session ID for the upload',
329
+ },
330
+ {
331
+ displayName: 'File Name',
332
+ name: 'fileName',
333
+ type: 'string',
334
+ required: true,
335
+ displayOptions: {
336
+ show: {
337
+ resource: ['chat'],
338
+ operation: ['generateUploadUrl'],
339
+ },
340
+ },
341
+ default: '',
342
+ description: 'Name of the file to upload',
343
+ },
344
+ {
345
+ displayName: 'File Type',
346
+ name: 'fileType',
347
+ type: 'string',
348
+ displayOptions: {
349
+ show: {
350
+ resource: ['chat'],
351
+ operation: ['generateUploadUrl'],
352
+ },
353
+ },
354
+ default: '',
355
+ description: 'MIME type of the file (optional)',
356
+ },
253
357
  // =====================================
254
358
  // Typebot Operations
255
359
  // =====================================
@@ -312,6 +416,12 @@ class Typebot {
312
416
  description: 'Get published typebot',
313
417
  action: 'Get published typebot',
314
418
  },
419
+ {
420
+ name: 'Import',
421
+ value: 'import',
422
+ description: 'Import a typebot from JSON',
423
+ action: 'Import a typebot',
424
+ },
315
425
  ],
316
426
  default: 'list',
317
427
  },
@@ -418,6 +528,35 @@ class Typebot {
418
528
  default: '{\n "name": "My Typebot"\n}',
419
529
  description: 'The typebot configuration as JSON',
420
530
  },
531
+ // Import Typebot fields
532
+ {
533
+ displayName: 'Workspace ID',
534
+ name: 'workspaceId',
535
+ type: 'string',
536
+ required: true,
537
+ displayOptions: {
538
+ show: {
539
+ resource: ['typebot'],
540
+ operation: ['import'],
541
+ },
542
+ },
543
+ default: '',
544
+ description: 'The workspace ID where the typebot will be imported',
545
+ },
546
+ {
547
+ displayName: 'Typebot Data',
548
+ name: 'typebotData',
549
+ type: 'json',
550
+ required: true,
551
+ displayOptions: {
552
+ show: {
553
+ resource: ['typebot'],
554
+ operation: ['import'],
555
+ },
556
+ },
557
+ default: '{\n "version": "6",\n "name": "Imported Bot"\n}',
558
+ description: 'The complete typebot configuration to import (supports versions 3-6.1)',
559
+ },
421
560
  // Update Typebot fields
422
561
  {
423
562
  displayName: 'Update Data',
@@ -471,6 +610,12 @@ class Typebot {
471
610
  description: 'Get statistics',
472
611
  action: 'Get statistics',
473
612
  },
613
+ {
614
+ name: 'List Logs',
615
+ value: 'listLogs',
616
+ description: 'List logs for a result',
617
+ action: 'List logs in result',
618
+ },
474
619
  ],
475
620
  default: 'list',
476
621
  },
@@ -518,6 +663,35 @@ class Typebot {
518
663
  default: '',
519
664
  description: 'The ID of the result',
520
665
  },
666
+ // List Logs fields
667
+ {
668
+ displayName: 'Typebot ID',
669
+ name: 'typebotId',
670
+ type: 'string',
671
+ required: true,
672
+ displayOptions: {
673
+ show: {
674
+ resource: ['result'],
675
+ operation: ['listLogs'],
676
+ },
677
+ },
678
+ default: '',
679
+ description: 'The ID of the typebot',
680
+ },
681
+ {
682
+ displayName: 'Result ID',
683
+ name: 'resultId',
684
+ type: 'string',
685
+ required: true,
686
+ displayOptions: {
687
+ show: {
688
+ resource: ['result'],
689
+ operation: ['listLogs'],
690
+ },
691
+ },
692
+ default: '',
693
+ description: 'The ID of the result',
694
+ },
521
695
  // Delete Results fields
522
696
  {
523
697
  displayName: 'Result IDs',
@@ -831,6 +1005,49 @@ class Typebot {
831
1005
  json: true,
832
1006
  });
833
1007
  }
1008
+ else if (operation === 'updateTypebotInSession') {
1009
+ const sessionId = this.getNodeParameter('sessionId', i);
1010
+ responseData = await this.helpers.request({
1011
+ method: 'POST',
1012
+ url: `${chatBaseUrl}/v1/sessions/${sessionId}/updateTypebot`,
1013
+ json: true,
1014
+ });
1015
+ }
1016
+ else if (operation === 'saveLogs') {
1017
+ const sessionId = this.getNodeParameter('sessionId', i);
1018
+ const clientLogs = this.getNodeParameter('clientLogs', i);
1019
+ let logs;
1020
+ try {
1021
+ logs = JSON.parse(clientLogs);
1022
+ }
1023
+ catch (error) {
1024
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Client Logs must be valid JSON');
1025
+ }
1026
+ responseData = await this.helpers.request({
1027
+ method: 'POST',
1028
+ url: `${chatBaseUrl}/v2/sessions/${sessionId}/clientLogs`,
1029
+ body: { clientLogs: logs },
1030
+ json: true,
1031
+ });
1032
+ }
1033
+ else if (operation === 'generateUploadUrl') {
1034
+ const sessionId = this.getNodeParameter('sessionId', i);
1035
+ const fileName = this.getNodeParameter('fileName', i);
1036
+ const fileType = this.getNodeParameter('fileType', i);
1037
+ const body = {
1038
+ fileName,
1039
+ };
1040
+ if (fileType) {
1041
+ body.fileType = fileType;
1042
+ }
1043
+ responseData = await this.helpers.request({
1044
+ method: 'POST',
1045
+ url: `${chatBaseUrl}/v2/generate-upload-url`,
1046
+ qs: { sessionId },
1047
+ body,
1048
+ json: true,
1049
+ });
1050
+ }
834
1051
  }
835
1052
  // =====================================
836
1053
  // Typebot Operations
@@ -935,6 +1152,26 @@ class Typebot {
935
1152
  json: true,
936
1153
  });
937
1154
  }
1155
+ else if (operation === 'import') {
1156
+ const workspaceId = this.getNodeParameter('workspaceId', i);
1157
+ const typebotData = this.getNodeParameter('typebotData', i);
1158
+ let typebot;
1159
+ try {
1160
+ typebot = JSON.parse(typebotData);
1161
+ }
1162
+ catch (error) {
1163
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Typebot Data must be valid JSON');
1164
+ }
1165
+ responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
1166
+ method: 'POST',
1167
+ url: `${baseUrl}/v1/typebots/import`,
1168
+ body: {
1169
+ workspaceId,
1170
+ typebot,
1171
+ },
1172
+ json: true,
1173
+ });
1174
+ }
938
1175
  }
939
1176
  // =====================================
940
1177
  // Result Operations
@@ -972,7 +1209,16 @@ class Typebot {
972
1209
  const typebotId = this.getNodeParameter('typebotId', i);
973
1210
  responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
974
1211
  method: 'GET',
975
- url: `${baseUrl}/v1/typebots/${typebotId}/results/stats`,
1212
+ url: `${baseUrl}/v1/typebots/${typebotId}/analytics/stats`,
1213
+ json: true,
1214
+ });
1215
+ }
1216
+ else if (operation === 'listLogs') {
1217
+ const typebotId = this.getNodeParameter('typebotId', i);
1218
+ const resultId = this.getNodeParameter('resultId', i);
1219
+ responseData = await this.helpers.requestWithAuthentication.call(this, 'typebotApi', {
1220
+ method: 'GET',
1221
+ url: `${baseUrl}/v1/typebots/${typebotId}/results/${resultId}/logs`,
976
1222
  json: true,
977
1223
  });
978
1224
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-typebot",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "n8n community node for Typebot - A powerful chatbot builder integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",