Skip to content

Commit

Permalink
Merge pull request #4 from surfly/mir-4501-dynamic-nic-home-url
Browse files Browse the repository at this point in the history
Make NIC home URL dynamic
  • Loading branch information
mirhmousavi authored Jun 22, 2023
2 parents d98fdf9 + b8cdf8b commit 90333f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Fixes surfly/it#ISSUE_NUMBER

#### Description

---

#### Before requesting the review, make sure you've:
- updated all related docs
- written tests for any new functionality
- verified commit history

#### The pr is ready!
- [ ] all tests are passing
- [ ] I tested my changes and it works!
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
34 changes: 11 additions & 23 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* showLiveChatButton
* showVideoChatButton
* scaleDroneChannelId
* nicHomeURL
* nicBusNumber
* nicChatPOC
* clusterNiC
Expand All @@ -27,6 +28,7 @@
* var showLiveChatButton = true;
* var showVideoChatButton = true;
* var scaleDroneChannelId = 'fygLrCqVZUYQZL6';
* var nicHomeURL = 'https://home-b99.nice-incontact.com';
* var nicBusNumber = '1809119';
* var nicChatPOC = '1605d121-489c-4df4-83b1-334dbeb0a781u';
* var clusterNiC = 'b99';
Expand All @@ -44,7 +46,7 @@
* </html>
*/

let NicHomeURL = "https://home-" + clusterNiC + ".nice-incontact.com";
var nicHomeURL = nicHomeURL || "https://home-" + clusterNiC + ".nice-incontact.com";

var showLiveChatButton = typeof showLiveChatButton === 'undefined' ? true : showLiveChatButton;
var showVideoChatButton = typeof showVideoChatButton === 'undefined' ? true : showVideoChatButton;
Expand All @@ -55,7 +57,7 @@ if (showLiveChatButton === false && showVideoChatButton === false) {
};

var chatSrc = document.createElement("script");
chatSrc.src = NicHomeURL + "/inContact/ChatClient/js/embed.min.js";
chatSrc.src = nicHomeURL + "/inContact/ChatClient/js/embed.min.js";

var head = document.getElementsByTagName("head")[0];
head.appendChild(chatSrc);
Expand Down Expand Up @@ -132,10 +134,7 @@ function createVideochatSession() {
"name": "Customer"
};

videochatSession.on("session_created", function(session, event) {
console.log('Waiting for confirmation');
session.startLeader(null, surflyMetadata);
}).on("session_started", function(session, event) {
videochatSession.on("session_started", function(session, event) {
var surflySessionPin = session.pin;
var surflyFollowerLink = session.followerLink;
signalWorkItem(surflyFollowerLink);
Expand All @@ -147,7 +146,7 @@ function createVideochatSession() {
console.log("Videochat session ended");
showVideoChatButton && createVideochatButton();
endWorkItem(window.nicVideochatContactId);
}).create();
}).startLeader(null, surflyMetadata)
}


Expand All @@ -173,15 +172,10 @@ function createSurflySession(contactId, inviteType) {
var regularSession = Surfly.session({
block_until_agent_joins: false
});
regularSession.on("session_created", function(session, event) {
console.log('Waiting for confirmation');
session.startLeader(null, surflyMetadata);
}).on("session_started", function(session, event) {
regularSession.on("session_started", function(session, event) {
var surflySessionPin = session.pin;
var surflyFollowerLink = session.followerLink;

signalContact(contactId, surflyFollowerLink, surflySessionPin, 'cobrowse');

var chatDiv = document.getElementById("chat-div-wrap");
chatDiv.style.zIndex = "2147483549";
console.log('Session Pin: ' + surflySessionPin);
Expand All @@ -190,32 +184,26 @@ function createSurflySession(contactId, inviteType) {
console.log("Regular session ended, updating Studio");
updateStudioScript(contactId, 'cobrowse');
showVideoChatButton && createVideochatButton();
}).create();
}).startLeader(null, surflyMetadata);
} else if (inviteType == 'videochat') {
var regularSession = Surfly.session({
block_until_agent_joins: false,
videochat_autostart: true,
videochat_start_fullscreen: true
});
regularSession.on("session_created", function(session, event) {
console.log('Waiting for confirmation');
session.startLeader(null, surflyMetadata);
}).on("session_started", function(session, event) {
regularSession.on("session_started", function(session, event) {
var surflySessionPin = session.pin;
var surflyFollowerLink = session.followerLink;

signalContact(contactId, surflyFollowerLink, surflySessionPin, 'videochat');

var chatDiv = document.getElementById("chat-div-wrap");

chatDiv.style.zIndex = "2147483549";
console.log('Session Pin: ' + surflySessionPin);
console.log('Contact ID: ' + contactId);
}).on("session_ended", function(session, event) {
console.log("Regular session ended, updating Studio");
updateStudioScript(contactId, 'videochat');
showVideoChatButton && createVideochatButton();
}).create();
}).startLeader(null, surflyMetadata);
}
}

Expand Down Expand Up @@ -346,7 +334,7 @@ function loadSurfly() {

function initializeChatNiC() {
icPatronChat.init({
serverHost: NicHomeURL,
serverHost: nicHomeURL,
bus_no: nicBusNumber,
poc: nicChatPOC,
params: [localStorage.getItem(nicBusNumber + "-uniquePageId")]
Expand Down

0 comments on commit 90333f7

Please sign in to comment.