|
7 | 7 |
|
8 | 8 | <style> |
9 | 9 | body { |
10 | | - /*overflow: hidden*/; |
| 10 | + /*overflow: hidden*/ |
11 | 11 | } |
12 | 12 | .background-container { |
13 | 13 | width: 100%; |
|
25 | 25 | <!-- <img src="https://esw1234.github.io/wsi.png" alt="Background"> --> |
26 | 26 | </div> |
27 | 27 |
|
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> |
30 | 30 | <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 | + |
31 | 58 | function sendNudge(nudge) { |
32 | | - embeddedservice_bootstrap.utilAPI.sendTextMessage("Text"); |
| 59 | + embeddedservice_bootstrap.utilAPI.launchChat(); |
| 60 | + oliveReadyPromise.then(() => { |
| 61 | + embeddedservice_bootstrap.utilAPI.sendTextMessage("Text"); |
| 62 | + }); |
33 | 63 | } |
34 | 64 |
|
35 | 65 | function launchChat() { |
|
44 | 74 | embeddedservice_bootstrap.init( |
45 | 75 | '00DSB00000aGFJL', |
46 | 76 | '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', |
48 | 78 | { |
49 | 79 | scrt2URL: 'https://orgfarm-d585323017.test1.my.pc-rnd.salesforce-scrt.com' |
50 | 80 | } |
|
54 | 84 | } |
55 | 85 | }; |
56 | 86 | </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> |
58 | 88 |
|
59 | 89 | </body> |
60 | 90 | </html> |
0 commit comments