@servicetitan/titan-chatbot-api 4.1.2 → 4.2.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts +2 -0
  3. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts.map +1 -1
  4. package/dist/api-client/__mocks__/chatbot-api-client.mock.js +12 -0
  5. package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -1
  6. package/dist/api-client/base/chatbot-api-client.d.ts +2 -0
  7. package/dist/api-client/base/chatbot-api-client.d.ts.map +1 -1
  8. package/dist/api-client/help-center/chatbot-api-client.d.ts +2 -0
  9. package/dist/api-client/help-center/chatbot-api-client.d.ts.map +1 -1
  10. package/dist/api-client/help-center/chatbot-api-client.js +13 -0
  11. package/dist/api-client/help-center/chatbot-api-client.js.map +1 -1
  12. package/dist/api-client/models/index.d.ts +1 -1
  13. package/dist/api-client/models/index.d.ts.map +1 -1
  14. package/dist/api-client/models/index.js +1 -1
  15. package/dist/api-client/models/index.js.map +1 -1
  16. package/dist/api-client/titan-chat/chatbot-api-client.d.ts +2 -0
  17. package/dist/api-client/titan-chat/chatbot-api-client.d.ts.map +1 -1
  18. package/dist/api-client/titan-chat/chatbot-api-client.js +6 -0
  19. package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -1
  20. package/dist/api-client/titan-chat/native-client.d.ts +147 -4
  21. package/dist/api-client/titan-chat/native-client.d.ts.map +1 -1
  22. package/dist/api-client/titan-chat/native-client.js +341 -0
  23. package/dist/api-client/titan-chat/native-client.js.map +1 -1
  24. package/package.json +3 -3
  25. package/src/api-client/__mocks__/chatbot-api-client.mock.ts +2 -0
  26. package/src/api-client/base/chatbot-api-client.ts +6 -0
  27. package/src/api-client/help-center/chatbot-api-client.ts +16 -0
  28. package/src/api-client/models/index.ts +2 -0
  29. package/src/api-client/titan-chat/chatbot-api-client.ts +8 -0
  30. package/src/api-client/titan-chat/native-client.ts +307 -4
  31. package/tsconfig.tsbuildinfo +1 -1
@@ -328,57 +328,188 @@ export class Client {
328
328
  }
329
329
  return Promise.resolve(null);
330
330
  }
331
+ /**
332
+ * @param start (optional)
333
+ * @param end (optional)
334
+ * @param x_Client_ID (optional)
335
+ * @return Success
336
+ */
337
+ transcripts(start, end, version, x_Client_ID, signal) {
338
+ let url_ = this.baseUrl + "/api/v{version}/transcripts?";
339
+ if (version === undefined || version === null)
340
+ throw new Error("The parameter 'version' must be defined.");
341
+ url_ = url_.replace("{version}", encodeURIComponent("" + version));
342
+ if (start === null)
343
+ throw new Error("The parameter 'start' cannot be null.");
344
+ else if (start !== undefined)
345
+ url_ += "start=" + encodeURIComponent(start ? "" + start.toISOString() : "") + "&";
346
+ if (end === null)
347
+ throw new Error("The parameter 'end' cannot be null.");
348
+ else if (end !== undefined)
349
+ url_ += "end=" + encodeURIComponent(end ? "" + end.toISOString() : "") + "&";
350
+ url_ = url_.replace(/[?&]$/, "");
351
+ let options_ = {
352
+ method: "GET",
353
+ signal,
354
+ headers: {
355
+ "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
356
+ "Accept": "text/plain"
357
+ }
358
+ };
359
+ return this.http.fetch(url_, options_).then((_response) => {
360
+ return this.processTranscripts(_response);
361
+ });
362
+ }
363
+ processTranscripts(response) {
364
+ const status = response.status;
365
+ let _headers = {};
366
+ if (response.headers && response.headers.forEach) {
367
+ response.headers.forEach((v, k) => _headers[k] = v);
368
+ }
369
+ ;
370
+ if (status === 200) {
371
+ return response.text().then((_responseText) => {
372
+ let result200 = null;
373
+ let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
374
+ if (Array.isArray(resultData200)) {
375
+ result200 = [];
376
+ for (let item of resultData200)
377
+ result200.push(ExportHistoryMessage.fromJS(item));
378
+ }
379
+ else {
380
+ result200 = null;
381
+ }
382
+ return result200;
383
+ });
384
+ }
385
+ else if (status !== 200 && status !== 204) {
386
+ return response.text().then((_responseText) => {
387
+ return throwException("An unexpected server error occurred.", status, _responseText, _headers);
388
+ });
389
+ }
390
+ return Promise.resolve(null);
391
+ }
392
+ /**
393
+ * @param sessionId (optional)
394
+ * @param x_Client_ID (optional)
395
+ * @return Success
396
+ */
397
+ summary(sessionId, version, x_Client_ID, signal) {
398
+ let url_ = this.baseUrl + "/api/v{version}/transcripts/summary?";
399
+ if (version === undefined || version === null)
400
+ throw new Error("The parameter 'version' must be defined.");
401
+ url_ = url_.replace("{version}", encodeURIComponent("" + version));
402
+ if (sessionId === null)
403
+ throw new Error("The parameter 'sessionId' cannot be null.");
404
+ else if (sessionId !== undefined)
405
+ url_ += "sessionId=" + encodeURIComponent("" + sessionId) + "&";
406
+ url_ = url_.replace(/[?&]$/, "");
407
+ let options_ = {
408
+ method: "GET",
409
+ signal,
410
+ headers: {
411
+ "X-Client-ID": x_Client_ID !== undefined && x_Client_ID !== null ? "" + x_Client_ID : "",
412
+ "Accept": "text/plain"
413
+ }
414
+ };
415
+ return this.http.fetch(url_, options_).then((_response) => {
416
+ return this.processSummary(_response);
417
+ });
418
+ }
419
+ processSummary(response) {
420
+ const status = response.status;
421
+ let _headers = {};
422
+ if (response.headers && response.headers.forEach) {
423
+ response.headers.forEach((v, k) => _headers[k] = v);
424
+ }
425
+ ;
426
+ if (status === 200) {
427
+ return response.text().then((_responseText) => {
428
+ let result200 = null;
429
+ let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
430
+ result200 = resultData200 !== undefined ? resultData200 : null;
431
+ return result200;
432
+ });
433
+ }
434
+ else if (status !== 200 && status !== 204) {
435
+ return response.text().then((_responseText) => {
436
+ return throwException("An unexpected server error occurred.", status, _responseText, _headers);
437
+ });
438
+ }
439
+ return Promise.resolve(null);
440
+ }
331
441
  }
442
+ /** Chatbot response message. */
332
443
  export class BotMessage {
333
444
  constructor(data) {
445
+ /** Primary key. */
334
446
  Object.defineProperty(this, "id", {
335
447
  enumerable: true,
336
448
  configurable: true,
337
449
  writable: true,
338
450
  value: void 0
339
451
  });
452
+ /** Session ID. Required in multi-turn conversations after the session is created. */
340
453
  Object.defineProperty(this, "sessionId", {
341
454
  enumerable: true,
342
455
  configurable: true,
343
456
  writable: true,
344
457
  value: void 0
345
458
  });
459
+ Object.defineProperty(this, "timeStamp", {
460
+ enumerable: true,
461
+ configurable: true,
462
+ writable: true,
463
+ value: void 0
464
+ });
465
+ /** Chatbot answer. */
346
466
  Object.defineProperty(this, "answer", {
347
467
  enumerable: true,
348
468
  configurable: true,
349
469
  writable: true,
350
470
  value: void 0
351
471
  });
472
+ /** Ordered list of relevant Knowledge Base links. */
352
473
  Object.defineProperty(this, "scoredUrls", {
353
474
  enumerable: true,
354
475
  configurable: true,
355
476
  writable: true,
356
477
  value: void 0
357
478
  });
479
+ /** A value indicating one of the conditions:
480
+ - N - "none" or "normal", a successful response
481
+ - A - "agent", user wants to talk to a support agent
482
+ - C - "conversation", user attempted to continue a conversation in a single-turn message
483
+ - OI - "offensive input"
484
+ Client may handle these conditions in different ways. */
358
485
  Object.defineProperty(this, "guardFlag", {
359
486
  enumerable: true,
360
487
  configurable: true,
361
488
  writable: true,
362
489
  value: void 0
363
490
  });
491
+ /** Whether the answer is guardrailed, meaning TitanChatbot.Host.API.Models.BotMessage.GuardFlag is anything but "N". */
364
492
  Object.defineProperty(this, "isGuardrailed", {
365
493
  enumerable: true,
366
494
  configurable: true,
367
495
  writable: true,
368
496
  value: void 0
369
497
  });
498
+ /** Chatbot version number. */
370
499
  Object.defineProperty(this, "botVersion", {
371
500
  enumerable: true,
372
501
  configurable: true,
373
502
  writable: true,
374
503
  value: void 0
375
504
  });
505
+ /** AI model version. */
376
506
  Object.defineProperty(this, "modelVersion", {
377
507
  enumerable: true,
378
508
  configurable: true,
379
509
  writable: true,
380
510
  value: void 0
381
511
  });
512
+ /** Various metadata for diagnostics purposes. */
382
513
  Object.defineProperty(this, "meta", {
383
514
  enumerable: true,
384
515
  configurable: true,
@@ -396,6 +527,7 @@ export class BotMessage {
396
527
  if (_data) {
397
528
  this.id = _data["id"];
398
529
  this.sessionId = _data["sessionId"];
530
+ this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : undefined;
399
531
  this.answer = _data["answer"];
400
532
  if (Array.isArray(_data["scoredUrls"])) {
401
533
  this.scoredUrls = [];
@@ -419,6 +551,7 @@ export class BotMessage {
419
551
  data = typeof data === 'object' ? data : {};
420
552
  data["id"] = this.id;
421
553
  data["sessionId"] = this.sessionId;
554
+ data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : undefined;
422
555
  data["answer"] = this.answer;
423
556
  if (Array.isArray(this.scoredUrls)) {
424
557
  data["scoredUrls"] = [];
@@ -438,32 +571,208 @@ export var Experience;
438
571
  Experience[Experience["SingleTurn"] = 1] = "SingleTurn";
439
572
  Experience[Experience["MultiTurn"] = 2] = "MultiTurn";
440
573
  })(Experience || (Experience = {}));
574
+ export class ExportHistoryMessage {
575
+ constructor(data) {
576
+ /** Primary key. */
577
+ Object.defineProperty(this, "id", {
578
+ enumerable: true,
579
+ configurable: true,
580
+ writable: true,
581
+ value: void 0
582
+ });
583
+ /** Session ID. Required in multi-turn conversations after the session is created. */
584
+ Object.defineProperty(this, "sessionId", {
585
+ enumerable: true,
586
+ configurable: true,
587
+ writable: true,
588
+ value: void 0
589
+ });
590
+ Object.defineProperty(this, "timeStamp", {
591
+ enumerable: true,
592
+ configurable: true,
593
+ writable: true,
594
+ value: void 0
595
+ });
596
+ Object.defineProperty(this, "userId", {
597
+ enumerable: true,
598
+ configurable: true,
599
+ writable: true,
600
+ value: void 0
601
+ });
602
+ Object.defineProperty(this, "sessionStartTime", {
603
+ enumerable: true,
604
+ configurable: true,
605
+ writable: true,
606
+ value: void 0
607
+ });
608
+ Object.defineProperty(this, "sessionEndTime", {
609
+ enumerable: true,
610
+ configurable: true,
611
+ writable: true,
612
+ value: void 0
613
+ });
614
+ Object.defineProperty(this, "userName", {
615
+ enumerable: true,
616
+ configurable: true,
617
+ writable: true,
618
+ value: void 0
619
+ });
620
+ Object.defineProperty(this, "userEmail", {
621
+ enumerable: true,
622
+ configurable: true,
623
+ writable: true,
624
+ value: void 0
625
+ });
626
+ Object.defineProperty(this, "question", {
627
+ enumerable: true,
628
+ configurable: true,
629
+ writable: true,
630
+ value: void 0
631
+ });
632
+ Object.defineProperty(this, "answer", {
633
+ enumerable: true,
634
+ configurable: true,
635
+ writable: true,
636
+ value: void 0
637
+ });
638
+ Object.defineProperty(this, "messageType", {
639
+ enumerable: true,
640
+ configurable: true,
641
+ writable: true,
642
+ value: void 0
643
+ });
644
+ Object.defineProperty(this, "salesforceCaseId", {
645
+ enumerable: true,
646
+ configurable: true,
647
+ writable: true,
648
+ value: void 0
649
+ });
650
+ Object.defineProperty(this, "guardFlag", {
651
+ enumerable: true,
652
+ configurable: true,
653
+ writable: true,
654
+ value: void 0
655
+ });
656
+ Object.defineProperty(this, "isGuardrailed", {
657
+ enumerable: true,
658
+ configurable: true,
659
+ writable: true,
660
+ value: void 0
661
+ });
662
+ Object.defineProperty(this, "botVersion", {
663
+ enumerable: true,
664
+ configurable: true,
665
+ writable: true,
666
+ value: void 0
667
+ });
668
+ Object.defineProperty(this, "metadata", {
669
+ enumerable: true,
670
+ configurable: true,
671
+ writable: true,
672
+ value: void 0
673
+ });
674
+ Object.defineProperty(this, "feedback", {
675
+ enumerable: true,
676
+ configurable: true,
677
+ writable: true,
678
+ value: void 0
679
+ });
680
+ Object.defineProperty(this, "sessionFeedback", {
681
+ enumerable: true,
682
+ configurable: true,
683
+ writable: true,
684
+ value: void 0
685
+ });
686
+ if (data) {
687
+ for (var property in data) {
688
+ if (data.hasOwnProperty(property))
689
+ this[property] = data[property];
690
+ }
691
+ }
692
+ }
693
+ init(_data) {
694
+ if (_data) {
695
+ this.id = _data["id"];
696
+ this.sessionId = _data["sessionId"];
697
+ this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : undefined;
698
+ this.userId = _data["userId"];
699
+ this.sessionStartTime = _data["sessionStartTime"] ? new Date(_data["sessionStartTime"].toString()) : undefined;
700
+ this.sessionEndTime = _data["sessionEndTime"] ? new Date(_data["sessionEndTime"].toString()) : undefined;
701
+ this.userName = _data["userName"];
702
+ this.userEmail = _data["userEmail"];
703
+ this.question = _data["question"];
704
+ this.answer = _data["answer"];
705
+ this.messageType = _data["messageType"];
706
+ this.salesforceCaseId = _data["salesforceCaseId"];
707
+ this.guardFlag = _data["guardFlag"];
708
+ this.isGuardrailed = _data["isGuardrailed"];
709
+ this.botVersion = _data["botVersion"];
710
+ this.metadata = _data["metadata"];
711
+ this.feedback = _data["feedback"] ? Feedback.fromJS(_data["feedback"]) : undefined;
712
+ this.sessionFeedback = _data["sessionFeedback"] ? Feedback.fromJS(_data["sessionFeedback"]) : undefined;
713
+ }
714
+ }
715
+ static fromJS(data) {
716
+ data = typeof data === 'object' ? data : {};
717
+ let result = new ExportHistoryMessage();
718
+ result.init(data);
719
+ return result;
720
+ }
721
+ toJSON(data) {
722
+ data = typeof data === 'object' ? data : {};
723
+ data["id"] = this.id;
724
+ data["sessionId"] = this.sessionId;
725
+ data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : undefined;
726
+ data["userId"] = this.userId;
727
+ data["sessionStartTime"] = this.sessionStartTime ? this.sessionStartTime.toISOString() : undefined;
728
+ data["sessionEndTime"] = this.sessionEndTime ? this.sessionEndTime.toISOString() : undefined;
729
+ data["userName"] = this.userName;
730
+ data["userEmail"] = this.userEmail;
731
+ data["question"] = this.question;
732
+ data["answer"] = this.answer;
733
+ data["messageType"] = this.messageType;
734
+ data["salesforceCaseId"] = this.salesforceCaseId;
735
+ data["guardFlag"] = this.guardFlag;
736
+ data["isGuardrailed"] = this.isGuardrailed;
737
+ data["botVersion"] = this.botVersion;
738
+ data["metadata"] = this.metadata;
739
+ data["feedback"] = this.feedback ? this.feedback.toJSON() : undefined;
740
+ data["sessionFeedback"] = this.sessionFeedback ? this.sessionFeedback.toJSON() : undefined;
741
+ return data;
742
+ }
743
+ }
744
+ /** User feedback for chatbot interaction. */
441
745
  export class Feedback {
442
746
  constructor(data) {
747
+ /** A link to correct information according to user. */
443
748
  Object.defineProperty(this, "linkUrl", {
444
749
  enumerable: true,
445
750
  configurable: true,
446
751
  writable: true,
447
752
  value: void 0
448
753
  });
754
+ /** User typed input. */
449
755
  Object.defineProperty(this, "description", {
450
756
  enumerable: true,
451
757
  configurable: true,
452
758
  writable: true,
453
759
  value: void 0
454
760
  });
761
+ /** Session ID for session feedback. */
455
762
  Object.defineProperty(this, "sessionId", {
456
763
  enumerable: true,
457
764
  configurable: true,
458
765
  writable: true,
459
766
  value: void 0
460
767
  });
768
+ /** Message ID for message feedback. */
461
769
  Object.defineProperty(this, "messageId", {
462
770
  enumerable: true,
463
771
  configurable: true,
464
772
  writable: true,
465
773
  value: void 0
466
774
  });
775
+ /** Selected options. */
467
776
  Object.defineProperty(this, "options", {
468
777
  enumerable: true,
469
778
  configurable: true,
@@ -567,14 +876,17 @@ export class FrontendModel {
567
876
  return data;
568
877
  }
569
878
  }
879
+ /** A meaningful selectable option or a parent node for other options. */
570
880
  export class Option {
571
881
  constructor(data) {
882
+ /** Identifier key. */
572
883
  Object.defineProperty(this, "key", {
573
884
  enumerable: true,
574
885
  configurable: true,
575
886
  writable: true,
576
887
  value: void 0
577
888
  });
889
+ /** Display name. */
578
890
  Object.defineProperty(this, "displayName", {
579
891
  enumerable: true,
580
892
  configurable: true,
@@ -587,6 +899,7 @@ export class Option {
587
899
  writable: true,
588
900
  value: void 0
589
901
  });
902
+ /** Child options down the hierarchy. */
590
903
  Object.defineProperty(this, "subOptions", {
591
904
  enumerable: true,
592
905
  configurable: true,
@@ -637,6 +950,7 @@ export var OptionType;
637
950
  OptionType[OptionType["Group"] = 1] = "Group";
638
951
  OptionType[OptionType["Selectable"] = 2] = "Selectable";
639
952
  })(OptionType || (OptionType = {}));
953
+ /** A scored link to Knowledge Base article. */
640
954
  export class ScoredUrl {
641
955
  constructor(data) {
642
956
  Object.defineProperty(this, "url", {
@@ -685,14 +999,17 @@ export class ScoredUrl {
685
999
  return data;
686
1000
  }
687
1001
  }
1002
+ /** User-selected values from available options. Hierarchy of TitanChatbot.Host.API.Models.Selections must match hierarchy of TitanChatbot.Host.API.Models.Option. */
688
1003
  export class Selections {
689
1004
  constructor(data) {
1005
+ /** Selected values. */
690
1006
  Object.defineProperty(this, "values", {
691
1007
  enumerable: true,
692
1008
  configurable: true,
693
1009
  writable: true,
694
1010
  value: void 0
695
1011
  });
1012
+ /** Child selections down the hierarchy. */
696
1013
  Object.defineProperty(this, "subOptions", {
697
1014
  enumerable: true,
698
1015
  configurable: true,
@@ -745,14 +1062,17 @@ export class Selections {
745
1062
  return data;
746
1063
  }
747
1064
  }
1065
+ /** Series of chatbot exchanges making a conversation. */
748
1066
  export class Session {
749
1067
  constructor(data) {
1068
+ /** Primary key. */
750
1069
  Object.defineProperty(this, "id", {
751
1070
  enumerable: true,
752
1071
  configurable: true,
753
1072
  writable: true,
754
1073
  value: void 0
755
1074
  });
1075
+ /** Arbitrary data to be stored in session. */
756
1076
  Object.defineProperty(this, "data", {
757
1077
  enumerable: true,
758
1078
  configurable: true,
@@ -797,14 +1117,30 @@ export class Session {
797
1117
  return data;
798
1118
  }
799
1119
  }
1120
+ /** User request message. */
800
1121
  export class UserMessage {
801
1122
  constructor(data) {
1123
+ /** Primary key. */
1124
+ Object.defineProperty(this, "id", {
1125
+ enumerable: true,
1126
+ configurable: true,
1127
+ writable: true,
1128
+ value: void 0
1129
+ });
1130
+ /** Session ID. Required in multi-turn conversations after the session is created. */
802
1131
  Object.defineProperty(this, "sessionId", {
803
1132
  enumerable: true,
804
1133
  configurable: true,
805
1134
  writable: true,
806
1135
  value: void 0
807
1136
  });
1137
+ Object.defineProperty(this, "timeStamp", {
1138
+ enumerable: true,
1139
+ configurable: true,
1140
+ writable: true,
1141
+ value: void 0
1142
+ });
1143
+ /** User question. */
808
1144
  Object.defineProperty(this, "question", {
809
1145
  enumerable: true,
810
1146
  configurable: true,
@@ -823,6 +1159,7 @@ export class UserMessage {
823
1159
  writable: true,
824
1160
  value: void 0
825
1161
  });
1162
+ /** Additional context. */
826
1163
  Object.defineProperty(this, "context", {
827
1164
  enumerable: true,
828
1165
  configurable: true,
@@ -838,7 +1175,9 @@ export class UserMessage {
838
1175
  }
839
1176
  init(_data) {
840
1177
  if (_data) {
1178
+ this.id = _data["id"];
841
1179
  this.sessionId = _data["sessionId"];
1180
+ this.timeStamp = _data["timeStamp"] ? new Date(_data["timeStamp"].toString()) : undefined;
842
1181
  this.question = _data["question"];
843
1182
  this.experience = _data["experience"];
844
1183
  this.selections = _data["selections"] ? Selections.fromJS(_data["selections"]) : undefined;
@@ -859,7 +1198,9 @@ export class UserMessage {
859
1198
  }
860
1199
  toJSON(data) {
861
1200
  data = typeof data === 'object' ? data : {};
1201
+ data["id"] = this.id;
862
1202
  data["sessionId"] = this.sessionId;
1203
+ data["timeStamp"] = this.timeStamp ? this.timeStamp.toISOString() : undefined;
863
1204
  data["question"] = this.question;
864
1205
  data["experience"] = this.experience;
865
1206
  data["selections"] = this.selections ? this.selections.toJSON() : undefined;