@webex/contact-center 3.12.0-webex-services-ready.4 → 3.13.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 (250) hide show
  1. package/.sdd/manifest.json +24 -13
  2. package/ai-docs/ARCHITECTURE.md +1 -1
  3. package/ai-docs/CONTRACTS.md +19 -3
  4. package/ai-docs/SECURITY.md +1 -1
  5. package/ai-docs/SERVICE_STATE.md +4 -0
  6. package/ai-docs/contact-center-spec.md +50 -6
  7. package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
  8. package/ai-docs/features/contact-owner-change-refactor.md +78 -0
  9. package/dist/cc.js +757 -22
  10. package/dist/cc.js.map +1 -1
  11. package/dist/config.js +7 -0
  12. package/dist/config.js.map +1 -1
  13. package/dist/constants.js +23 -2
  14. package/dist/constants.js.map +1 -1
  15. package/dist/index.js +34 -12
  16. package/dist/index.js.map +1 -1
  17. package/dist/metrics/MetricsManager.js +16 -0
  18. package/dist/metrics/MetricsManager.js.map +1 -1
  19. package/dist/metrics/behavioral-events.js +110 -0
  20. package/dist/metrics/behavioral-events.js.map +1 -1
  21. package/dist/metrics/constants.js +33 -0
  22. package/dist/metrics/constants.js.map +1 -1
  23. package/dist/services/AddressBook.js +18 -15
  24. package/dist/services/AddressBook.js.map +1 -1
  25. package/dist/services/AnswerCallOnWebexService.js +202 -0
  26. package/dist/services/AnswerCallOnWebexService.js.map +1 -0
  27. package/dist/services/ApiAiAssistant.js +221 -11
  28. package/dist/services/ApiAiAssistant.js.map +1 -1
  29. package/dist/services/EntryPoint.js +46 -68
  30. package/dist/services/EntryPoint.js.map +1 -1
  31. package/dist/services/Queue.js +27 -22
  32. package/dist/services/Queue.js.map +1 -1
  33. package/dist/services/WebCallingService.js +10 -2
  34. package/dist/services/WebCallingService.js.map +1 -1
  35. package/dist/services/WebexCrossClientService.js +225 -0
  36. package/dist/services/WebexCrossClientService.js.map +1 -0
  37. package/dist/services/WxAppTelephonyMercurySync.js +111 -0
  38. package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
  39. package/dist/services/config/Util.js +46 -46
  40. package/dist/services/config/Util.js.map +1 -1
  41. package/dist/services/config/constants.js +34 -77
  42. package/dist/services/config/constants.js.map +1 -1
  43. package/dist/services/config/index.js +100 -226
  44. package/dist/services/config/index.js.map +1 -1
  45. package/dist/services/config/types.js +51 -18
  46. package/dist/services/config/types.js.map +1 -1
  47. package/dist/services/constants.js +11 -1
  48. package/dist/services/constants.js.map +1 -1
  49. package/dist/services/core/Err.js.map +1 -1
  50. package/dist/services/core/Utils.js +25 -1
  51. package/dist/services/core/Utils.js.map +1 -1
  52. package/dist/services/core/WebexRequest.js +6 -2
  53. package/dist/services/core/WebexRequest.js.map +1 -1
  54. package/dist/services/core/aqm-reqs.js +17 -11
  55. package/dist/services/core/aqm-reqs.js.map +1 -1
  56. package/dist/services/core/constants.js +9 -1
  57. package/dist/services/core/constants.js.map +1 -1
  58. package/dist/services/core/types.js.map +1 -1
  59. package/dist/services/core/websocket/WebSocketManager.js +17 -1
  60. package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
  61. package/dist/services/task/Task.js +275 -8
  62. package/dist/services/task/Task.js.map +1 -1
  63. package/dist/services/task/TaskFactory.js +11 -6
  64. package/dist/services/task/TaskFactory.js.map +1 -1
  65. package/dist/services/task/TaskManager.js +590 -42
  66. package/dist/services/task/TaskManager.js.map +1 -1
  67. package/dist/services/task/TaskUtils.js +11 -1
  68. package/dist/services/task/TaskUtils.js.map +1 -1
  69. package/dist/services/task/WebexCallingUtils.js +70 -0
  70. package/dist/services/task/WebexCallingUtils.js.map +1 -0
  71. package/dist/services/task/constants.js +14 -2
  72. package/dist/services/task/constants.js.map +1 -1
  73. package/dist/services/task/contact.js +29 -0
  74. package/dist/services/task/contact.js.map +1 -1
  75. package/dist/services/task/digital/Digital.js +4 -3
  76. package/dist/services/task/digital/Digital.js.map +1 -1
  77. package/dist/services/task/state-machine/TaskStateMachine.js +162 -53
  78. package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -1
  79. package/dist/services/task/state-machine/actions.js +6 -1
  80. package/dist/services/task/state-machine/actions.js.map +1 -1
  81. package/dist/services/task/state-machine/guards.js +7 -10
  82. package/dist/services/task/state-machine/guards.js.map +1 -1
  83. package/dist/services/task/state-machine/types.js.map +1 -1
  84. package/dist/services/task/state-machine/uiControlsComputer.js +118 -18
  85. package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -1
  86. package/dist/services/task/types.js +47 -1
  87. package/dist/services/task/types.js.map +1 -1
  88. package/dist/services/task/voice/Voice.js +477 -17
  89. package/dist/services/task/voice/Voice.js.map +1 -1
  90. package/dist/services/task/voice/WebRTC.js +6 -3
  91. package/dist/services/task/voice/WebRTC.js.map +1 -1
  92. package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
  93. package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
  94. package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
  95. package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
  96. package/dist/services/wxAppDiagnosticLogging.js +159 -0
  97. package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
  98. package/dist/services/wxAppTelephonyUtils.js +19 -0
  99. package/dist/services/wxAppTelephonyUtils.js.map +1 -0
  100. package/dist/types/cc.d.ts +102 -8
  101. package/dist/types/config.d.ts +7 -0
  102. package/dist/types/constants.d.ts +21 -0
  103. package/dist/types/index.d.ts +34 -15
  104. package/dist/types/metrics/MetricsManager.d.ts +6 -0
  105. package/dist/types/metrics/constants.d.ts +31 -0
  106. package/dist/types/services/AddressBook.d.ts +2 -1
  107. package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
  108. package/dist/types/services/ApiAiAssistant.d.ts +48 -4
  109. package/dist/types/services/EntryPoint.d.ts +7 -5
  110. package/dist/types/services/Queue.d.ts +5 -3
  111. package/dist/types/services/WebexCrossClientService.d.ts +32 -0
  112. package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
  113. package/dist/types/services/config/Util.d.ts +4 -8
  114. package/dist/types/services/config/constants.d.ts +28 -76
  115. package/dist/types/services/config/index.d.ts +16 -64
  116. package/dist/types/services/config/types.d.ts +146 -173
  117. package/dist/types/services/constants.d.ts +9 -0
  118. package/dist/types/services/core/Err.d.ts +2 -0
  119. package/dist/types/services/core/Utils.d.ts +10 -0
  120. package/dist/types/services/core/WebexRequest.d.ts +1 -0
  121. package/dist/types/services/core/constants.d.ts +7 -0
  122. package/dist/types/services/core/types.d.ts +2 -0
  123. package/dist/types/services/task/Task.d.ts +34 -5
  124. package/dist/types/services/task/TaskFactory.d.ts +4 -2
  125. package/dist/types/services/task/TaskUtils.d.ts +6 -0
  126. package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
  127. package/dist/types/services/task/constants.d.ts +12 -0
  128. package/dist/types/services/task/contact.d.ts +4 -0
  129. package/dist/types/services/task/digital/Digital.d.ts +4 -3
  130. package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +304 -56
  131. package/dist/types/services/task/state-machine/guards.d.ts +6 -5
  132. package/dist/types/services/task/state-machine/types.d.ts +9 -1
  133. package/dist/types/services/task/types.d.ts +192 -5
  134. package/dist/types/services/task/voice/Voice.d.ts +68 -11
  135. package/dist/types/services/task/voice/WebRTC.d.ts +5 -4
  136. package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
  137. package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
  138. package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
  139. package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
  140. package/dist/types/types.d.ts +80 -13
  141. package/dist/types/utils/PageCache.d.ts +20 -3
  142. package/dist/types.js +54 -8
  143. package/dist/types.js.map +1 -1
  144. package/dist/utils/PageCache.js +19 -5
  145. package/dist/utils/PageCache.js.map +1 -1
  146. package/dist/webex.js +9 -1
  147. package/dist/webex.js.map +1 -1
  148. package/package.json +10 -9
  149. package/src/cc.ts +969 -38
  150. package/src/config.ts +7 -0
  151. package/src/constants.ts +24 -0
  152. package/src/index.ts +39 -10
  153. package/src/metrics/MetricsManager.ts +16 -0
  154. package/src/metrics/ai-docs/metrics-spec.md +138 -21
  155. package/src/metrics/behavioral-events.ts +112 -0
  156. package/src/metrics/constants.ts +36 -0
  157. package/src/services/AddressBook.ts +17 -6
  158. package/src/services/AnswerCallOnWebexService.ts +239 -0
  159. package/src/services/ApiAiAssistant.ts +297 -13
  160. package/src/services/EntryPoint.ts +59 -60
  161. package/src/services/Queue.ts +29 -12
  162. package/src/services/WebCallingService.ts +16 -2
  163. package/src/services/WebexCrossClientService.ts +298 -0
  164. package/src/services/WxAppTelephonyMercurySync.ts +142 -0
  165. package/src/services/agent/ai-docs/AGENTS.md +1 -1
  166. package/src/services/agent/ai-docs/agent-spec.md +1 -0
  167. package/src/services/ai-docs/AGENTS.md +10 -10
  168. package/src/services/ai-docs/services-spec.md +25 -5
  169. package/src/services/config/Util.ts +52 -82
  170. package/src/services/config/ai-docs/AGENTS.md +35 -40
  171. package/src/services/config/ai-docs/ARCHITECTURE.md +90 -103
  172. package/src/services/config/ai-docs/config-spec.md +132 -132
  173. package/src/services/config/constants.ts +39 -85
  174. package/src/services/config/index.ts +116 -277
  175. package/src/services/config/types.ts +140 -195
  176. package/src/services/constants.ts +10 -0
  177. package/src/services/core/Err.ts +1 -0
  178. package/src/services/core/Utils.ts +28 -0
  179. package/src/services/core/WebexRequest.ts +3 -1
  180. package/src/services/core/ai-docs/core-spec.md +25 -11
  181. package/src/services/core/aqm-reqs.ts +18 -12
  182. package/src/services/core/constants.ts +8 -0
  183. package/src/services/core/types.ts +33 -1
  184. package/src/services/core/websocket/WebSocketManager.ts +26 -2
  185. package/src/services/task/Task.ts +386 -12
  186. package/src/services/task/TaskFactory.ts +33 -6
  187. package/src/services/task/TaskManager.ts +857 -41
  188. package/src/services/task/TaskUtils.ts +13 -0
  189. package/src/services/task/WebexCallingUtils.ts +136 -0
  190. package/src/services/task/ai-docs/ARCHITECTURE.md +1 -0
  191. package/src/services/task/ai-docs/task-spec.md +190 -8
  192. package/src/services/task/constants.ts +13 -0
  193. package/src/services/task/contact.ts +30 -0
  194. package/src/services/task/digital/Digital.ts +11 -4
  195. package/src/services/task/state-machine/TaskStateMachine.ts +235 -81
  196. package/src/services/task/state-machine/actions.ts +5 -2
  197. package/src/services/task/state-machine/ai-docs/AGENTS.md +6 -4
  198. package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +35 -16
  199. package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +103 -33
  200. package/src/services/task/state-machine/guards.ts +7 -10
  201. package/src/services/task/state-machine/types.ts +16 -1
  202. package/src/services/task/state-machine/uiControlsComputer.ts +206 -32
  203. package/src/services/task/types.ts +269 -4
  204. package/src/services/task/voice/Voice.ts +625 -17
  205. package/src/services/task/voice/WebRTC.ts +11 -4
  206. package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
  207. package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
  208. package/src/services/wxAppDiagnosticLogging.ts +286 -0
  209. package/src/services/wxAppTelephonyUtils.ts +14 -0
  210. package/src/types.ts +108 -13
  211. package/src/utils/AGENTS.md +21 -10
  212. package/src/utils/PageCache.ts +38 -5
  213. package/src/utils/ai-docs/utils-spec.md +21 -11
  214. package/src/webex.js +8 -0
  215. package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
  216. package/test/unit/spec/cc.ts +3408 -152
  217. package/test/unit/spec/index.ts +885 -0
  218. package/test/unit/spec/metrics/MetricsManager.ts +25 -0
  219. package/test/unit/spec/metrics/behavioral-events.ts +60 -0
  220. package/test/unit/spec/services/AddressBook.ts +37 -6
  221. package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
  222. package/test/unit/spec/services/ApiAiAssistant.ts +269 -8
  223. package/test/unit/spec/services/EntryPoint.ts +87 -40
  224. package/test/unit/spec/services/Queue.ts +123 -12
  225. package/test/unit/spec/services/WebCallingService.ts +38 -0
  226. package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
  227. package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
  228. package/test/unit/spec/services/config/Util.ts +501 -0
  229. package/test/unit/spec/services/config/index.ts +313 -543
  230. package/test/unit/spec/services/core/Utils.ts +22 -0
  231. package/test/unit/spec/services/core/WebexRequest.ts +8 -7
  232. package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
  233. package/test/unit/spec/services/core/websocket/WebSocketManager.ts +64 -14
  234. package/test/unit/spec/services/task/Task.ts +2257 -11
  235. package/test/unit/spec/services/task/TaskFactory.ts +56 -2
  236. package/test/unit/spec/services/task/TaskManager.ts +5559 -1493
  237. package/test/unit/spec/services/task/TaskUtils.ts +72 -0
  238. package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
  239. package/test/unit/spec/services/task/contact.ts +33 -0
  240. package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +1501 -92
  241. package/test/unit/spec/services/task/state-machine/guards.ts +210 -8
  242. package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +445 -7
  243. package/test/unit/spec/services/task/voice/Voice.ts +1710 -4
  244. package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
  245. package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
  246. package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
  247. package/test/unit/spec/wellnessSampleUtils.ts +288 -0
  248. package/typedoc.md +1 -1
  249. package/umd/contact-center.min.js +2 -2
  250. package/umd/contact-center.min.js.map +1 -1
@@ -11,6 +11,7 @@ import {
11
11
  DESTINATION_TYPE,
12
12
  TASK_EVENTS,
13
13
  TaskUIControls,
14
+ DropConferenceParticipantPayload,
14
15
  ConsultEndPayload,
15
16
  ConsultPayload,
16
17
  ConsultTransferPayLoad,
@@ -19,9 +20,22 @@ import {
19
20
  TASK_CHANNEL_TYPE,
20
21
  VOICE_VARIANT,
21
22
  CallId,
23
+ AISummaryAction,
24
+ AISummary,
25
+ AISummaryResponse,
26
+ AISummaryFeatureEnablement,
27
+ AISummaryCapabilities,
28
+ TaskToggleMuteOptions,
29
+ TaskTransmitDtmfOptions,
22
30
  } from './types';
23
- import {METHODS} from './constants';
24
- import {CC_FILE, TASK_FILE} from '../../constants';
31
+ import {AI_SUMMARY_DURATION_MS, ENTRY_POINT_TRANSFER_DESTINATION_TYPE, METHODS} from './constants';
32
+ import {
33
+ AI_ASSISTANT_CLIENT_TYPE,
34
+ AI_SUMMARY_ERROR_CODES,
35
+ AI_SUMMARY_INVALID_RESPONSE_PAYLOAD,
36
+ CC_FILE,
37
+ TASK_FILE,
38
+ } from '../../constants';
25
39
  import {getErrorDetails} from '../core/Utils';
26
40
  import routingContact from './contact';
27
41
  import MetricsManager from '../../metrics/MetricsManager';
@@ -42,7 +56,10 @@ import {
42
56
  haveUIControlsChanged,
43
57
  } from './state-machine/uiControlsComputer';
44
58
  import AutoWrapup from './AutoWrapup';
45
- import {WrapupData} from '../config/types';
59
+ import type {WrapupData} from '../config/types';
60
+ import {AIAssistantEventName, AIAssistantEventType} from '../../types';
61
+ import {createSummaryError} from './TaskUtils';
62
+ import type ApiAIAssistant from '../ApiAiAssistant';
46
63
 
47
64
  type UIControlConfigInput = Omit<UIControlConfig, 'channelType'> & {
48
65
  channelType?: UIControlConfig['channelType'];
@@ -61,13 +78,21 @@ export default abstract class Task extends EventEmitter implements ITask {
61
78
  protected wrapupData?: WrapupData;
62
79
  public autoWrapup?: AutoWrapup;
63
80
  protected agentId?: string;
81
+ protected agentName?: string;
82
+ private apiAIAssistant?: ApiAIAssistant;
83
+ public aiSummaryCapabilities: Readonly<AISummaryCapabilities> = {
84
+ midCallEnabled: false,
85
+ postCallEnabled: false,
86
+ };
64
87
 
65
88
  constructor(
66
89
  contact: ReturnType<typeof routingContact>,
67
90
  data: TaskData,
68
91
  uiControlConfig: UIControlConfigInput,
69
92
  wrapupData?: WrapupData,
70
- agentId?: string
93
+ agentId?: string,
94
+ agentName?: string,
95
+ apiAIAssistant?: ApiAIAssistant
71
96
  ) {
72
97
  super();
73
98
  this.contact = contact;
@@ -77,6 +102,8 @@ export default abstract class Task extends EventEmitter implements ITask {
77
102
  this.uiControlConfig = {...uiControlConfig, channelType, agentId};
78
103
  this.wrapupData = wrapupData;
79
104
  this.agentId = agentId;
105
+ this.agentName = agentName;
106
+ this.apiAIAssistant = apiAIAssistant;
80
107
  this.metricsManager = MetricsManager.getInstance();
81
108
  this.webCallMap = {};
82
109
  this.currentUiControls = getDefaultUIControls();
@@ -141,6 +168,14 @@ export default abstract class Task extends EventEmitter implements ITask {
141
168
  this.unsupportedMethodError('consultConference');
142
169
  }
143
170
 
171
+ public async dropConferenceParticipant(
172
+ // The base task preserves the public signature; Voice provides the implementation.
173
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
174
+ payload: DropConferenceParticipantPayload
175
+ ): Promise<TaskResponse> {
176
+ this.unsupportedMethodError(METHODS.DROP_CONFERENCE_PARTICIPANT);
177
+ }
178
+
144
179
  public async exitConference(): Promise<TaskResponse> {
145
180
  this.unsupportedMethodError('exitConference');
146
181
  }
@@ -153,10 +188,20 @@ export default abstract class Task extends EventEmitter implements ITask {
153
188
  this.unsupportedMethodError('switchCall');
154
189
  }
155
190
 
156
- public async toggleMute(): Promise<void> {
191
+ public async toggleMute(options?: TaskToggleMuteOptions): Promise<void> {
192
+ if (options) {
193
+ // parameter intentionally unused
194
+ }
157
195
  this.unsupportedMethodError('toggleMute');
158
196
  }
159
197
 
198
+ public async transmitDtmf(options: TaskTransmitDtmfOptions): Promise<void> {
199
+ if (options) {
200
+ // parameter intentionally unused
201
+ }
202
+ this.unsupportedMethodError('transmitDtmf');
203
+ }
204
+
160
205
  public unregisterWebCallListeners(): void {
161
206
  // Default implementation - child classes can override
162
207
  LoggerProxy.log('unregisterWebCallListeners called', {
@@ -195,6 +240,285 @@ export default abstract class Task extends EventEmitter implements ITask {
195
240
  this.unsupportedMethodError('holdResume');
196
241
  }
197
242
 
243
+ public setFeatureEnablement(enablement: AISummaryFeatureEnablement): void {
244
+ if (enablement.interactionId !== this.data.interactionId) {
245
+ return;
246
+ }
247
+
248
+ this.aiSummaryCapabilities = {
249
+ midCallEnabled: enablement.midCallEnabled === true,
250
+ postCallEnabled: enablement.postCallEnabled === true,
251
+ };
252
+ }
253
+
254
+ public clearFeatureEnablement(): void {
255
+ this.aiSummaryCapabilities = {
256
+ midCallEnabled: false,
257
+ postCallEnabled: false,
258
+ };
259
+ }
260
+
261
+ public async requestPostCallSummary(): Promise<AISummary> {
262
+ const metricFields: Record<string, unknown> = {operation: METHODS.REQUEST_POST_CALL_SUMMARY};
263
+
264
+ try {
265
+ this.metricsManager.timeEvent([
266
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_POST_CALL_SUCCESS,
267
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_POST_CALL_FAILED,
268
+ ]);
269
+
270
+ const interactionId = this.data.interactionId;
271
+ const conversationId = this.data.interaction?.mainInteractionId || interactionId;
272
+ Object.assign(metricFields, {conversationId, interactionId});
273
+
274
+ if (
275
+ !this.apiAIAssistant ||
276
+ this.apiAIAssistant.aiFeature?.generatedSummaries?.wrapUpSummariesEnabled !== true ||
277
+ !this.aiSummaryCapabilities.postCallEnabled
278
+ ) {
279
+ throw createSummaryError(AI_SUMMARY_ERROR_CODES.POST_CALL_SUMMARY_DISABLED);
280
+ }
281
+
282
+ const result = await this.apiAIAssistant.requestAndWaitForRtd<AISummary>({
283
+ correlationId: conversationId,
284
+ rtdEventType: 'POST_CALL_SUMMARY',
285
+ timeoutMs: AI_SUMMARY_DURATION_MS,
286
+ createTimeoutError: () =>
287
+ createSummaryError(AI_SUMMARY_ERROR_CODES.POST_CALL_SUMMARY_TIMEOUT),
288
+ agentId: this.agentId as string,
289
+ interactionId,
290
+ eventType: AIAssistantEventType.CTI_EVENT,
291
+ eventName: AIAssistantEventName.GET_POST_CALL_SUMMARY,
292
+ eventMetaData: {
293
+ conversationId,
294
+ clientType: AI_ASSISTANT_CLIENT_TYPE,
295
+ },
296
+ timeout: AI_SUMMARY_DURATION_MS,
297
+ });
298
+
299
+ this.metricsManager.trackEvent(
300
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_POST_CALL_SUCCESS,
301
+ {taskId: this.data?.interactionId, ...metricFields},
302
+ ['operational']
303
+ );
304
+
305
+ return result;
306
+ } catch (error) {
307
+ this.metricsManager.trackEvent(
308
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_POST_CALL_FAILED,
309
+ {
310
+ taskId: this.data?.interactionId,
311
+ ...metricFields,
312
+ failureCode: Task.getAISummaryFailureCode(error),
313
+ },
314
+ ['operational']
315
+ );
316
+ throw error;
317
+ }
318
+ }
319
+
320
+ public async sendPostCallSummaryResponse(response: AISummaryResponse): Promise<void> {
321
+ const metricFields: Record<string, unknown> = {
322
+ operation: METHODS.SEND_POST_CALL_SUMMARY_RESPONSE,
323
+ };
324
+
325
+ try {
326
+ this.metricsManager.timeEvent([
327
+ METRIC_EVENT_NAMES.AI_SUMMARY_POST_CALL_RESPONSE_SUCCESS,
328
+ METRIC_EVENT_NAMES.AI_SUMMARY_POST_CALL_RESPONSE_FAILED,
329
+ ]);
330
+ const interactionId = this.data.interactionId;
331
+ const conversationId = this.data.interaction?.mainInteractionId || interactionId;
332
+ Object.assign(metricFields, {conversationId, interactionId});
333
+
334
+ const publishTimestamp = Date.now();
335
+ const eventName = AIAssistantEventName.POST_CALL_SUMMARY_RESPONSE;
336
+ const eventPayload = {
337
+ conversationId,
338
+ clientType: AI_ASSISTANT_CLIENT_TYPE,
339
+ action: eventName,
340
+ summary: response.summary,
341
+ numberOfTimesViewed: response.numberOfTimesViewed,
342
+ numberOfTimesEdited: response.numberOfTimesEdited,
343
+ numberOfTimesCopied: response.numberOfTimesCopied,
344
+ feedback: response.feedback,
345
+ state: response.state,
346
+ wrapUpCode: response.wrapUpCode,
347
+ };
348
+ await this.apiAIAssistant.sendEvent(
349
+ this.agentId as string,
350
+ interactionId,
351
+ AIAssistantEventType.CTI_EVENT,
352
+ eventName,
353
+ eventPayload,
354
+ undefined,
355
+ undefined,
356
+ publishTimestamp,
357
+ AI_SUMMARY_DURATION_MS
358
+ );
359
+
360
+ this.metricsManager.trackEvent(
361
+ METRIC_EVENT_NAMES.AI_SUMMARY_POST_CALL_RESPONSE_SUCCESS,
362
+ {taskId: this.data?.interactionId, ...metricFields},
363
+ ['operational']
364
+ );
365
+ } catch (error) {
366
+ this.metricsManager.trackEvent(
367
+ METRIC_EVENT_NAMES.AI_SUMMARY_POST_CALL_RESPONSE_FAILED,
368
+ {
369
+ taskId: this.data?.interactionId,
370
+ ...metricFields,
371
+ failureCode: Task.getAISummaryFailureCode(error),
372
+ },
373
+ ['operational']
374
+ );
375
+ throw error;
376
+ }
377
+ }
378
+
379
+ public async requestMidCallSummary(action: AISummaryAction): Promise<AISummary> {
380
+ const metricFields: Record<string, unknown> = {
381
+ operation: METHODS.REQUEST_MID_CALL_SUMMARY,
382
+ actionType: action,
383
+ };
384
+
385
+ try {
386
+ this.metricsManager.timeEvent([
387
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_MID_CALL_SUCCESS,
388
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_MID_CALL_FAILED,
389
+ ]);
390
+
391
+ const interactionId = this.data.interactionId;
392
+ const conversationId = this.data.interaction?.mainInteractionId || interactionId;
393
+ Object.assign(metricFields, {conversationId, interactionId});
394
+
395
+ if (
396
+ !this.apiAIAssistant ||
397
+ this.apiAIAssistant.aiFeature?.generatedSummaries?.consultTransferSummariesEnabled !==
398
+ true ||
399
+ !this.aiSummaryCapabilities.midCallEnabled
400
+ ) {
401
+ throw createSummaryError(AI_SUMMARY_ERROR_CODES.MID_CALL_SUMMARY_DISABLED);
402
+ }
403
+
404
+ const eventName =
405
+ action === 'CONSULT'
406
+ ? AIAssistantEventName.GET_MID_CALL_CONSULT_SUMMARY
407
+ : AIAssistantEventName.GET_MID_CALL_TRANSFER_SUMMARY;
408
+ const result = await this.apiAIAssistant.requestAndWaitForRtd<AISummary>({
409
+ correlationId: conversationId,
410
+ rtdEventType: 'MID_CALL_SUMMARY',
411
+ timeoutMs: AI_SUMMARY_DURATION_MS,
412
+ createTimeoutError: () =>
413
+ createSummaryError(AI_SUMMARY_ERROR_CODES.MID_CALL_SUMMARY_TIMEOUT),
414
+ agentId: this.agentId as string,
415
+ interactionId,
416
+ eventType: AIAssistantEventType.CTI_EVENT,
417
+ eventName,
418
+ eventMetaData: {
419
+ conversationId,
420
+ clientType: AI_ASSISTANT_CLIENT_TYPE,
421
+ },
422
+ timeout: AI_SUMMARY_DURATION_MS,
423
+ });
424
+
425
+ this.metricsManager.trackEvent(
426
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_MID_CALL_SUCCESS,
427
+ {taskId: this.data?.interactionId, ...metricFields},
428
+ ['operational']
429
+ );
430
+
431
+ return result;
432
+ } catch (error) {
433
+ this.metricsManager.trackEvent(
434
+ METRIC_EVENT_NAMES.AI_SUMMARY_GET_MID_CALL_FAILED,
435
+ {
436
+ taskId: this.data?.interactionId,
437
+ ...metricFields,
438
+ failureCode: Task.getAISummaryFailureCode(error),
439
+ },
440
+ ['operational']
441
+ );
442
+ throw error;
443
+ }
444
+ }
445
+
446
+ public async sendMidCallSummaryResponse(
447
+ response: AISummaryResponse,
448
+ action: AISummaryAction
449
+ ): Promise<void> {
450
+ const metricFields: Record<string, unknown> = {
451
+ operation: METHODS.SEND_MID_CALL_SUMMARY_RESPONSE,
452
+ actionType: action,
453
+ };
454
+
455
+ try {
456
+ this.metricsManager.timeEvent([
457
+ METRIC_EVENT_NAMES.AI_SUMMARY_MID_CALL_RESPONSE_SUCCESS,
458
+ METRIC_EVENT_NAMES.AI_SUMMARY_MID_CALL_RESPONSE_FAILED,
459
+ ]);
460
+ const interactionId = this.data.interactionId;
461
+ const conversationId = this.data.interaction?.mainInteractionId || interactionId;
462
+ Object.assign(metricFields, {conversationId, interactionId});
463
+
464
+ const publishTimestamp = Date.now();
465
+ const eventName =
466
+ action === 'CONSULT'
467
+ ? AIAssistantEventName.MID_CALL_CONSULT_SUMMARY_RESPONSE
468
+ : AIAssistantEventName.MID_CALL_TRANSFER_SUMMARY_RESPONSE;
469
+ const eventPayload = {
470
+ conversationId,
471
+ clientType: AI_ASSISTANT_CLIENT_TYPE,
472
+ action: eventName,
473
+ summary: response.summary,
474
+ numberOfTimesViewed: response.numberOfTimesViewed,
475
+ numberOfTimesEdited: response.numberOfTimesEdited,
476
+ numberOfTimesCopied: response.numberOfTimesCopied,
477
+ feedback: response.feedback,
478
+ state: response.state,
479
+ agentName: this.agentName ?? '',
480
+ };
481
+ await this.apiAIAssistant.sendEvent(
482
+ this.agentId as string,
483
+ interactionId,
484
+ AIAssistantEventType.CTI_EVENT,
485
+ eventName,
486
+ eventPayload,
487
+ undefined,
488
+ undefined,
489
+ publishTimestamp,
490
+ AI_SUMMARY_DURATION_MS
491
+ );
492
+
493
+ this.metricsManager.trackEvent(
494
+ METRIC_EVENT_NAMES.AI_SUMMARY_MID_CALL_RESPONSE_SUCCESS,
495
+ {taskId: this.data?.interactionId, ...metricFields},
496
+ ['operational']
497
+ );
498
+ } catch (error) {
499
+ this.metricsManager.trackEvent(
500
+ METRIC_EVENT_NAMES.AI_SUMMARY_MID_CALL_RESPONSE_FAILED,
501
+ {
502
+ taskId: this.data?.interactionId,
503
+ ...metricFields,
504
+ failureCode: Task.getAISummaryFailureCode(error),
505
+ },
506
+ ['operational']
507
+ );
508
+ throw error;
509
+ }
510
+ }
511
+
512
+ private static getAISummaryFailureCode(error: unknown): string {
513
+ const errorCode = (error as {data?: {errorCode?: unknown}})?.data?.errorCode;
514
+
515
+ if (typeof errorCode === 'string') {
516
+ return errorCode;
517
+ }
518
+
519
+ return AI_SUMMARY_INVALID_RESPONSE_PAYLOAD;
520
+ }
521
+
198
522
  /**
199
523
  * Latest UI controls derived from state machine state and context.
200
524
  */
@@ -268,6 +592,36 @@ export default abstract class Task extends EventEmitter implements ITask {
268
592
  *
269
593
  * @returns UI control states for all task actions
270
594
  */
595
+ /**
596
+ * Update wxApp thick-client answer flag at runtime (Voice overrides).
597
+ */
598
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
599
+ public setEnableWxBetterTogether(_enabled: boolean): void {
600
+ // no-op for non-voice tasks
601
+ }
602
+
603
+ /**
604
+ * Apply wxApp mute state from external sync (Voice overrides).
605
+ */
606
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
607
+ public applyWxAppMuteStateFromSync(_incomingCallId: string, _muted: boolean): void {
608
+ // no-op for non-voice tasks
609
+ }
610
+
611
+ /**
612
+ * Hook for post-assign wxApp sync (Voice overrides).
613
+ */
614
+ protected onTaskAssigned(): void {
615
+ // no-op by default
616
+ }
617
+
618
+ /**
619
+ * Hook for post-hydrate wxApp sync (Voice overrides).
620
+ */
621
+ protected onTaskHydrated(): void {
622
+ // no-op by default
623
+ }
624
+
271
625
  protected computeUIControls(): TaskUIControls {
272
626
  const snapshot = this.stateMachineService?.getSnapshot?.();
273
627
 
@@ -277,8 +631,12 @@ export default abstract class Task extends EventEmitter implements ITask {
277
631
 
278
632
  const currentState = snapshot.value as TaskState;
279
633
  const context = snapshot.context as TaskContext;
634
+ const mergedContext: TaskContext = {
635
+ ...context,
636
+ uiControlConfig: {...context.uiControlConfig, ...this.uiControlConfig},
637
+ };
280
638
 
281
- const uiControls = computeUIControls(currentState, context, this.data);
639
+ const uiControls = computeUIControls(currentState, mergedContext, this.data);
282
640
 
283
641
  return uiControls;
284
642
  }
@@ -427,9 +785,16 @@ export default abstract class Task extends EventEmitter implements ITask {
427
785
  emitTaskCampaignPreviewRemoveFailed: this.createEmitSelfAction(
428
786
  TASK_EVENTS.TASK_CAMPAIGN_PREVIEW_REMOVE_FAILED
429
787
  ),
430
- emitTaskHydrate: this.createEmitSelfAction(TASK_EVENTS.TASK_HYDRATE, {
431
- updateTaskData: true,
432
- }),
788
+ emitTaskHydrate: ({event}: TaskActionArgs) => {
789
+ this.updateTaskFromEvent(event);
790
+ LoggerProxy.info(`Emitting task event ${TASK_EVENTS.TASK_HYDRATE}`, {
791
+ module: TASK_FILE,
792
+ method: 'emitTaskEvent',
793
+ interactionId: this.data?.interactionId,
794
+ });
795
+ this.emit(TASK_EVENTS.TASK_HYDRATE, this);
796
+ this.onTaskHydrated();
797
+ },
433
798
  emitTaskOfferContact: this.createEmitSelfAction(TASK_EVENTS.TASK_OFFER_CONTACT, {
434
799
  updateTaskData: true,
435
800
  }),
@@ -437,6 +802,7 @@ export default abstract class Task extends EventEmitter implements ITask {
437
802
  this.updateTaskFromEvent(event);
438
803
  this.emit(TASK_EVENTS.TASK_ASSIGNED, this);
439
804
  this.emit(TASK_EVENTS.TASK_MULTI_LOGIN_HYDRATE, this);
805
+ this.onTaskAssigned();
440
806
  },
441
807
  emitTaskEnd: this.createEmitSelfAction(TASK_EVENTS.TASK_END, {updateTaskData: true}),
442
808
  emitTaskOfferConsult: this.createEmitSelfAction(TASK_EVENTS.TASK_OFFER_CONSULT, {
@@ -587,7 +953,7 @@ export default abstract class Task extends EventEmitter implements ITask {
587
953
  * @param methodName - The name of the method that is unsupported
588
954
  * @throws Error
589
955
  */
590
- protected unsupportedMethodError(methodName: string) {
956
+ protected unsupportedMethodError(methodName: string): never {
591
957
  LoggerProxy.error(`Unsupported operation`, {
592
958
  module: 'TASK',
593
959
  method: methodName,
@@ -672,10 +1038,18 @@ export default abstract class Task extends EventEmitter implements ITask {
672
1038
  METRIC_EVENT_NAMES.TASK_TRANSFER_FAILED,
673
1039
  ]);
674
1040
  let result: TaskResponse;
675
- if (transferPayload.destinationType === DESTINATION_TYPE.QUEUE) {
1041
+ const isQueueTransfer = transferPayload.destinationType === DESTINATION_TYPE.QUEUE;
1042
+ const isEntryPointTransfer = transferPayload.destinationType === DESTINATION_TYPE.ENTRYPOINT;
1043
+
1044
+ if (isQueueTransfer || isEntryPointTransfer) {
676
1045
  result = await this.contact.vteamTransfer({
677
1046
  interactionId: this.data.interactionId,
678
- data: transferPayload,
1047
+ data: {
1048
+ ...transferPayload,
1049
+ destinationType: isEntryPointTransfer
1050
+ ? ENTRY_POINT_TRANSFER_DESTINATION_TYPE
1051
+ : DESTINATION_TYPE.QUEUE,
1052
+ },
679
1053
  });
680
1054
  } else {
681
1055
  result = await this.contact.blindTransfer({
@@ -1,12 +1,14 @@
1
1
  import routingContact from './contact';
2
2
  import WebCallingService from '../WebCallingService';
3
+ import AnswerCallOnWebexService from '../AnswerCallOnWebexService';
3
4
  import Task from './Task';
4
5
  import Voice from './voice/Voice';
5
6
  import WebRTC from './voice/WebRTC';
6
7
  import Digital from './digital/Digital';
7
8
  import {MEDIA_CHANNEL, TaskData} from './types';
8
9
  import {ConfigFlags, LoginOption} from '../../types';
9
- import {WrapupData} from '../config/types';
10
+ import type {WrapupData} from '../config/types';
11
+ import type ApiAIAssistant from '../ApiAiAssistant';
10
12
 
11
13
  export default class TaskFactory {
12
14
  /**
@@ -18,15 +20,22 @@ export default class TaskFactory {
18
20
  data: TaskData,
19
21
  configFlags: ConfigFlags,
20
22
  wrapupData?: WrapupData,
21
- agentId?: string
23
+ agentId?: string,
24
+ agentName?: string,
25
+ answerCallOnWebexService?: AnswerCallOnWebexService,
26
+ apiAIAssistant?: ApiAIAssistant
22
27
  ): Task {
23
28
  const mediaType = data.interaction.mediaType ?? MEDIA_CHANNEL.TELEPHONY;
24
- const {isEndTaskEnabled, isEndConsultEnabled} = configFlags;
29
+ const {isEndTaskEnabled, isEndConsultEnabled, consultTransfer} = configFlags;
25
30
  const recordingEnabled = data?.interaction?.callProcessingDetails?.pauseResumeEnabled ?? true;
26
31
  const voiceControlOptions = {
27
32
  isEndTaskEnabled,
28
33
  isEndConsultEnabled,
29
34
  isRecordingEnabled: recordingEnabled,
35
+ enableWxBetterTogether: configFlags.enableWxBetterTogether ?? false,
36
+ answerCallOnWebexService,
37
+ getUsersubPublished: configFlags.getWxAppUsersubPublished,
38
+ consultTransferConfig: consultTransfer,
30
39
  };
31
40
  switch (mediaType) {
32
41
  case MEDIA_CHANNEL.TELEPHONY:
@@ -37,16 +46,34 @@ export default class TaskFactory {
37
46
  data,
38
47
  voiceControlOptions,
39
48
  wrapupData,
40
- agentId
49
+ agentId,
50
+ agentName,
51
+ apiAIAssistant
41
52
  );
42
53
  }
43
54
 
44
- return new Voice(contact, data, voiceControlOptions, wrapupData, agentId);
55
+ return new Voice(
56
+ contact,
57
+ data,
58
+ voiceControlOptions,
59
+ wrapupData,
60
+ agentId,
61
+ agentName,
62
+ apiAIAssistant
63
+ );
45
64
 
46
65
  case MEDIA_CHANNEL.CHAT:
47
66
  case MEDIA_CHANNEL.EMAIL:
48
67
  case MEDIA_CHANNEL.SOCIAL:
49
- return new Digital(contact, data, wrapupData, agentId);
68
+ return new Digital(
69
+ contact,
70
+ data,
71
+ wrapupData,
72
+ agentId,
73
+ consultTransfer,
74
+ agentName,
75
+ apiAIAssistant
76
+ );
50
77
 
51
78
  default:
52
79
  throw new Error(`Unknown media type: ${mediaType}`);