@microsoft/omnichannel-chat-sdk 1.2.1-main.f777b2c → 1.3.1-main.2674439

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 (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +14 -3
  3. package/lib/OmnichannelChatSDK.d.ts +5 -1
  4. package/lib/OmnichannelChatSDK.js +287 -180
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +1 -1
  7. package/lib/config/settings.js +1 -1
  8. package/lib/core/ChatSDKErrors.d.ts +2 -0
  9. package/lib/core/ChatSDKErrors.js +2 -0
  10. package/lib/core/ChatSDKErrors.js.map +1 -1
  11. package/lib/core/ChatSDKExceptionDetails.d.ts +1 -0
  12. package/lib/core/GetAgentAvailabilityOptionalParams.d.ts +13 -0
  13. package/lib/core/GetAgentAvailabilityOptionalParams.js +3 -0
  14. package/lib/core/GetAgentAvailabilityOptionalParams.js.map +1 -0
  15. package/lib/core/PostChatContext.d.ts +2 -0
  16. package/lib/core/StartChatOptionalParams.d.ts +4 -0
  17. package/lib/core/messaging/ACSClient.js +5 -0
  18. package/lib/core/messaging/ACSClient.js.map +1 -1
  19. package/lib/external/ACSAdapter/AMSFileManager.js +2 -1
  20. package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
  21. package/lib/telemetry/AriaTelemetry.d.ts +1 -0
  22. package/lib/telemetry/AriaTelemetry.js +49 -0
  23. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  24. package/lib/telemetry/ScenarioType.d.ts +1 -0
  25. package/lib/telemetry/ScenarioType.js +1 -0
  26. package/lib/telemetry/ScenarioType.js.map +1 -1
  27. package/lib/telemetry/TelemetryEvent.d.ts +3 -1
  28. package/lib/telemetry/TelemetryEvent.js +2 -0
  29. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  30. package/lib/tsconfig.tsbuildinfo +172 -98
  31. package/lib/utils/WebUtils.d.ts +2 -2
  32. package/lib/utils/WebUtils.js +30 -4
  33. package/lib/utils/WebUtils.js.map +1 -1
  34. package/lib/utils/chatAdapterCreators.js +67 -30
  35. package/lib/utils/chatAdapterCreators.js.map +1 -1
  36. package/lib/utils/location.d.ts +7 -0
  37. package/lib/utils/location.js +96 -0
  38. package/lib/utils/location.js.map +1 -0
  39. package/lib/utils/loggers.d.ts +16 -0
  40. package/lib/utils/loggers.js +69 -1
  41. package/lib/utils/loggers.js.map +1 -1
  42. package/lib/utils/sleep.d.ts +2 -0
  43. package/lib/utils/sleep.js +5 -0
  44. package/lib/utils/sleep.js.map +1 -0
  45. package/package.json +3 -3
@@ -58,6 +58,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
58
58
  var loggers_1 = require("./utils/loggers");
59
59
  var ACSClient_1 = require("./core/messaging/ACSClient");
60
60
  var ocsdk_1 = require("@microsoft/ocsdk");
61
+ var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
61
62
  var locale_1 = require("./utils/locale");
62
63
  var WebUtils_1 = require("./utils/WebUtils");
63
64
  var platform_1 = require("./utils/platform");
@@ -67,7 +68,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
67
68
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
68
69
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
69
70
  var ChatSDKErrors_1 = require("./core/ChatSDKErrors");
70
- var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
71
71
  var ConversationMode_1 = require("./core/ConversationMode");
72
72
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
73
73
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
@@ -87,13 +87,15 @@ var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
87
87
  var createTelemetry_1 = require("./utils/createTelemetry");
88
88
  var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
89
89
  var MessageTags_1 = require("./core/messaging/MessageTags");
90
+ var location_1 = require("./utils/location");
90
91
  var utilities_1 = require("./utils/utilities");
91
92
  var urlResolvers_1 = require("./utils/urlResolvers");
92
93
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
93
94
  var OmnichannelChatSDK = /** @class */ (function () {
94
95
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
96
+ var _this = this;
95
97
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
96
- var _a, _b, _c, _d, _e, _f, _g, _h;
98
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
97
99
  this.ACSClient = null;
98
100
  this.AMSClient = null;
99
101
  this.authSettings = null;
@@ -106,17 +108,70 @@ var OmnichannelChatSDK = /** @class */ (function () {
106
108
  this.acsClientLogger = null;
107
109
  this.acsAdapterLogger = null;
108
110
  this.callingSdkLogger = null;
111
+ this.amsClientLogger = null;
109
112
  this.isPersistentChat = false;
110
113
  this.isChatReconnect = false;
111
114
  this.reconnectId = null;
112
115
  this.refreshTokenTimer = null;
116
+ this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams) {
117
+ requestOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(_this.localeId);
118
+ if (optionalParams.customContext) {
119
+ requestOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
120
+ }
121
+ if (optionalParams.browser) {
122
+ requestOptionalParams.initContext.browser = optionalParams.browser;
123
+ }
124
+ if (optionalParams.os) {
125
+ requestOptionalParams.initContext.os = optionalParams.os;
126
+ }
127
+ if (optionalParams.locale) {
128
+ requestOptionalParams.initContext.locale = optionalParams.locale;
129
+ }
130
+ if (optionalParams.device) {
131
+ requestOptionalParams.initContext.device = optionalParams.device;
132
+ }
133
+ if (optionalParams.preChatResponse) {
134
+ requestOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
135
+ }
136
+ if (optionalParams.portalContactId) {
137
+ requestOptionalParams.initContext.portalcontactid = optionalParams.portalContactId;
138
+ }
139
+ if (optionalParams.sendDefaultInitContext) {
140
+ if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
141
+ var exceptionDetails = {
142
+ response: ChatSDKErrors_1.default.UnsupportedPlatform,
143
+ message: "sendDefaultInitContext is only supported on browser"
144
+ };
145
+ console.error(exceptionDetails.message);
146
+ _this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
147
+ RequestId: _this.requestId,
148
+ ChatId: _this.chatToken.chatId,
149
+ ExceptionDetails: JSON.stringify(exceptionDetails)
150
+ });
151
+ throw new Error(exceptionDetails.response);
152
+ }
153
+ requestOptionalParams.getContext = true;
154
+ }
155
+ // Override initContext completely
156
+ if (optionalParams.initContext) {
157
+ requestOptionalParams.initContext = optionalParams.initContext;
158
+ }
159
+ if (_this.authenticatedUserToken) {
160
+ requestOptionalParams.authenticatedUserToken = _this.authenticatedUserToken;
161
+ }
162
+ if (_this.chatToken.chatId) {
163
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
+ requestOptionalParams.initContext.chatId = _this.chatToken.chatId;
165
+ }
166
+ return requestOptionalParams;
167
+ };
113
168
  this.debug = false;
114
169
  this.runtimeId = ocsdk_1.uuidv4();
115
170
  this.omnichannelConfig = omnichannelConfig;
116
171
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
117
172
  );
118
173
  this.isInitialized = false;
119
- this.liveChatVersion = LiveChatVersion_1.default.V1;
174
+ this.liveChatVersion = LiveChatVersion_1.default.V2;
120
175
  this.localeId = locale_1.defaultLocaleId;
121
176
  this.requestId = ocsdk_1.uuidv4();
122
177
  this.chatToken = {};
@@ -131,18 +186,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
131
186
  this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
132
187
  this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
133
188
  this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
189
+ this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
134
190
  this.scenarioMarker.useTelemetry(this.telemetry);
135
191
  this.ic3ClientLogger.useTelemetry(this.telemetry);
136
192
  this.ocSdkLogger.useTelemetry(this.telemetry);
137
193
  this.acsClientLogger.useTelemetry(this.telemetry);
138
194
  this.acsAdapterLogger.useTelemetry(this.telemetry);
139
195
  this.callingSdkLogger.useTelemetry(this.telemetry);
196
+ this.amsClientLogger.useTelemetry(this.telemetry);
140
197
  this.scenarioMarker.setRuntimeId(this.runtimeId);
141
198
  this.ic3ClientLogger.setRuntimeId(this.runtimeId);
142
199
  this.ocSdkLogger.setRuntimeId(this.runtimeId);
143
200
  this.acsClientLogger.setRuntimeId(this.runtimeId);
144
201
  this.acsAdapterLogger.setRuntimeId(this.runtimeId);
145
202
  this.callingSdkLogger.setRuntimeId(this.runtimeId);
203
+ this.amsClientLogger.setRuntimeId(this.runtimeId);
146
204
  OmnichannelConfigValidator_1.default(omnichannelConfig);
147
205
  SDKConfigValidators_1.default(chatSDKConfig);
148
206
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -154,10 +212,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
154
212
  (_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
155
213
  (_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
156
214
  (_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
215
+ (_j = this.amsClientLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
157
216
  }
158
217
  /* istanbul ignore next */
159
218
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
160
- var _a, _b, _c, _d, _e, _f, _g;
219
+ var _a, _b, _c, _d, _e, _f, _g, _h;
161
220
  this.debug = flag;
162
221
  (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
163
222
  (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
@@ -167,31 +226,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
167
226
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
168
227
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
169
228
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
229
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
170
230
  };
171
231
  OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
172
232
  if (optionalParams === void 0) { optionalParams = {}; }
173
233
  return __awaiter(this, void 0, void 0, function () {
174
- var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
175
- return __generator(this, function (_e) {
176
- switch (_e.label) {
234
+ var _a, getLiveChatConfigOptionalParams, _b, _c, e_1;
235
+ return __generator(this, function (_d) {
236
+ switch (_d.label) {
177
237
  case 0:
178
238
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
179
239
  if (this.isInitialized) {
180
240
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
181
241
  return [2 /*return*/, this.liveChatConfig];
182
242
  }
183
- _e.label = 1;
243
+ _d.label = 1;
184
244
  case 1:
185
- _e.trys.push([1, 8, , 9]);
245
+ _d.trys.push([1, 9, , 10]);
186
246
  this.OCSDKProvider = ocsdk_1.SDKProvider;
187
247
  _a = this;
188
248
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
189
249
  case 2:
190
- _a.OCClient = _e.sent();
250
+ _a.OCClient = _d.sent();
191
251
  getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
192
252
  return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
193
253
  case 3:
194
- _e.sent();
254
+ _d.sent();
195
255
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
196
256
  this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
197
257
  _b = this;
@@ -199,26 +259,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
199
259
  framedMode: platform_1.isBrowser(),
200
260
  multiClient: true,
201
261
  debug: false,
202
- logger: undefined
262
+ logger: this.amsClientLogger
203
263
  })];
204
264
  case 4:
205
- _b.AMSClient = _e.sent();
206
- return [3 /*break*/, 7];
265
+ _b.AMSClient = _d.sent();
266
+ return [3 /*break*/, 8];
207
267
  case 5:
268
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 7];
208
269
  _c = this;
209
270
  return [4 /*yield*/, this.getIC3Client()];
210
271
  case 6:
211
- _c.IC3Client = _e.sent();
212
- _e.label = 7;
213
- case 7:
272
+ _c.IC3Client = _d.sent();
273
+ return [3 /*break*/, 8];
274
+ case 7: throw new Error("Unsupported LiveChatVersion");
275
+ case 8:
214
276
  this.isInitialized = true;
215
277
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
216
- return [3 /*break*/, 9];
217
- case 8:
218
- _d = _e.sent();
219
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
220
- return [3 /*break*/, 9];
221
- case 9: return [2 /*return*/, this.liveChatConfig];
278
+ return [3 /*break*/, 10];
279
+ case 9:
280
+ e_1 = _d.sent();
281
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK, {
282
+ ExceptionDetails: JSON.stringify(e_1)
283
+ });
284
+ return [3 /*break*/, 10];
285
+ case 10: return [2 /*return*/, this.liveChatConfig];
222
286
  }
223
287
  });
224
288
  });
@@ -308,44 +372,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
308
372
  });
309
373
  };
310
374
  OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
311
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
375
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
312
376
  if (optionalParams === void 0) { optionalParams = {}; }
313
377
  return __awaiter(this, void 0, void 0, function () {
314
- var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _v, exceptionDetails, sessionInitOptionalParams, exceptionDetails, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _w, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _x, error_8, exceptionDetails;
378
+ var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse, _x, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _y, exceptionDetails, sessionInitOptionalParams, location_2, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _z, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _0, error_8, exceptionDetails;
315
379
  var _this = this;
316
- return __generator(this, function (_y) {
317
- switch (_y.label) {
380
+ return __generator(this, function (_1) {
381
+ switch (_1.label) {
318
382
  case 0:
319
383
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
320
384
  RequestId: this.requestId
321
385
  });
322
386
  shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
323
387
  if (!shouldReinitIC3Client) return [3 /*break*/, 2];
324
- _t = this;
388
+ _w = this;
325
389
  return [4 /*yield*/, this.getIC3Client()];
326
390
  case 1:
327
- _t.IC3Client = _y.sent();
328
- _y.label = 2;
391
+ _w.IC3Client = _1.sent();
392
+ _1.label = 2;
329
393
  case 2:
330
394
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
331
395
  this.reconnectId = optionalParams.reconnectId;
332
396
  }
333
397
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
334
- _y.label = 3;
398
+ _1.label = 3;
335
399
  case 3:
336
- _y.trys.push([3, 5, , 6]);
400
+ _1.trys.push([3, 5, , 6]);
337
401
  reconnectableChatsParams = {
338
402
  authenticatedUserToken: this.authenticatedUserToken
339
403
  };
340
404
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
341
405
  case 4:
342
- reconnectableChatsResponse = _y.sent();
406
+ reconnectableChatsResponse = _1.sent();
343
407
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
344
408
  this.reconnectId = reconnectableChatsResponse.reconnectid;
345
409
  }
346
410
  return [3 /*break*/, 6];
347
411
  case 5:
348
- _u = _y.sent();
412
+ _x = _1.sent();
349
413
  exceptionDetails = {
350
414
  response: "OCClientGetReconnectableChatsFailed"
351
415
  };
@@ -356,7 +420,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
356
420
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
357
421
  return [4 /*yield*/, this.getConversationDetails()];
358
422
  case 7:
359
- conversationDetails = _y.sent();
423
+ conversationDetails = _1.sent();
360
424
  if (Object.keys(conversationDetails).length === 0) {
361
425
  exceptionDetails = {
362
426
  response: "InvalidConversation"
@@ -381,30 +445,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
381
445
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
382
446
  throw Error(exceptionDetails.response);
383
447
  }
384
- _y.label = 8;
448
+ _1.label = 8;
385
449
  case 8:
386
450
  if (!this.authSettings) return [3 /*break*/, 14];
387
451
  if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
388
452
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
389
453
  case 9:
390
- _y.sent();
391
- _y.label = 10;
454
+ _1.sent();
455
+ _1.label = 10;
392
456
  case 10:
393
457
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
394
458
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
395
459
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
396
- _y.label = 11;
460
+ _1.label = 11;
397
461
  case 11:
398
- _y.trys.push([11, 13, , 14]);
462
+ _1.trys.push([11, 13, , 14]);
399
463
  return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
400
464
  authenticatedUserToken: this.authenticatedUserToken,
401
465
  chatId: this.chatToken.chatId
402
466
  })];
403
467
  case 12:
404
- _y.sent();
468
+ _1.sent();
405
469
  return [3 /*break*/, 14];
406
470
  case 13:
407
- _v = _y.sent();
471
+ _y = _1.sent();
408
472
  exceptionDetails = {
409
473
  response: "OCClientValidateAuthChatRecordFailed",
410
474
  message: "InvalidAuthChatRecord"
@@ -419,84 +483,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
419
483
  if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
420
484
  return [4 /*yield*/, this.getChatToken(false)];
421
485
  case 15:
422
- _y.sent();
423
- _y.label = 16;
486
+ _1.sent();
487
+ _1.label = 16;
424
488
  case 16:
425
489
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
426
490
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
427
491
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
428
492
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
429
493
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
494
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
430
495
  sessionInitOptionalParams = {
431
496
  initContext: {}
432
497
  };
433
- sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
434
- if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
498
+ sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
499
+ sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
500
+ if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
435
501
  sessionInitOptionalParams.reconnectId = this.reconnectId;
436
502
  }
437
- if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
503
+ else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
438
504
  sessionInitOptionalParams.reconnectId = this.reconnectId;
439
505
  }
440
- if (optionalParams.customContext) {
441
- sessionInitOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
442
- }
443
- if (optionalParams.browser) {
444
- sessionInitOptionalParams.initContext.browser = optionalParams.browser;
445
- }
446
- if (optionalParams.os) {
447
- sessionInitOptionalParams.initContext.os = optionalParams.os;
448
- }
449
- if (optionalParams.locale) {
450
- sessionInitOptionalParams.initContext.locale = optionalParams.locale;
451
- }
452
- if (optionalParams.device) {
453
- sessionInitOptionalParams.initContext.device = optionalParams.device;
454
- }
455
- if (optionalParams.preChatResponse) {
456
- sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
457
- }
458
- if (optionalParams.sendDefaultInitContext) {
459
- if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
460
- exceptionDetails = {
461
- response: ChatSDKErrors_1.default.UnsupportedPlatform,
462
- message: "sendDefaultInitContext is only supported on browser"
463
- };
464
- console.error(exceptionDetails.message);
465
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
466
- RequestId: this.requestId,
467
- ChatId: this.chatToken.chatId,
468
- ExceptionDetails: JSON.stringify(exceptionDetails)
469
- });
470
- throw new Error(exceptionDetails.response);
471
- }
472
- sessionInitOptionalParams.getContext = true;
473
- }
474
- // Override initContext completely
475
- if (optionalParams.initContext) {
476
- sessionInitOptionalParams.initContext = optionalParams.initContext;
477
- }
478
- if (this.authenticatedUserToken) {
479
- sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
480
- }
481
- if (this.chatToken.chatId) {
482
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
483
- sessionInitOptionalParams.initContext.chatId = this.chatToken.chatId;
484
- }
485
- if (!!optionalParams.liveChatContext) return [3 /*break*/, 20];
486
- _y.label = 17;
506
+ if (!(((_m = (_l = this.liveChatConfig) === null || _l === void 0 ? void 0 : _l.LiveWSAndLiveChatEngJoin) === null || _m === void 0 ? void 0 : _m.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
507
+ return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
487
508
  case 17:
488
- _y.trys.push([17, 19, , 20]);
489
- return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
509
+ location_2 = _1.sent();
510
+ sessionInitOptionalParams.initContext.latitude = location_2.latitude;
511
+ sessionInitOptionalParams.initContext.longitude = location_2.longitude;
512
+ _1.label = 18;
490
513
  case 18:
491
- _y.sent();
492
- return [3 /*break*/, 20];
514
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
515
+ _1.label = 19;
493
516
  case 19:
494
- error_3 = _y.sent();
517
+ _1.trys.push([19, 21, , 22]);
518
+ return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
519
+ case 20:
520
+ _1.sent();
521
+ return [3 /*break*/, 22];
522
+ case 21:
523
+ error_3 = _1.sent();
495
524
  exceptionDetails = {
496
525
  response: "OCClientSessionInitFailed"
497
526
  };
498
527
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
499
- if (((_k = error_3) === null || _k === void 0 ? void 0 : _k.isAxiosError) && ((_m = (_l = error_3.response) === null || _l === void 0 ? void 0 : _l.headers) === null || _m === void 0 ? void 0 : _m.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
528
+ if (((_o = error_3) === null || _o === void 0 ? void 0 : _o.isAxiosError) && ((_q = (_p = error_3.response) === null || _p === void 0 ? void 0 : _p.headers) === null || _q === void 0 ? void 0 : _q.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
500
529
  exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
501
530
  exceptionDetails.message = 'Widget used outside of operating hours';
502
531
  console.error(exceptionDetails.message);
@@ -507,8 +536,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
507
536
  ExceptionDetails: JSON.stringify(exceptionDetails)
508
537
  });
509
538
  throw new Error(exceptionDetails.response);
510
- case 20:
511
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
539
+ case 22:
540
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
512
541
  chatAdapterConfig = {
513
542
  token: this.chatToken.token,
514
543
  id: this.chatToken.visitorId || 'teamsvisitor',
@@ -516,18 +545,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
516
545
  environmentUrl: this.chatToken.acsEndpoint,
517
546
  pollingInterval: 30000
518
547
  };
519
- _y.label = 21;
520
- case 21:
521
- _y.trys.push([21, 23, , 24]);
522
- return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
548
+ _1.label = 23;
549
+ case 23:
550
+ _1.trys.push([23, 25, , 26]);
551
+ return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
523
552
  token: chatAdapterConfig.token,
524
553
  environmentUrl: chatAdapterConfig.environmentUrl
525
554
  }))];
526
- case 22:
527
- _y.sent();
528
- return [3 /*break*/, 24];
529
- case 23:
530
- error_4 = _y.sent();
555
+ case 24:
556
+ _1.sent();
557
+ return [3 /*break*/, 26];
558
+ case 25:
559
+ error_4 = _1.sent();
531
560
  exceptionDetails = {
532
561
  response: "ACSClientInitializeFailed"
533
562
  };
@@ -538,23 +567,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
538
567
  });
539
568
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
540
569
  return [2 /*return*/, error_4];
541
- case 24:
542
- _y.trys.push([24, 26, , 27]);
543
- _w = this;
544
- return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
570
+ case 26:
571
+ _1.trys.push([26, 28, , 29]);
572
+ _z = this;
573
+ return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
545
574
  id: chatAdapterConfig.id,
546
575
  threadId: chatAdapterConfig.threadId,
547
576
  pollingInterval: chatAdapterConfig.pollingInterval
548
577
  }))];
549
- case 25:
550
- _w.conversation = (_y.sent());
578
+ case 27:
579
+ _z.conversation = (_1.sent());
551
580
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
552
581
  RequestId: this.requestId,
553
582
  ChatId: this.chatToken.chatId
554
583
  });
555
- return [3 /*break*/, 27];
556
- case 26:
557
- error_5 = _y.sent();
584
+ return [3 /*break*/, 29];
585
+ case 28:
586
+ error_5 = _1.sent();
558
587
  exceptionDetails = {
559
588
  response: "ACSClientJoinConversationFailed"
560
589
  };
@@ -565,16 +594,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
565
594
  });
566
595
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
567
596
  throw Error(exceptionDetails.response);
568
- case 27:
569
- _y.trys.push([27, 29, , 30]);
570
- return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
597
+ case 29:
598
+ _1.trys.push([29, 31, , 32]);
599
+ return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
571
600
  chatToken: this.chatToken
572
601
  }))];
573
- case 28:
574
- _y.sent();
575
- return [3 /*break*/, 30];
576
- case 29:
577
- error_6 = _y.sent();
602
+ case 30:
603
+ _1.sent();
604
+ return [3 /*break*/, 32];
605
+ case 31:
606
+ error_6 = _1.sent();
578
607
  exceptionDetails = {
579
608
  response: "AMSClientInitializeFailed"
580
609
  };
@@ -584,19 +613,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
584
613
  ExceptionDetails: JSON.stringify(exceptionDetails)
585
614
  });
586
615
  throw Error(exceptionDetails.response);
587
- case 30: return [3 /*break*/, 37];
588
- case 31:
589
- _y.trys.push([31, 33, , 34]);
616
+ case 32: return [3 /*break*/, 39];
617
+ case 33:
618
+ _1.trys.push([33, 35, , 36]);
590
619
  return [4 /*yield*/, this.IC3Client.initialize({
591
620
  token: this.chatToken.token,
592
621
  regionGtms: this.chatToken.regionGTMS,
593
622
  visitor: true
594
623
  })];
595
- case 32:
596
- _y.sent();
597
- return [3 /*break*/, 34];
598
- case 33:
599
- error_7 = _y.sent();
624
+ case 34:
625
+ _1.sent();
626
+ return [3 /*break*/, 36];
627
+ case 35:
628
+ error_7 = _1.sent();
600
629
  exceptionDetails = {
601
630
  response: "IC3ClientInitializeFailed"
602
631
  };
@@ -607,19 +636,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
607
636
  });
608
637
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
609
638
  return [2 /*return*/, error_7];
610
- case 34:
611
- _y.trys.push([34, 36, , 37]);
612
- _x = this;
639
+ case 36:
640
+ _1.trys.push([36, 38, , 39]);
641
+ _0 = this;
613
642
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
614
- case 35:
615
- _x.conversation = _y.sent();
643
+ case 37:
644
+ _0.conversation = _1.sent();
616
645
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
617
646
  RequestId: this.requestId,
618
647
  ChatId: this.chatToken.chatId
619
648
  });
620
- return [3 /*break*/, 37];
621
- case 36:
622
- error_8 = _y.sent();
649
+ return [3 /*break*/, 39];
650
+ case 38:
651
+ error_8 = _1.sent();
623
652
  exceptionDetails = {
624
653
  response: "IC3ClientJoinConversationFailed"
625
654
  };
@@ -630,8 +659,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
630
659
  });
631
660
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
632
661
  return [2 /*return*/, error_8];
633
- case 37:
634
- if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
662
+ case 39:
663
+ if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
635
664
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
636
665
  return __generator(this, function (_a) {
637
666
  switch (_a.label) {
@@ -642,7 +671,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
642
671
  return [2 /*return*/];
643
672
  }
644
673
  });
645
- }); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
674
+ }); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
646
675
  }
647
676
  return [2 /*return*/];
648
677
  }
@@ -650,11 +679,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
650
679
  });
651
680
  };
652
681
  OmnichannelChatSDK.prototype.endChat = function () {
653
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
682
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
654
683
  return __awaiter(this, void 0, void 0, function () {
655
684
  var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
656
- return __generator(this, function (_p) {
657
- switch (_p.label) {
685
+ return __generator(this, function (_r) {
686
+ switch (_r.label) {
658
687
  case 0:
659
688
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
660
689
  RequestId: this.requestId,
@@ -674,12 +703,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
674
703
  if (this.authenticatedUserToken) {
675
704
  sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
676
705
  }
677
- _p.label = 1;
706
+ _r.label = 1;
678
707
  case 1:
679
- _p.trys.push([1, 3, , 4]);
708
+ _r.trys.push([1, 3, , 4]);
680
709
  return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
681
710
  case 2:
682
- _p.sent();
711
+ _r.sent();
683
712
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
684
713
  RequestId: this.requestId,
685
714
  ChatId: this.chatToken.chatId
@@ -704,9 +733,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
704
733
  (_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
705
734
  (_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
706
735
  (_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
736
+ (_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
737
+ (_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
707
738
  return [3 /*break*/, 4];
708
739
  case 3:
709
- error_9 = _p.sent();
740
+ error_9 = _r.sent();
710
741
  exceptionDetails = {
711
742
  response: "OCClientSessionCloseFailed"
712
743
  };
@@ -1730,28 +1761,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
1730
1761
  };
1731
1762
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1732
1763
  return __awaiter(this, void 0, void 0, function () {
1733
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1734
- return __generator(this, function (_a) {
1735
- switch (_a.label) {
1764
+ var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, _a, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext, ex_1;
1765
+ return __generator(this, function (_b) {
1766
+ switch (_b.label) {
1736
1767
  case 0:
1737
1768
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1738
1769
  RequestId: this.requestId
1739
1770
  });
1740
- _a.label = 1;
1771
+ _b.label = 1;
1741
1772
  case 1:
1742
- _a.trys.push([1, 6, , 7]);
1773
+ _b.trys.push([1, 8, , 9]);
1743
1774
  chatConfig = this.liveChatConfig;
1744
1775
  liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
1745
1776
  msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
1746
- if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
1777
+ if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 6];
1747
1778
  return [4 /*yield*/, this.getConversationDetails()];
1748
1779
  case 2:
1749
- liveWorkItemDetails = _a.sent();
1780
+ liveWorkItemDetails = _b.sent();
1750
1781
  participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
1751
1782
  participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
1752
1783
  conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
1753
- surveyInviteLinkRequest = {
1754
- "FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
1784
+ agentSurveyInviteLinkRequest = {
1785
+ "FormId": msfp_sourcesurveyidentifier,
1786
+ "ConversationId": conversationId,
1787
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1788
+ };
1789
+ botSurveyInviteLinkRequest = {
1790
+ "FormId": msfp_botsourcesurveyidentifier,
1755
1791
  "ConversationId": conversationId,
1756
1792
  "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1757
1793
  };
@@ -1761,14 +1797,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
1761
1797
  if (this.authenticatedUserToken) {
1762
1798
  optionalParams.authenticatedUserToken = this.authenticatedUserToken;
1763
1799
  }
1764
- ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
1765
- return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
1800
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, agentSurveyInviteLinkRequest, optionalParams)];
1766
1801
  case 3:
1767
- surveyInviteLinkResponse = _a.sent();
1768
- surveyInviteLink = void 0, formsProLocale = void 0;
1769
- if (surveyInviteLinkResponse != null) {
1770
- if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
1771
- surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
1802
+ agentSurveyInviteLinkResponse = _b.sent();
1803
+ _a = postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier;
1804
+ if (!_a) return [3 /*break*/, 5];
1805
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)];
1806
+ case 4:
1807
+ _a = (_b.sent());
1808
+ _b.label = 5;
1809
+ case 5:
1810
+ botSurveyInviteLinkResponse = _a;
1811
+ agentSurveyInviteLink = void 0, agentFormsProLocale = void 0, botSurveyInviteLink = void 0, botFormsProLocale = void 0;
1812
+ if (agentSurveyInviteLinkResponse != null) {
1813
+ if (agentSurveyInviteLinkResponse.inviteList != null && agentSurveyInviteLinkResponse.inviteList.length == 1) {
1814
+ agentSurveyInviteLink = agentSurveyInviteLinkResponse.inviteList[0].invitationLink;
1772
1815
  }
1773
1816
  else {
1774
1817
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
@@ -1778,14 +1821,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
1778
1821
  });
1779
1822
  return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
1780
1823
  }
1781
- if (surveyInviteLinkResponse.formsProLocaleCode != null) {
1782
- formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
1824
+ if (agentSurveyInviteLinkResponse.formsProLocaleCode != null) {
1825
+ agentFormsProLocale = agentSurveyInviteLinkResponse.formsProLocaleCode;
1826
+ }
1827
+ if (botSurveyInviteLinkResponse != null) {
1828
+ if (botSurveyInviteLinkResponse.inviteList != null && botSurveyInviteLinkResponse.inviteList.length == 1) {
1829
+ botSurveyInviteLink = botSurveyInviteLinkResponse.inviteList[0].invitationLink;
1830
+ }
1831
+ if (botSurveyInviteLinkResponse.formsProLocaleCode != null) {
1832
+ botFormsProLocale = botSurveyInviteLinkResponse.formsProLocaleCode;
1833
+ }
1783
1834
  }
1784
1835
  postChatContext = {
1785
1836
  participantJoined: participantJoined,
1786
1837
  participantType: participantType,
1787
- surveyInviteLink: surveyInviteLink,
1788
- formsProLocale: formsProLocale
1838
+ surveyInviteLink: agentSurveyInviteLink,
1839
+ botSurveyInviteLink: botSurveyInviteLink,
1840
+ formsProLocale: agentFormsProLocale,
1841
+ botFormsProLocale: botFormsProLocale
1789
1842
  };
1790
1843
  return [2 /*return*/, Promise.resolve(postChatContext)];
1791
1844
  }
@@ -1797,23 +1850,77 @@ var OmnichannelChatSDK = /** @class */ (function () {
1797
1850
  });
1798
1851
  return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
1799
1852
  }
1800
- return [3 /*break*/, 5];
1801
- case 4:
1853
+ return [3 /*break*/, 7];
1854
+ case 6:
1802
1855
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1803
1856
  RequestId: this.requestId,
1804
1857
  ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
1805
1858
  });
1806
1859
  return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
1807
- case 5: return [3 /*break*/, 7];
1808
- case 6:
1809
- ex_1 = _a.sent();
1860
+ case 7: return [3 /*break*/, 9];
1861
+ case 8:
1862
+ ex_1 = _b.sent();
1810
1863
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1811
1864
  ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
1812
1865
  RequestId: this.requestId,
1813
1866
  ExceptionDetails: JSON.stringify(ex_1)
1814
1867
  });
1815
1868
  return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
1816
- case 7: return [2 /*return*/];
1869
+ case 9: return [2 /*return*/];
1870
+ }
1871
+ });
1872
+ });
1873
+ };
1874
+ OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
1875
+ if (optionalParams === void 0) { optionalParams = {}; }
1876
+ return __awaiter(this, void 0, void 0, function () {
1877
+ var reportError, getAgentAvailabilityOptionalParams, response, e_2;
1878
+ var _this = this;
1879
+ return __generator(this, function (_a) {
1880
+ switch (_a.label) {
1881
+ case 0:
1882
+ reportError = function (response, message, chatId) {
1883
+ if (chatId === void 0) { chatId = ""; }
1884
+ var exceptionDetails = {
1885
+ response: response,
1886
+ message: message
1887
+ };
1888
+ _this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1889
+ RequestId: _this.requestId,
1890
+ ExceptionDetails: JSON.stringify(exceptionDetails),
1891
+ ChatId: chatId
1892
+ });
1893
+ throw new Error(exceptionDetails.message);
1894
+ };
1895
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1896
+ RequestId: this.requestId
1897
+ });
1898
+ if (!this.authSettings) {
1899
+ reportError("Unsupported", "GetAgentAvailability is supported only for authenticated live chat widget.");
1900
+ }
1901
+ if (!this.authenticatedUserToken) {
1902
+ reportError("UndefinedAuthToken", "Missing AuthToken for GetAgentAvailability.");
1903
+ }
1904
+ if (this.conversation) {
1905
+ reportError("InvalidOperation", "GetAgentAvailability can only be called before a chat has started.", this.chatToken.chatId);
1906
+ }
1907
+ getAgentAvailabilityOptionalParams = {
1908
+ initContext: {}
1909
+ };
1910
+ getAgentAvailabilityOptionalParams = this.populateInitChatOptionalParam(getAgentAvailabilityOptionalParams, optionalParams);
1911
+ _a.label = 1;
1912
+ case 1:
1913
+ _a.trys.push([1, 3, , 4]);
1914
+ return [4 /*yield*/, this.OCClient.getAgentAvailability(this.requestId, getAgentAvailabilityOptionalParams)];
1915
+ case 2:
1916
+ response = _a.sent();
1917
+ return [2 /*return*/, response];
1918
+ case 3:
1919
+ e_2 = _a.sent();
1920
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1921
+ reportError("GetAgentAvailabilityFailed", e_2.message);
1922
+ return [3 /*break*/, 4];
1923
+ case 4: return [2 /*return*/];
1817
1924
  }
1818
1925
  });
1819
1926
  });