@carbon/ai-chat 0.1.6 → 0.1.7-alpha0
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/cjs/{cds-aichat-internal.js → AppContainer.js} +615 -7203
- package/dist/cjs/Carousel.js +24 -16
- package/dist/cjs/Chat.js +813 -805
- package/dist/cjs/GenesysMessengerServiceDesk.js +60 -52
- package/dist/cjs/HumanAgentServiceImpl.js +103 -95
- package/dist/cjs/NiceDFOServiceDesk.js +56 -48
- package/dist/cjs/PDFViewerContainer.js +58 -149
- package/dist/cjs/ReactPlayer.js +2 -2
- package/dist/cjs/SFServiceDesk.js +66 -58
- package/dist/cjs/ServiceDeskImpl.js +2 -2
- package/dist/cjs/Table.js +457 -341
- package/dist/cjs/ZendeskServiceDesk.js +36 -28
- package/dist/cjs/_node-resolve_empty.js +2 -2
- package/dist/cjs/agentActions.js +5 -5
- package/dist/cjs/aiChatEntry.js +163 -144
- package/dist/cjs/anonymousUserIDStorage.js +8 -8
- package/dist/cjs/ar-dz.js +4 -4
- package/dist/cjs/ar-kw.js +4 -4
- package/dist/cjs/ar-ly.js +4 -4
- package/dist/cjs/ar-ma.js +4 -4
- package/dist/cjs/ar-sa.js +4 -4
- package/dist/cjs/ar-tn.js +4 -4
- package/dist/cjs/ar.js +4 -4
- package/dist/cjs/ar2.js +2 -2
- package/dist/cjs/cds-aichat-container.js +111 -23
- package/dist/cjs/cds-aichat-custom-element.js +42 -30
- package/dist/cjs/cs.js +4 -4
- package/dist/cjs/cs2.js +2 -2
- package/dist/cjs/de-at.js +4 -4
- package/dist/cjs/de-ch.js +4 -4
- package/dist/cjs/de.js +4 -4
- package/dist/cjs/de2.js +2 -2
- package/dist/cjs/en-au.js +4 -4
- package/dist/cjs/en-ca.js +4 -4
- package/dist/cjs/en-gb.js +4 -4
- package/dist/cjs/en-ie.js +4 -4
- package/dist/cjs/en-il.js +4 -4
- package/dist/cjs/en-nz.js +4 -4
- package/dist/cjs/es-do.js +4 -4
- package/dist/cjs/es-us.js +4 -4
- package/dist/cjs/es.js +4 -4
- package/dist/cjs/es2.js +2 -2
- package/dist/cjs/export.js +3 -3
- package/dist/cjs/export.legacy.js +3 -3
- package/dist/cjs/fontUtils.js +2 -2
- package/dist/cjs/fr-ca.js +4 -4
- package/dist/cjs/fr-ch.js +4 -4
- package/dist/cjs/fr.js +4 -4
- package/dist/cjs/fr2.js +2 -2
- package/dist/cjs/highlight_js.js +2 -2
- package/dist/cjs/it-ch.js +4 -4
- package/dist/cjs/it.js +4 -4
- package/dist/cjs/it2.js +2 -2
- package/dist/cjs/ja.js +4 -4
- package/dist/cjs/ja2.js +2 -2
- package/dist/cjs/ko.js +4 -4
- package/dist/cjs/ko2.js +2 -2
- package/dist/cjs/markdown.js +2362 -14
- package/dist/cjs/mockServiceDesk.js +42 -34
- package/dist/cjs/nl.js +4 -4
- package/dist/cjs/nl2.js +2 -2
- package/dist/cjs/pt-br.js +4 -4
- package/dist/cjs/pt-br2.js +2 -2
- package/dist/cjs/pt.js +4 -4
- package/dist/cjs/render.js +18 -10
- package/dist/cjs/zh-cn.js +4 -4
- package/dist/cjs/zh-tw.js +4 -4
- package/dist/cjs/zh-tw2.js +2 -2
- package/dist/cjs/zh.js +2 -2
- package/dist/es/{cds-aichat-internal.js → AppContainer.js} +1117 -7671
- package/dist/es/Carousel.js +16 -8
- package/dist/es/Chat.js +16 -8
- package/dist/es/GenesysMessengerServiceDesk.js +16 -8
- package/dist/es/HumanAgentServiceImpl.js +16 -8
- package/dist/es/NiceDFOServiceDesk.js +16 -8
- package/dist/es/PDFViewerContainer.js +16 -107
- package/dist/es/ReactPlayer.js +2 -2
- package/dist/es/SFServiceDesk.js +16 -8
- package/dist/es/ServiceDeskImpl.js +2 -2
- package/dist/es/Table.js +426 -310
- package/dist/es/ZendeskServiceDesk.js +16 -8
- package/dist/es/_node-resolve_empty.js +2 -2
- package/dist/es/agentActions.js +3 -3
- package/dist/es/aiChatEntry.js +136 -117
- package/dist/es/anonymousUserIDStorage.js +3 -3
- package/dist/es/ar-dz.js +3 -3
- package/dist/es/ar-kw.js +3 -3
- package/dist/es/ar-ly.js +3 -3
- package/dist/es/ar-ma.js +3 -3
- package/dist/es/ar-sa.js +3 -3
- package/dist/es/ar-tn.js +3 -3
- package/dist/es/ar.js +3 -3
- package/dist/es/ar2.js +2 -2
- package/dist/es/cds-aichat-container.js +103 -15
- package/dist/es/cds-aichat-custom-element.js +30 -18
- package/dist/es/cs.js +3 -3
- package/dist/es/cs2.js +2 -2
- package/dist/es/de-at.js +3 -3
- package/dist/es/de-ch.js +3 -3
- package/dist/es/de.js +3 -3
- package/dist/es/de2.js +2 -2
- package/dist/es/en-au.js +3 -3
- package/dist/es/en-ca.js +3 -3
- package/dist/es/en-gb.js +3 -3
- package/dist/es/en-ie.js +3 -3
- package/dist/es/en-il.js +3 -3
- package/dist/es/en-nz.js +3 -3
- package/dist/es/es-do.js +3 -3
- package/dist/es/es-us.js +3 -3
- package/dist/es/es.js +3 -3
- package/dist/es/es2.js +2 -2
- package/dist/es/export.js +3 -3
- package/dist/es/export.legacy.js +3 -3
- package/dist/es/fontUtils.js +2 -2
- package/dist/es/fr-ca.js +3 -3
- package/dist/es/fr-ch.js +3 -3
- package/dist/es/fr.js +3 -3
- package/dist/es/fr2.js +2 -2
- package/dist/es/highlight_js.js +2 -2
- package/dist/es/it-ch.js +3 -3
- package/dist/es/it.js +3 -3
- package/dist/es/it2.js +2 -2
- package/dist/es/ja.js +3 -3
- package/dist/es/ja2.js +2 -2
- package/dist/es/ko.js +3 -3
- package/dist/es/ko2.js +2 -2
- package/dist/es/markdown.js +2361 -15
- package/dist/es/mockServiceDesk.js +16 -8
- package/dist/es/nl.js +3 -3
- package/dist/es/nl2.js +2 -2
- package/dist/es/pt-br.js +3 -3
- package/dist/es/pt-br2.js +2 -2
- package/dist/es/pt.js +3 -3
- package/dist/es/render.js +17 -9
- package/dist/es/zh-cn.js +3 -3
- package/dist/es/zh-tw.js +3 -3
- package/dist/es/zh-tw2.js +2 -2
- package/dist/es/zh.js +2 -2
- package/dist/types/aiChatEntry.d.ts +69 -9
- package/package.json +27 -14
- package/dist/cjs/jstz.min.js +0 -43
- package/dist/cjs/markdown_attrs.js +0 -805
- package/dist/es/jstz.min.js +0 -41
- package/dist/es/markdown_attrs.js +0 -803
|
@@ -13,9 +13,9 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-alpha0
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 12 2025 9:14 am -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
@@ -23,29 +23,37 @@ Built: Feb 3 2025 9:58 am -05:00
|
|
|
23
23
|
'use strict';
|
|
24
24
|
|
|
25
25
|
var highlight_js = require('./highlight_js.js');
|
|
26
|
-
var
|
|
26
|
+
var AppContainer = require('./AppContainer.js');
|
|
27
27
|
var anonymousUserIDStorage = require('./anonymousUserIDStorage.js');
|
|
28
28
|
var ServiceDeskImpl = require('./ServiceDeskImpl.js');
|
|
29
|
-
require('lit');
|
|
30
|
-
require('lit/decorators.js');
|
|
31
29
|
require('react');
|
|
32
|
-
require('react-dom');
|
|
33
30
|
require('@carbon/react');
|
|
31
|
+
require('classnames');
|
|
34
32
|
require('react-intl');
|
|
35
33
|
require('react-redux');
|
|
34
|
+
require('tabbable');
|
|
35
|
+
require('@carbon/icons-react');
|
|
36
36
|
require('./markdown.js');
|
|
37
|
-
require('
|
|
37
|
+
require('tslib');
|
|
38
|
+
require('lit');
|
|
39
|
+
require('lit/decorators.js');
|
|
38
40
|
require('@carbon/web-components/es/components/button/index.js');
|
|
39
41
|
require('@carbon/web-components/es/components/overflow-menu/index.js');
|
|
40
42
|
require('lit/directives/unsafe-html.js');
|
|
43
|
+
require('prop-types');
|
|
41
44
|
require('@carbon/web-components/es/components/slug/index.js');
|
|
42
45
|
require('@carbon/web-components/es/components/popover/defs.js');
|
|
43
46
|
require('@carbon/web-components/es/components/slug/defs.js');
|
|
47
|
+
require('@floating-ui/react');
|
|
48
|
+
require('react-dom');
|
|
44
49
|
require('@carbon/web-components/es/components/slug/slug-action-button.js');
|
|
45
50
|
require('@carbon/web-components/es/components/slug/slug.js');
|
|
51
|
+
require('@carbon/web-components/es/components/inline-loading/index.js');
|
|
52
|
+
require('@carbon/icon-helpers');
|
|
53
|
+
require('@carbon/icons');
|
|
54
|
+
require('lit/directives/unsafe-svg.js');
|
|
46
55
|
require('@carbon/web-components/es/components/textarea/index.js');
|
|
47
56
|
require('@carbon/web-components/es/components/icon-button/index.js');
|
|
48
|
-
require('lit/directives/unsafe-svg.js');
|
|
49
57
|
require('@carbon/web-components/es/components/tag/index.js');
|
|
50
58
|
require('@carbon/web-components/es/components/chat-button/index.js');
|
|
51
59
|
require('@carbon/web-components/es/components/button/button.js');
|
|
@@ -1738,24 +1746,24 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1738
1746
|
this.updatePersistedState({ customerID: null, lastAgentMessageID: null, contactID: null, threadID: null }, false);
|
|
1739
1747
|
}
|
|
1740
1748
|
else {
|
|
1741
|
-
|
|
1749
|
+
AppContainer.debugLog(`${PREFIX} Retrieved previous state`, this.persistedState());
|
|
1742
1750
|
}
|
|
1743
1751
|
const configData = this.config;
|
|
1744
|
-
|
|
1752
|
+
AppContainer.debugLog(`${PREFIX} Creating integration using config`, configData);
|
|
1745
1753
|
let { customerID } = this.persistedState();
|
|
1746
1754
|
if (!customerID) {
|
|
1747
1755
|
if (configData.useWebChatUserID === true) {
|
|
1748
1756
|
customerID = this.state.userID;
|
|
1749
1757
|
}
|
|
1750
1758
|
else if (configData.useWebChatUserID === false || this.state.userID.startsWith(anonymousUserIDStorage.ANONYMOUS_USER_ID_PREFIX)) {
|
|
1751
|
-
customerID =
|
|
1759
|
+
customerID = AppContainer.uuid(AppContainer.UUIDType.MISCELLANEOUS);
|
|
1752
1760
|
}
|
|
1753
1761
|
else {
|
|
1754
1762
|
customerID = this.state.userID;
|
|
1755
1763
|
}
|
|
1756
1764
|
this.updatePersistedState({ customerID });
|
|
1757
1765
|
}
|
|
1758
|
-
|
|
1766
|
+
AppContainer.debugLog(`${PREFIX} Using customer ID "${customerID}"`);
|
|
1759
1767
|
const options = {
|
|
1760
1768
|
brandId: configData.brandID,
|
|
1761
1769
|
channelId: configData.channelID,
|
|
@@ -1774,9 +1782,9 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1774
1782
|
await this.eventBus.fire(getAuthCodeEvent, this.instance);
|
|
1775
1783
|
this.sdk = new ChatSdk(options);
|
|
1776
1784
|
// this.addEvents();
|
|
1777
|
-
|
|
1785
|
+
AppContainer.debugLog(`${PREFIX} Authorizing...`);
|
|
1778
1786
|
const authResponse = (await this.sdk.authorize(getAuthCodeEvent.authCode, getAuthCodeEvent.visitorID));
|
|
1779
|
-
|
|
1787
|
+
AppContainer.debugLog(`${PREFIX} Authorize complete`, authResponse);
|
|
1780
1788
|
this.isChannelOnline = authResponse.channel?.availability?.status === 'online';
|
|
1781
1789
|
this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.SET_POSITION_IN_QUEUE, event => this.handlePositionInQueue(event));
|
|
1782
1790
|
this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.ASSIGNED_AGENT_CHANGED, event => this.handleAgentChanged(event));
|
|
@@ -1791,17 +1799,17 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1791
1799
|
const { threadID } = this.persistedState();
|
|
1792
1800
|
if (threadID) {
|
|
1793
1801
|
try {
|
|
1794
|
-
|
|
1802
|
+
AppContainer.debugLog(`${PREFIX} Using existing thread ${threadID}`, this.thread);
|
|
1795
1803
|
// If we had a previous thread, then use that and try to recover it.
|
|
1796
1804
|
this.thread = this.sdk.getThread(threadID);
|
|
1797
|
-
const recovered = await
|
|
1798
|
-
|
|
1805
|
+
const recovered = await AppContainer.resolveOrTimeout(this.thread.recover(), INIT_TIMEOUT_MS, 'recover timed out');
|
|
1806
|
+
AppContainer.debugLog(`${PREFIX} Recovered thread ${threadID}`, recovered);
|
|
1799
1807
|
await this.handleRecover(recovered);
|
|
1800
1808
|
this.addThreadListeners();
|
|
1801
1809
|
return true;
|
|
1802
1810
|
}
|
|
1803
1811
|
catch (error) {
|
|
1804
|
-
|
|
1812
|
+
AppContainer.consoleError(`${PREFIX} Error getting existing thread`, error);
|
|
1805
1813
|
this.updatePersistedState({ threadID: null, contactID: null });
|
|
1806
1814
|
}
|
|
1807
1815
|
}
|
|
@@ -1822,17 +1830,17 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1822
1830
|
*/
|
|
1823
1831
|
async startChat(connectMessage, startChatOptions) {
|
|
1824
1832
|
await this.ensureSDK();
|
|
1825
|
-
const connectItem = connectMessage.output.generic.find(
|
|
1833
|
+
const connectItem = connectMessage.output.generic.find(AppContainer.isConnectToAgent);
|
|
1826
1834
|
const { preStartChatPayload } = startChatOptions;
|
|
1827
1835
|
// Create a new thread.
|
|
1828
|
-
const threadID =
|
|
1829
|
-
|
|
1836
|
+
const threadID = AppContainer.uuid(AppContainer.UUIDType.MISCELLANEOUS);
|
|
1837
|
+
AppContainer.debugLog(`${PREFIX} Creating new thread ${threadID}`);
|
|
1830
1838
|
this.thread = this.sdk.getThread(threadID);
|
|
1831
1839
|
this.addThreadListeners();
|
|
1832
1840
|
if (preStartChatPayload?.customerName) {
|
|
1833
1841
|
this.sdk.getCustomer().setName(preStartChatPayload.customerName);
|
|
1834
1842
|
}
|
|
1835
|
-
this.newContactPromise =
|
|
1843
|
+
this.newContactPromise = AppContainer.resolvablePromise();
|
|
1836
1844
|
// Set any custom fields from the pre-chat handler.
|
|
1837
1845
|
if (preStartChatPayload?.consumerContact?.customFields?.length) {
|
|
1838
1846
|
const customFields = {};
|
|
@@ -1841,19 +1849,19 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1841
1849
|
});
|
|
1842
1850
|
this.thread.setCustomFields(customFields);
|
|
1843
1851
|
}
|
|
1844
|
-
const messagesToAgent =
|
|
1852
|
+
const messagesToAgent = AppContainer.getSummaryMessages(connectItem, 'Begin conversation');
|
|
1845
1853
|
await this.thread.startChat(messagesToAgent.join('\n'));
|
|
1846
1854
|
// Sending the messages above should result in a new contact being created.
|
|
1847
|
-
const contactID = await
|
|
1855
|
+
const contactID = await AppContainer.resolveOrTimeout(this.newContactPromise, INIT_TIMEOUT_MS, 'A new chat timed out waiting for a contact to be created.');
|
|
1848
1856
|
this.updatePersistedState({ threadID, contactID });
|
|
1849
1857
|
this.newContactPromise = null;
|
|
1850
|
-
|
|
1858
|
+
AppContainer.debugLog(`${PREFIX} Started chat with contact ${contactID}`);
|
|
1851
1859
|
}
|
|
1852
1860
|
/**
|
|
1853
1861
|
* Handles a ChatEvent.MESSAGE_CREATED event from Nice.
|
|
1854
1862
|
*/
|
|
1855
1863
|
async handleMessageCreated(event) {
|
|
1856
|
-
|
|
1864
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1857
1865
|
const eventData = event.detail.data;
|
|
1858
1866
|
const { message, agentContact } = eventData;
|
|
1859
1867
|
await this.handleMessage(message, true, agentContact?.user);
|
|
@@ -1865,7 +1873,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1865
1873
|
async handleRecover(recovered) {
|
|
1866
1874
|
const { lastAgentMessageID } = this.persistedState();
|
|
1867
1875
|
const { messages } = recovered;
|
|
1868
|
-
|
|
1876
|
+
AppContainer.debugLog(`${PREFIX} Last agent message: ${lastAgentMessageID}`);
|
|
1869
1877
|
const lastIndex = messages.findIndex((message) => message.id === lastAgentMessageID);
|
|
1870
1878
|
if (lastIndex > 0) {
|
|
1871
1879
|
// Go backwards from the last index and handle each message.
|
|
@@ -1885,7 +1893,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1885
1893
|
const threadID = message.threadIdOnExternalPlatform;
|
|
1886
1894
|
const currentThreadID = this.persistedState().threadID;
|
|
1887
1895
|
if (!threadID || threadID !== currentThreadID) {
|
|
1888
|
-
|
|
1896
|
+
AppContainer.debugLog(`${PREFIX} Got message for thread ${threadID} but the current thread is ${currentThreadID}.`);
|
|
1889
1897
|
return;
|
|
1890
1898
|
}
|
|
1891
1899
|
const { isConnected } = this.serviceManager.store.getState().persistedToBrowserStorage.chatState.agentState;
|
|
@@ -1896,17 +1904,17 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1896
1904
|
}
|
|
1897
1905
|
const messageItems = [];
|
|
1898
1906
|
if (message.messageContent?.text) {
|
|
1899
|
-
messageItems.push(
|
|
1900
|
-
response_type:
|
|
1907
|
+
messageItems.push(AppContainer.assertType({
|
|
1908
|
+
response_type: AppContainer.MessageResponseTypes.TEXT,
|
|
1901
1909
|
text: message.messageContent.text,
|
|
1902
1910
|
}));
|
|
1903
1911
|
}
|
|
1904
1912
|
if (message.attachments?.length) {
|
|
1905
1913
|
message.attachments.forEach((attachment) => {
|
|
1906
|
-
messageItems.push(
|
|
1907
|
-
response_type:
|
|
1908
|
-
kind:
|
|
1909
|
-
button_type:
|
|
1914
|
+
messageItems.push(AppContainer.assertType({
|
|
1915
|
+
response_type: AppContainer.MessageResponseTypes.BUTTON,
|
|
1916
|
+
kind: AppContainer.ButtonItemKind.LINK,
|
|
1917
|
+
button_type: AppContainer.ButtonItemType.URL,
|
|
1910
1918
|
url: attachment.url,
|
|
1911
1919
|
label: attachment.friendlyName || attachment.fileName || attachment.filename,
|
|
1912
1920
|
}));
|
|
@@ -1925,23 +1933,23 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1925
1933
|
* Handles a ChatEvent.AGENT_TYPING_STARTED or ChatEvent.AGENT_TYPING_ENDED event from Nice.
|
|
1926
1934
|
*/
|
|
1927
1935
|
async handleAgentTyping(event, isTyping) {
|
|
1928
|
-
|
|
1936
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1929
1937
|
await this.callback.agentTyping(isTyping);
|
|
1930
1938
|
}
|
|
1931
1939
|
/**
|
|
1932
1940
|
* Handles a ChatEvent.CONTACT_STATUS_CHANGED event from Nice.
|
|
1933
1941
|
*/
|
|
1934
1942
|
async handleContactStatusChanged(event) {
|
|
1935
|
-
|
|
1943
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1936
1944
|
const eventData = event.detail.data;
|
|
1937
1945
|
const contactID = eventData.case.id;
|
|
1938
1946
|
const currentContactID = this.persistedState().contactID;
|
|
1939
1947
|
if (!contactID || contactID !== currentContactID) {
|
|
1940
|
-
|
|
1948
|
+
AppContainer.debugLog(`${PREFIX} Got contact ${contactID} status change but the current contact is ${currentContactID}.`);
|
|
1941
1949
|
return;
|
|
1942
1950
|
}
|
|
1943
1951
|
if (eventData.case?.status === 'closed') {
|
|
1944
|
-
|
|
1952
|
+
AppContainer.debugLog(`${PREFIX} Agent closed contact ${contactID}`, event);
|
|
1945
1953
|
await this.callback.agentEndedChat();
|
|
1946
1954
|
}
|
|
1947
1955
|
}
|
|
@@ -1949,24 +1957,24 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1949
1957
|
* Handles a ChatEvent.CONTACT_CREATED event from Nice.
|
|
1950
1958
|
*/
|
|
1951
1959
|
async handleContactCreated(event) {
|
|
1952
|
-
|
|
1960
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1953
1961
|
if (this.newContactPromise) {
|
|
1954
1962
|
this.newContactPromise.doResolve(event.detail.data?.case?.id);
|
|
1955
1963
|
}
|
|
1956
1964
|
else {
|
|
1957
|
-
|
|
1965
|
+
AppContainer.debugLog(`${PREFIX} Got a new contact but wasn't expecting one.`, event);
|
|
1958
1966
|
}
|
|
1959
1967
|
}
|
|
1960
1968
|
/**
|
|
1961
1969
|
* Handles a ChatEvent.ASSIGNED_AGENT_CHANGED event from Nice.
|
|
1962
1970
|
*/
|
|
1963
1971
|
async handleAgentChanged(event) {
|
|
1964
|
-
|
|
1972
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1965
1973
|
const eventData = event.detail.data;
|
|
1966
1974
|
const contactID = eventData.case.id;
|
|
1967
1975
|
const currentContactID = this.persistedState().contactID;
|
|
1968
1976
|
if (!contactID || contactID !== currentContactID) {
|
|
1969
|
-
|
|
1977
|
+
AppContainer.debugLog(`${PREFIX} Got contact ${contactID} status change but the current contact is ${currentContactID}.`);
|
|
1970
1978
|
return;
|
|
1971
1979
|
}
|
|
1972
1980
|
const { inboxAssignee, previousInboxAssignee } = eventData;
|
|
@@ -1984,7 +1992,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
1984
1992
|
* Handles a ChatEvent.SET_POSITION_IN_QUEUE event from Nice.
|
|
1985
1993
|
*/
|
|
1986
1994
|
async handlePositionInQueue(event) {
|
|
1987
|
-
|
|
1995
|
+
AppContainer.debugLog(`${PREFIX} ${event.type}`, event);
|
|
1988
1996
|
const eventDetail = event.detail;
|
|
1989
1997
|
await this.callback.updateAgentAvailability({ position_in_queue: eventDetail.data.positionInQueue || 1 });
|
|
1990
1998
|
}
|
|
@@ -2004,7 +2012,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
2004
2012
|
* Tells the service desk to terminate the chat.
|
|
2005
2013
|
*/
|
|
2006
2014
|
async endChat(info) {
|
|
2007
|
-
|
|
2015
|
+
AppContainer.debugLog(`${PREFIX} Ended chat`);
|
|
2008
2016
|
this.updatePersistedState({ threadID: null, contactID: null });
|
|
2009
2017
|
if (!info.endedByAgent) {
|
|
2010
2018
|
// Note: This Promise doesn't seem to ever resolve which is a bug in the Nice SDK so we're not going to await it.
|
|
@@ -2025,8 +2033,8 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
2025
2033
|
await this.thread.sendTextMessage(messageText);
|
|
2026
2034
|
}
|
|
2027
2035
|
catch (error) {
|
|
2028
|
-
this.callback.setErrorStatus({ type:
|
|
2029
|
-
|
|
2036
|
+
this.callback.setErrorStatus({ type: AppContainer.ErrorType.USER_MESSAGE, messageID });
|
|
2037
|
+
AppContainer.consoleError(`${PREFIX} Error sending message to agent`, error);
|
|
2030
2038
|
}
|
|
2031
2039
|
}
|
|
2032
2040
|
// Send any file uploads that were included.
|
|
@@ -2044,7 +2052,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
2044
2052
|
let errorMessage;
|
|
2045
2053
|
try {
|
|
2046
2054
|
const result = await this.thread.sendAttachments(transfer.files);
|
|
2047
|
-
|
|
2055
|
+
AppContainer.debugLog(`${PREFIX} Got sendAttachments result`, result);
|
|
2048
2056
|
if (isUploadFailResponse(result)) {
|
|
2049
2057
|
// The SDK types say this is supposed to be returned from sendAttachments but in testing, it seems that it is
|
|
2050
2058
|
// thrown instead so this is here just in case.
|
|
@@ -2052,7 +2060,7 @@ class NiceDFOServiceDesk extends ServiceDeskImpl.ServiceDeskImpl {
|
|
|
2052
2060
|
}
|
|
2053
2061
|
}
|
|
2054
2062
|
catch (error) {
|
|
2055
|
-
|
|
2063
|
+
AppContainer.consoleError(`${PREFIX} Error sending files to agent`, error);
|
|
2056
2064
|
errorMessage = this.formatUploadErrorMessage(error);
|
|
2057
2065
|
}
|
|
2058
2066
|
// The uploads either all succeed or they all fail. Only display the error message on the first file.
|