@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.48 → 0.0.1-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/chat.client.d.ts +1 -4
- package/dist/client/contact-method.client.d.ts +2 -1
- package/dist/contact-method.js +14 -4
- package/dist/contact-method.js.map +1 -1
- package/dist/contract/custom-component/contact-method-item.d.ts +2 -0
- package/dist/contract/custom-component/contact-method-list.d.ts +1 -0
- package/dist/feedback-list.js +107 -0
- package/dist/feedback-list.js.map +1 -0
- package/dist/index.js +202 -159
- package/dist/index.js.map +1 -1
- package/dist/interface/entry.interface.d.ts +4 -1
- package/dist/no-good-alternative.js +33 -0
- package/dist/no-good-alternative.js.map +1 -0
- package/dist/ui/feedback-list.d.ts +8 -0
- package/dist/ui/no-good-alternative.d.ts +6 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
};
|
|
40
40
|
import { ContactMethodPlatform } from "@telia-ace/knowledge-widget-adapters";
|
|
41
41
|
import { DataType, DataClient } from "@telia-ace/knowledge-widget-types-grid";
|
|
42
|
-
import { ConversationMessageListItemType, ConversationPlatform
|
|
42
|
+
import { ConversationMessageListItemType, ConversationPlatform } from "@telia-ace/widget-conversation";
|
|
43
43
|
import { v4 } from "uuid";
|
|
44
44
|
import { createStorageWriter, StorageCategory, readStorage } from "@telia-ace/widget-services";
|
|
45
45
|
import { FormBuilder, submitButton } from "@telia-ace/widget-forms";
|
|
@@ -173,6 +173,72 @@ const _StoreHelper = class {
|
|
|
173
173
|
};
|
|
174
174
|
let StoreHelper = _StoreHelper;
|
|
175
175
|
StoreHelper.messageStore = [];
|
|
176
|
+
class ChatClient {
|
|
177
|
+
constructor() {
|
|
178
|
+
}
|
|
179
|
+
static initialize(user, agent) {
|
|
180
|
+
ChatHelper.setUser(user);
|
|
181
|
+
ChatHelper.setAgent(agent);
|
|
182
|
+
}
|
|
183
|
+
processMessageArrayAndStoreIt(messages) {
|
|
184
|
+
return __async(this, null, function* () {
|
|
185
|
+
for (const message of messages.filter((o) => o && o != null && !!o.message)) {
|
|
186
|
+
if (message.isUser)
|
|
187
|
+
this.postUserMessage(message);
|
|
188
|
+
else
|
|
189
|
+
this.postAgentMessage(message);
|
|
190
|
+
}
|
|
191
|
+
yield StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
updateMessageArrayAndStoreIt(messages) {
|
|
195
|
+
let conversationEntry = void 0;
|
|
196
|
+
messages.forEach((o) => {
|
|
197
|
+
let message = StoreHelper.getMessage(o.id);
|
|
198
|
+
message == null ? void 0 : message.conversationEntry.update(o.message);
|
|
199
|
+
conversationEntry = message == null ? void 0 : message.conversationEntry;
|
|
200
|
+
});
|
|
201
|
+
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
202
|
+
}
|
|
203
|
+
printUserMessageAndStoreIt(action) {
|
|
204
|
+
if (action == "next" || action == "help")
|
|
205
|
+
return;
|
|
206
|
+
let entry = StoreHelper.getEntry(action);
|
|
207
|
+
let message = {
|
|
208
|
+
id: v4(),
|
|
209
|
+
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
210
|
+
isUser: true
|
|
211
|
+
};
|
|
212
|
+
this.postUserMessage(message);
|
|
213
|
+
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
214
|
+
}
|
|
215
|
+
postUserMessage(message) {
|
|
216
|
+
ChatHelper.getUser().print(message.message);
|
|
217
|
+
}
|
|
218
|
+
postAgentMessage(message) {
|
|
219
|
+
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
220
|
+
}
|
|
221
|
+
getTitleFromEntry(entry, action) {
|
|
222
|
+
const entryType = ServerEntryTypeEnum[entry.type];
|
|
223
|
+
switch (entryType) {
|
|
224
|
+
case ServerEntryTypeEnum.List:
|
|
225
|
+
return this.getTitleFromList(entry, action);
|
|
226
|
+
case ServerEntryTypeEnum.Text:
|
|
227
|
+
return this.getTitleFromText(entry, action);
|
|
228
|
+
default:
|
|
229
|
+
return "";
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getTitleFromText(entry, action) {
|
|
233
|
+
if (!!entry.content.items)
|
|
234
|
+
return this.getTitleFromList(entry, action);
|
|
235
|
+
else
|
|
236
|
+
return entry.content.html;
|
|
237
|
+
}
|
|
238
|
+
getTitleFromList(entry, action) {
|
|
239
|
+
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
176
242
|
const _ContactMethodClient = class {
|
|
177
243
|
constructor(container) {
|
|
178
244
|
this.handleNewForm = (errors, entry) => __async(this, null, function* () {
|
|
@@ -225,7 +291,7 @@ const _ContactMethodClient = class {
|
|
|
225
291
|
}
|
|
226
292
|
return (contactMethod == null ? void 0 : contactMethod.body) || {};
|
|
227
293
|
};
|
|
228
|
-
this.chatClient = new ChatClient(
|
|
294
|
+
this.chatClient = new ChatClient();
|
|
229
295
|
}
|
|
230
296
|
static initialize(container, dataClient, contactMethodPlatform, agent) {
|
|
231
297
|
this.dataClient = dataClient;
|
|
@@ -267,10 +333,7 @@ const _ContactMethodClient = class {
|
|
|
267
333
|
if (messageItemIndex > -1) {
|
|
268
334
|
const [messageItemType, messageItemContent] = message.message[messageItemIndex];
|
|
269
335
|
const updatedMessageItemContent = __spreadProps(__spreadValues({}, messageItemContent), {
|
|
270
|
-
contactMethods: messageItemContent.contactMethods
|
|
271
|
-
cm.expanded = true;
|
|
272
|
-
return cm;
|
|
273
|
-
})
|
|
336
|
+
contactMethods: this.getNewContactMethods(messageItemContent.contactMethods)
|
|
274
337
|
});
|
|
275
338
|
const updatedMessageItems = [
|
|
276
339
|
...message.message.slice(0, messageItemIndex),
|
|
@@ -281,6 +344,17 @@ const _ContactMethodClient = class {
|
|
|
281
344
|
}
|
|
282
345
|
}
|
|
283
346
|
}
|
|
347
|
+
getNewContactMethods(contactMethods) {
|
|
348
|
+
if (Array.isArray(contactMethods)) {
|
|
349
|
+
return contactMethods.map((cm) => {
|
|
350
|
+
cm.expanded = true;
|
|
351
|
+
return cm;
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
contactMethods.expanded = true;
|
|
355
|
+
return contactMethods;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
284
358
|
handleContactMethodList(input, contactMethods) {
|
|
285
359
|
let title = input.split("/")[2];
|
|
286
360
|
let newGuid = v4();
|
|
@@ -355,7 +429,7 @@ const _ContactMethodClient = class {
|
|
|
355
429
|
return message;
|
|
356
430
|
}
|
|
357
431
|
}
|
|
358
|
-
loadContactMethods(dataType, id = void 0) {
|
|
432
|
+
loadContactMethods(dataType, id = void 0, guideId = void 0) {
|
|
359
433
|
switch (dataType) {
|
|
360
434
|
case DataType.ContactMethodCategories: {
|
|
361
435
|
return _ContactMethodClient.container.getAsync("matchingClient").then((matchingClient) => {
|
|
@@ -365,7 +439,9 @@ const _ContactMethodClient = class {
|
|
|
365
439
|
});
|
|
366
440
|
}
|
|
367
441
|
case DataType.ContactMethods: {
|
|
368
|
-
if (!!id) {
|
|
442
|
+
if (!!id && !!guideId) {
|
|
443
|
+
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethod, { contactMethodId: id, guideId }).then((contactMethods) => contactMethods);
|
|
444
|
+
} else if (!!id) {
|
|
369
445
|
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethod, { contactMethodId: id }).then((contactMethods) => contactMethods);
|
|
370
446
|
} else {
|
|
371
447
|
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethods, {}).then((contactMethods) => contactMethods);
|
|
@@ -382,6 +458,31 @@ const _ContactMethodClient = class {
|
|
|
382
458
|
};
|
|
383
459
|
let ContactMethodClient = _ContactMethodClient;
|
|
384
460
|
ContactMethodClient.contactMessageEntryArray = [];
|
|
461
|
+
const _HttpHelper = class {
|
|
462
|
+
static combineUrl(basePath, path) {
|
|
463
|
+
return basePath + path;
|
|
464
|
+
}
|
|
465
|
+
static getCredentials() {
|
|
466
|
+
return "same-origin";
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
let HttpHelper = _HttpHelper;
|
|
470
|
+
HttpHelper.fetchOptions = {
|
|
471
|
+
method: "POST",
|
|
472
|
+
headers: {
|
|
473
|
+
Accept: "application/json",
|
|
474
|
+
"Content-Type": "application/json"
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
|
|
478
|
+
HttpHelper.parseSubdomain = (input) => {
|
|
479
|
+
const index = input.lastIndexOf("-");
|
|
480
|
+
const lastPart = input.substr(index + 1);
|
|
481
|
+
if (_HttpHelper.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
482
|
+
return input.substr(0, index);
|
|
483
|
+
}
|
|
484
|
+
return input;
|
|
485
|
+
};
|
|
385
486
|
const getContactMethodEntry = (contactMethodId) => {
|
|
386
487
|
const entries = StoreHelper.getEntryStore();
|
|
387
488
|
return entries.find((e) => e.content.id === +contactMethodId);
|
|
@@ -448,11 +549,13 @@ const contactMethodFromLegacy = ({
|
|
|
448
549
|
}
|
|
449
550
|
return settings;
|
|
450
551
|
};
|
|
451
|
-
class
|
|
552
|
+
const _EntryInterface = class {
|
|
452
553
|
constructor(container) {
|
|
453
554
|
this.container = container;
|
|
454
555
|
this.helpActionKey = "help";
|
|
455
556
|
this.nextActionKey = "next";
|
|
557
|
+
this.contactMethodClient = void 0;
|
|
558
|
+
this.contactMethodClient = new ContactMethodClient(container);
|
|
456
559
|
}
|
|
457
560
|
transform(entry, feedbackEntry) {
|
|
458
561
|
return __async(this, null, function* () {
|
|
@@ -468,7 +571,7 @@ class EntryInterface {
|
|
|
468
571
|
case ServerEntryTypeEnum.Text:
|
|
469
572
|
return {
|
|
470
573
|
id: entry.id,
|
|
471
|
-
message: this.textTransform(entry, feedbackEntry),
|
|
574
|
+
message: yield this.textTransform(entry, feedbackEntry),
|
|
472
575
|
entry,
|
|
473
576
|
isUser: false
|
|
474
577
|
};
|
|
@@ -484,12 +587,12 @@ class EntryInterface {
|
|
|
484
587
|
}
|
|
485
588
|
transformContactMethod(entry) {
|
|
486
589
|
return __async(this, null, function* () {
|
|
590
|
+
var _a;
|
|
487
591
|
const dataClient = yield this.container.getAsync("dataClient");
|
|
488
592
|
const contactMethod = yield dataClient.fetch(DataType.ContactMethod, {
|
|
489
593
|
contactMethodId: entry.content.id
|
|
490
594
|
});
|
|
491
|
-
|
|
492
|
-
cmClient.addContactMethod(contactMethod);
|
|
595
|
+
(_a = this.contactMethodClient) == null ? void 0 : _a.addContactMethod(contactMethod);
|
|
493
596
|
});
|
|
494
597
|
}
|
|
495
598
|
transformArray(entryArray) {
|
|
@@ -505,26 +608,17 @@ class EntryInterface {
|
|
|
505
608
|
});
|
|
506
609
|
}
|
|
507
610
|
getUserMessage(action) {
|
|
508
|
-
|
|
509
|
-
|
|
611
|
+
return __async(this, null, function* () {
|
|
612
|
+
let entry = StoreHelper.getEntry(action);
|
|
613
|
+
return yield this.getTitleFromEntry(entry, action);
|
|
614
|
+
});
|
|
510
615
|
}
|
|
511
616
|
listTransform(entry, feedbackEntry) {
|
|
512
|
-
if (entry.type === "Contact")
|
|
617
|
+
if (entry.type === "Contact" || !entry.content)
|
|
513
618
|
return;
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
return;
|
|
517
|
-
let object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
|
|
518
|
-
if (!!feedbackEntry) {
|
|
519
|
-
let feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState);
|
|
520
|
-
StoreHelper.insertMessageToStore({
|
|
521
|
-
id: feedbackEntry.id,
|
|
522
|
-
message: void 0,
|
|
523
|
-
entry: feedbackEntry,
|
|
524
|
-
isUser: false
|
|
525
|
-
});
|
|
526
|
-
return object.concat(feedbackObject);
|
|
527
|
-
}
|
|
619
|
+
let object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState, entry.id);
|
|
620
|
+
if (!!feedbackEntry)
|
|
621
|
+
return this.addFeedbackToEntry(object, feedbackEntry);
|
|
528
622
|
return object;
|
|
529
623
|
}
|
|
530
624
|
getContentText(entry) {
|
|
@@ -534,29 +628,39 @@ class EntryInterface {
|
|
|
534
628
|
return { title: entry.content.header };
|
|
535
629
|
}
|
|
536
630
|
textTransform(entry, feedbackEntry) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
631
|
+
return __async(this, null, function* () {
|
|
632
|
+
var _a;
|
|
633
|
+
if (!!entry.content.items)
|
|
634
|
+
return this.listTransform(entry, feedbackEntry);
|
|
635
|
+
let returnObj = [
|
|
636
|
+
[ConversationMessageListItemType.HTML, { body: entry.content.html.replace("\n", "") }]
|
|
637
|
+
];
|
|
638
|
+
if (!!entry.actions.submitted) {
|
|
639
|
+
let contactMethod = yield (_a = this.contactMethodClient) == null ? void 0 : _a.loadContactMethods(DataType.ContactMethods, entry.actions.submitted.id.toString(), entry.actions.submitted.guideId.toString());
|
|
640
|
+
returnObj.push([
|
|
641
|
+
"ace-knowledge-contact-method",
|
|
642
|
+
{
|
|
643
|
+
contactMethods: contactMethod,
|
|
644
|
+
entry: { entryId: entry.id },
|
|
645
|
+
guideId: entry.actions.submitted.guideId
|
|
646
|
+
}
|
|
647
|
+
]);
|
|
648
|
+
}
|
|
649
|
+
if (!!feedbackEntry)
|
|
650
|
+
return this.addFeedbackToEntry(returnObj, feedbackEntry);
|
|
651
|
+
return returnObj;
|
|
652
|
+
});
|
|
555
653
|
}
|
|
556
|
-
getListActions(items, text, actions, state) {
|
|
654
|
+
getListActions(items, text, actions, state, id) {
|
|
557
655
|
let list = [];
|
|
558
|
-
let mainListContent = {};
|
|
559
656
|
const mainListType = this.getListType(state);
|
|
657
|
+
const createMainList = (type) => {
|
|
658
|
+
if (type === ConversationMessageListItemType.ButtonList) {
|
|
659
|
+
return [];
|
|
660
|
+
}
|
|
661
|
+
return {};
|
|
662
|
+
};
|
|
663
|
+
let mainListContent = createMainList(mainListType);
|
|
560
664
|
let mainList = [mainListType, { actions: mainListContent }];
|
|
561
665
|
if (mainListType === "ace-knowledge-contact-method") {
|
|
562
666
|
mainList[1] = __spreadProps(__spreadValues({}, mainList[1]), {
|
|
@@ -565,7 +669,7 @@ class EntryInterface {
|
|
|
565
669
|
return formatted;
|
|
566
670
|
}),
|
|
567
671
|
entry: {
|
|
568
|
-
entryId:
|
|
672
|
+
entryId: id
|
|
569
673
|
}
|
|
570
674
|
});
|
|
571
675
|
}
|
|
@@ -580,19 +684,34 @@ class EntryInterface {
|
|
|
580
684
|
switch (o.actionKey) {
|
|
581
685
|
case this.helpActionKey: {
|
|
582
686
|
list.push([ConversationMessageListItemType.Separator, void 0]);
|
|
583
|
-
list.push([
|
|
584
|
-
ConversationMessageListItemType.NoGoodAlternative,
|
|
585
|
-
{ body: o.title }
|
|
586
|
-
]);
|
|
687
|
+
list.push(["no-good-alternative", { body: o.title }]);
|
|
587
688
|
break;
|
|
588
689
|
}
|
|
589
690
|
case this.nextActionKey: {
|
|
590
|
-
if (
|
|
591
|
-
|
|
691
|
+
if (!_EntryInterface.pagingAmount)
|
|
692
|
+
_EntryInterface.pagingAmount = actions["next"].take - items.filter((o2) => o2.actionKey !== "help" && o2.actionKey !== "next").length;
|
|
693
|
+
if (!!actions["next"] && actions["next"].take === items.filter((o2) => o2.actionKey !== "help" && o2.actionKey !== "next").length + _EntryInterface.pagingAmount) {
|
|
694
|
+
if (Array.isArray(mainListContent)) {
|
|
695
|
+
mainListContent.push({
|
|
696
|
+
label: o.title,
|
|
697
|
+
actionKey: o.actionKey
|
|
698
|
+
});
|
|
699
|
+
} else {
|
|
700
|
+
mainListContent[o.actionKey] = o.title;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
592
703
|
break;
|
|
593
704
|
}
|
|
594
705
|
default: {
|
|
595
|
-
mainListContent
|
|
706
|
+
if (Array.isArray(mainListContent)) {
|
|
707
|
+
mainListContent.push({
|
|
708
|
+
label: o.title,
|
|
709
|
+
actionKey: o.actionKey,
|
|
710
|
+
symbol: o.symbol
|
|
711
|
+
});
|
|
712
|
+
} else {
|
|
713
|
+
mainListContent[o.actionKey] = o.title;
|
|
714
|
+
}
|
|
596
715
|
}
|
|
597
716
|
}
|
|
598
717
|
});
|
|
@@ -602,119 +721,41 @@ class EntryInterface {
|
|
|
602
721
|
if ((state == null ? void 0 : state.$type) === "Humany.Matching.Bots.Conversations.GuideListState, Humany.Matching") {
|
|
603
722
|
return ConversationMessageListItemType.LinkList;
|
|
604
723
|
} else if ((state == null ? void 0 : state.$type) === "Humany.Matching.Bots.Conversations.States.GuideFeedbackState, Humany.Matching") {
|
|
605
|
-
return
|
|
724
|
+
return "feedback-list";
|
|
606
725
|
} else if ((state == null ? void 0 : state.$type) === "Humany.Matching.Bots.Conversations.States.ContactState, Humany.Matching") {
|
|
607
726
|
return "ace-knowledge-contact-method";
|
|
608
727
|
} else
|
|
609
728
|
return ConversationMessageListItemType.ButtonList;
|
|
610
729
|
}
|
|
611
730
|
getTitleFromEntry(entry, action) {
|
|
612
|
-
if (!!entry) {
|
|
613
|
-
const entryType = ServerEntryTypeEnum[entry.type];
|
|
614
|
-
switch (entryType) {
|
|
615
|
-
case ServerEntryTypeEnum.List:
|
|
616
|
-
return this.getTitleFromList(entry, action);
|
|
617
|
-
case ServerEntryTypeEnum.Text:
|
|
618
|
-
return this.textTransform(entry);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
getTitleFromList(entry, action) {
|
|
623
|
-
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
class ChatClient {
|
|
627
|
-
constructor(container) {
|
|
628
|
-
this.entryInterface = new EntryInterface(container);
|
|
629
|
-
}
|
|
630
|
-
static initialize(user, agent) {
|
|
631
|
-
ChatHelper.setUser(user);
|
|
632
|
-
ChatHelper.setAgent(agent);
|
|
633
|
-
}
|
|
634
|
-
processMessageArrayAndStoreIt(messages) {
|
|
635
731
|
return __async(this, null, function* () {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
732
|
+
if (!!entry) {
|
|
733
|
+
const entryType = ServerEntryTypeEnum[entry.type];
|
|
734
|
+
switch (entryType) {
|
|
735
|
+
case ServerEntryTypeEnum.List:
|
|
736
|
+
return this.getTitleFromList(entry, action);
|
|
737
|
+
case ServerEntryTypeEnum.Text:
|
|
738
|
+
return yield this.textTransform(entry);
|
|
739
|
+
}
|
|
641
740
|
}
|
|
642
|
-
yield StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
643
741
|
});
|
|
644
742
|
}
|
|
645
|
-
updateMessageArrayAndStoreIt(messages) {
|
|
646
|
-
let conversationEntry = void 0;
|
|
647
|
-
messages.forEach((o) => {
|
|
648
|
-
let message = StoreHelper.getMessage(o.id);
|
|
649
|
-
message == null ? void 0 : message.conversationEntry.update(o.message);
|
|
650
|
-
conversationEntry = message == null ? void 0 : message.conversationEntry;
|
|
651
|
-
});
|
|
652
|
-
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
653
|
-
}
|
|
654
|
-
printUserMessageAndStoreIt(action) {
|
|
655
|
-
if (action == "next" || action == "help")
|
|
656
|
-
return;
|
|
657
|
-
let entry = StoreHelper.getEntry(action);
|
|
658
|
-
let message = {
|
|
659
|
-
id: v4(),
|
|
660
|
-
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
661
|
-
isUser: true
|
|
662
|
-
};
|
|
663
|
-
this.postUserMessage(message);
|
|
664
|
-
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
665
|
-
}
|
|
666
|
-
postUserMessage(message) {
|
|
667
|
-
ChatHelper.getUser().print(message.message);
|
|
668
|
-
}
|
|
669
|
-
postAgentMessage(message) {
|
|
670
|
-
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
671
|
-
}
|
|
672
|
-
getTitleFromEntry(entry, action) {
|
|
673
|
-
const entryType = ServerEntryTypeEnum[entry.type];
|
|
674
|
-
switch (entryType) {
|
|
675
|
-
case ServerEntryTypeEnum.List:
|
|
676
|
-
return this.getTitleFromList(entry, action);
|
|
677
|
-
case ServerEntryTypeEnum.Text:
|
|
678
|
-
return this.getTitleFromText(entry, action);
|
|
679
|
-
default:
|
|
680
|
-
return "";
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
getTitleFromText(entry, action) {
|
|
684
|
-
if (!!entry.content.items)
|
|
685
|
-
return this.getTitleFromList(entry, action);
|
|
686
|
-
else
|
|
687
|
-
return entry.content.html;
|
|
688
|
-
}
|
|
689
743
|
getTitleFromList(entry, action) {
|
|
690
744
|
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
691
745
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
let HttpHelper = _HttpHelper;
|
|
702
|
-
HttpHelper.fetchOptions = {
|
|
703
|
-
method: "POST",
|
|
704
|
-
headers: {
|
|
705
|
-
Accept: "application/json",
|
|
706
|
-
"Content-Type": "application/json"
|
|
707
|
-
}
|
|
708
|
-
};
|
|
709
|
-
HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
|
|
710
|
-
HttpHelper.parseSubdomain = (input) => {
|
|
711
|
-
const index = input.lastIndexOf("-");
|
|
712
|
-
const lastPart = input.substr(index + 1);
|
|
713
|
-
if (_HttpHelper.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
714
|
-
return input.substr(0, index);
|
|
746
|
+
addFeedbackToEntry(current, feedbackEntry) {
|
|
747
|
+
let feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState, feedbackEntry.id);
|
|
748
|
+
StoreHelper.insertMessageToStore({
|
|
749
|
+
id: feedbackEntry.id,
|
|
750
|
+
message: void 0,
|
|
751
|
+
entry: feedbackEntry,
|
|
752
|
+
isUser: false
|
|
753
|
+
});
|
|
754
|
+
return current.concat(feedbackObject);
|
|
715
755
|
}
|
|
716
|
-
return input;
|
|
717
756
|
};
|
|
757
|
+
let EntryInterface = _EntryInterface;
|
|
758
|
+
EntryInterface.pagingAmount = void 0;
|
|
718
759
|
class PagingInterface {
|
|
719
760
|
process(entries) {
|
|
720
761
|
const pagingEntry = entries.find((e) => e.tags.indexOf("paging") > -1);
|
|
@@ -857,7 +898,7 @@ class MiddlewareClient {
|
|
|
857
898
|
this.paging = new PagingInterface();
|
|
858
899
|
this.processor = new ProcessorInterface();
|
|
859
900
|
this.entryInterface = new EntryInterface(container);
|
|
860
|
-
this.chatClient = new ChatClient(
|
|
901
|
+
this.chatClient = new ChatClient();
|
|
861
902
|
}
|
|
862
903
|
static initialize(container, widget) {
|
|
863
904
|
MiddlewareHelper.setContainer(container);
|
|
@@ -918,7 +959,7 @@ class HttpClient {
|
|
|
918
959
|
this.endpointUrl = HttpHelper.combineUrl(this.projectionPath, "conversations");
|
|
919
960
|
this.clientId = this.options.clientId;
|
|
920
961
|
this.middlewareClient = new MiddlewareClient(container);
|
|
921
|
-
this.chatClient = new ChatClient(
|
|
962
|
+
this.chatClient = new ChatClient();
|
|
922
963
|
this.container = container;
|
|
923
964
|
}
|
|
924
965
|
firstHit() {
|
|
@@ -1057,7 +1098,9 @@ const KnowledgeBotProviderPlugin = (container) => __async(this, null, function*
|
|
|
1057
1098
|
const dataClient = yield DataClient.getInstance(container);
|
|
1058
1099
|
const platform = yield ConversationPlatform.getInstance(container);
|
|
1059
1100
|
const contactMethodPlatform = yield ContactMethodPlatform.getInstance(container);
|
|
1060
|
-
|
|
1101
|
+
platform.registerConversationItem("ace-knowledge-contact-method", import("./contact-method.js"));
|
|
1102
|
+
platform.registerConversationItem("no-good-alternative", import("./no-good-alternative.js"));
|
|
1103
|
+
platform.registerConversationItem("feedback-list", import("./feedback-list.js"));
|
|
1061
1104
|
platform.registerProvider("chat.bot", (conversation, component) => {
|
|
1062
1105
|
const endpoint = getKnowledgeBotEndpoint(container, component);
|
|
1063
1106
|
const clientId = v4();
|
|
@@ -1104,7 +1147,7 @@ const KnowledgeBotProviderPlugin = (container) => __async(this, null, function*
|
|
|
1104
1147
|
return next(input);
|
|
1105
1148
|
});
|
|
1106
1149
|
component.actions.watch("conversation.action", (input, next) => {
|
|
1107
|
-
const chatClient = new ChatClient(
|
|
1150
|
+
const chatClient = new ChatClient();
|
|
1108
1151
|
const cmClient = new ContactMethodClient(container);
|
|
1109
1152
|
const loader = conversation.loading();
|
|
1110
1153
|
if (input.split("/").length > 1) {
|