Guest User

Untitled

a guest
Nov 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <!--
  2. PLEASE NOTE:
  3. This sameple DOES NOT include the standard liveperson tag which should already be included on all pages you wish to start,
  4. continue cobrowse live sharing on
  5. -->
  6. <a href="#" onclick="enterServiceNumber();">Start Voice to CoBrowse Session</a>
  7. <script type='text/javascript'>
  8. function requestCobrowse(serviceId) {
  9. lpTag.taglets.cobrowse.loadApi(function (visitorApi) {
  10.  
  11. console.log("CoBrowse visitor API loaded");
  12.  
  13. visitorApi.once("sessionRejected", function () {
  14. alert("The service number is invalid.");
  15. });
  16.  
  17. visitorApi.once("sessionOffered", function (event) {
  18. console.log("Agent answered the request and offers a CoBrowse session");
  19. var automaticallyAcceptOffer = true; // Set to false if you would like to ask the visitor to confirm the session start.
  20.  
  21. if (automaticallyAcceptOffer || confirm("Would you like to start a CoBrowse session with '" + event.agentAlias + "'?")) {
  22. visitorApi.acceptSupportOffer(event);
  23. } else {
  24. visitorApi.cancelSupportOffer(event);
  25. }
  26. });
  27.  
  28.  
  29. function sessionReadyCallback(startEvent) {
  30. if (startEvent) {
  31. console.log("Session is ready and will be started shortly.");
  32. }
  33. }
  34.  
  35. visitorApi.requestSupport({
  36. serviceId: serviceId
  37. }, sessionReadyCallback);
  38. });
  39. }
  40.  
  41. /**
  42. * Example: Display a simple dialog for entering the service number. In non proof-of-concept
  43. * deployments the prompt should be replaced with a dialog that reflects the CI of the brand.
  44. */
  45.  
  46. function enterServiceNumber() {
  47. var serviceId = prompt("Please enter the CoBrowse service number in the field below.");
  48. if (serviceId) {
  49. requestCobrowse(serviceId);
  50. }
  51. }
  52. </script>
Add Comment
Please, Sign In to add comment