Skip to content

Commit f9affff

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

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

npachpande/cwc/local/patch/wsi.html

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,18 @@
2525
<!-- <img src="https://esw1234.github.io/wsi.png" alt="Background"> -->
2626
</div>
2727

28-
29-
<button type="button" class="custom-fab" onclick="sendNudge()">send nudge</button>
28+
<input type="text" id="nudgeInput"><br><br>
29+
<button type="button" onclick="sendNudge()">send nudge</button>
3030
<script type='text/javascript'>
3131
let oliveReadyPromise, oliveReadyPromiseResolve;
3232

3333
window.addEventListener("onEmbeddedMessagingReady", () => {
3434
oliveReadyPromise = new Promise((resolve) => {
3535
oliveReadyPromiseResolve = resolve;
3636
});
37-
if (Boolean(localStorage.getItem("isEmbeddedMessagingFirstBotMessageSent"))) {
38-
resolveOliveReadyPromise();
39-
}
4037
});
4138

42-
window.addEventListener("onEmbeddedMessagingFirstBotMessageSent", () => {
43-
localStorage.setItem("isEmbeddedMessagingFirstBotMessageSent", true);
44-
resolveOliveReadyPromise();
45-
});
46-
47-
window.addEventListener("onEmbeddedMessagingConversationClosed", () => {
48-
localStorage.setItem("isEmbeddedMessagingFirstBotMessageSent", false);
39+
window.addEventListener("onEmbeddedMessagingConversationOpened", () => {
4940
resolveOliveReadyPromise();
5041
});
5142

@@ -55,17 +46,14 @@
5546
}
5647
}
5748

58-
function sendNudge(nudge) {
49+
function sendNudge() {
50+
const nudgeText = document.getElementById("nudgeInput").value;
5951
embeddedservice_bootstrap.utilAPI.launchChat();
6052
oliveReadyPromise.then(() => {
61-
embeddedservice_bootstrap.utilAPI.sendTextMessage("Text");
53+
embeddedservice_bootstrap.utilAPI.sendTextMessage(nudgeText);
6254
});
6355
}
6456

65-
function launchChat() {
66-
embeddedservice_bootstrap.utilAPI.launchChat();
67-
}
68-
6957
function initEmbeddedMessaging() {
7058
try {
7159
embeddedservice_bootstrap.settings.language = 'en_US'; // For example, enter 'en' or 'en-US'

0 commit comments

Comments
 (0)