Skip to content

Commit de1c7fa

Browse files
authored
Update wsi.html
1 parent ffda682 commit de1c7fa

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

npachpande/cwc/local/patch/wsi.html

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<style>
99
body {
10-
/*overflow: hidden*/;
10+
/*overflow: hidden*/
1111
}
1212
.background-container {
1313
width: 100%;
@@ -25,11 +25,41 @@
2525
<!-- <img src="https://esw1234.github.io/wsi.png" alt="Background"> -->
2626
</div>
2727

28-
<button type="button" class="custom-fab" onclick="launchChat()">launch chat</button>
29-
<button type="button" class="custom-fab" onclick="sendNudge()">send nudge</button>
28+
29+
<button type="button" class="custom-fab" onclick="sendNudge()">send nudge</button>
3030
<script type='text/javascript'>
31+
let oliveReadyPromise, oliveReadyPromiseResolve;
32+
33+
window.addEventListener("onEmbeddedMessagingReady", () => {
34+
oliveReadyPromise = new Promise((resolve) => {
35+
oliveReadyPromiseResolve = resolve;
36+
});
37+
if (Boolean(localStorage.getItem("isEmbeddedMessagingFirstBotMessageSent"))) {
38+
resolveOliveReadyPromise();
39+
}
40+
});
41+
42+
window.addEventListener("onEmbeddedMessagingFirstBotMessageSent", () => {
43+
localStorage.setItem("isEmbeddedMessagingFirstBotMessageSent", true);
44+
resolveOliveReadyPromise();
45+
});
46+
47+
window.addEventListener("onEmbeddedMessagingConversationClosed", () => {
48+
localStorage.setItem("isEmbeddedMessagingFirstBotMessageSent", false);
49+
resolveOliveReadyPromise();
50+
});
51+
52+
function resolveOliveReadyPromise() {
53+
if (oliveReadyPromiseResolve) {
54+
oliveReadyPromiseResolve();
55+
}
56+
}
57+
3158
function sendNudge(nudge) {
32-
embeddedservice_bootstrap.utilAPI.sendTextMessage("Text");
59+
embeddedservice_bootstrap.utilAPI.launchChat();
60+
oliveReadyPromise.then(() => {
61+
embeddedservice_bootstrap.utilAPI.sendTextMessage("Text");
62+
});
3363
}
3464

3565
function launchChat() {
@@ -44,7 +74,7 @@
4474
embeddedservice_bootstrap.init(
4575
'00DSB00000aGFJL',
4676
'CWC_5',
47-
'https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWC51764103699905',
77+
'https://orgfarm-cd97985f87.my.site-com.f1f9h67w8lzd1bmxa00yv89dt.wc.crm.dev:6101/ESWCWC11768329220029',
4878
{
4979
scrt2URL: 'https://orgfarm-d585323017.test1.my.pc-rnd.salesforce-scrt.com'
5080
}
@@ -54,7 +84,7 @@
5484
}
5585
};
5686
</script>
57-
<script type='text/javascript' src='https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWC51764103699905/assets/js/bootstrap.js' onload='initEmbeddedMessaging()'></script>
87+
<script type='text/javascript' src='https://orgfarm-cd97985f87.my.site-com.f1f9h67w8lzd1bmxa00yv89dt.wc.crm.dev:6101/ESWCWC11768329220029/assets/js/bootstrap.js' onload='initEmbeddedMessaging()'></script>
5888

5989
</body>
6090
</html>

0 commit comments

Comments
 (0)