Ξεκινήστε μια συνομιλία προληπτικά

Μπορείτε να βοηθήσετε στη βελτίωση της ικανοποίησης των πελατών προβλέποντας περιοχές όπου οι πελάτες χρειάζονται βοήθεια και, στη συνέχεια, προσελκύοντάς τους μέσω συνομιλίας όταν περιηγούνται στον ιστότοπό σας για κάποιο χρονικό διάστημα.

Εξετάστε τα ακόλουθα σενάρια για την προληπτική έναρξη μιας συνομιλίας.

Σημείωμα

Τα δείγματα κώδικα που αναφέρονται στα ακόλουθα σενάρια χρησιμοποιούν το API setContextProvider που μπορεί να χρησιμοποιηθεί μόνο για συνομιλία χωρίς έλεγχο ταυτότητας. Για συνομιλία με έλεγχο ταυτότητας, πρέπει να χρησιμοποιήσετε το JSON Web Token (JWT). Περισσότερες πληροφορίες: Αποστολή διακριτικών ελέγχου ταυτότητας

Σενάριο 1: Χρόνος αναμονής πελάτη

Η Amy κατέστρεψε κατά λάθος ένα Surface Book και βρίσκεται στη γνωσιακή βάση του προϊόντος προσπαθώντας να αναζητήσει απαντήσεις για περίπου 20 δευτερόλεπτα. Ένα προληπτικό αίτημα συνομιλίας ενεργοποιείται με βάση τη σελίδα προϊόντος στην οποία περιηγούνταν η Amy και τον χρόνο που αφιέρωσε στη σελίδα.

Hi! Just checking in to see if I can help answer any questions you may have. 

Η Amy μπορεί να αποδεχτεί την προσφορά συνομιλίας και να ξεκινήσει τη συνομιλία για να επιλύσει το πρόβλημα.

Δείγμα κώδικα

<!-- Code to show proactive chat invite after visitor has spend given time on the webpage -->
<script id="Proactivechattrigger">
	// Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		var timeToWaitBeforeOfferingProactiveChatInMilliseconds = 20000;//time to wait before Offering proactive chat to webpage visitor
		// Setting context variables
        Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
            return {
                'Proactive Chat':{'value':'True','isDisplayable':true},
                'Time On Page':{'value': timeToWaitBeforeOfferingProactiveChatInMilliseconds ,'isDisplayable':true},
                'Page URL':{'value': window.location.href,'isDisplayable':true},
            };
        });
		
		//Display proactive chat invite after 'timeToWaitBeforeOfferingProactiveChatInMilliseconds' milliseconds
        setTimeout(function(){
            Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Just checking in to see if I can help answer any questions you may have."}, false)
        },timeToWaitBeforeOfferingProactiveChatInMilliseconds);
    });
</script>

Σενάριο 2: Ο πελάτης επισκέπτεται μια ιστοσελίδα πολλές φορές

Ο Θωμάς περιηγείται στην ιστοσελίδα της κοινότητας του Microsoft Surface και αναζητά πληροφορίες σχετικά με τη συσκευή Microsoft Surface. Ο Thomas έχει επισκεφθεί μια ιστοσελίδα πολλές φορές, αλλά δεν είναι σε θέση να βρει τις απαντήσεις.

Πραγματοποιώντας αυτό το σενάριο, ο οργανισμός προσφέρει ένα αίτημα συνομιλίας στον πελάτη με το ακόλουθο μήνυμα.

Hi! Do you have a question on Surface device ? I am here to help.

Δείγμα κώδικα

<!-- Code to show proactive chat invite(after given time) after visitor visits the webpage given number of time -->

<!-- Operations on cookies like creating cookies, deleting cookies etc.. -->
<script>
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000*365)); // 1 yr from now 
/* ####################### start set cookie  ####################### */
function setCookie(name, value, expires, path, domain, secure) {
  var thisCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = thisCookie;
}

/* ####################### start get cookie value ####################### */
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
/* ####################### end get cookie value ####################### */
}

/* ####################### start get cookie (name) ####################### */
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
/* ####################### End get cookie (name) ####################### */

/* ####################### Start delete cookie ####################### */
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
/* ####################### End of delete cookie ####################### */

/* ####################### Count number of visits to current webpage ####################### */
function VisitCounter(){
var visits = GetCookie("timesPageVisited");
if (!visits) { visits = 1; 
document.write("Select a Conversation Space");
} 
else { 
visits = parseInt(visits) + 1;document.write("Select a Conversation Space.");}
setCookie("timesPageVisited", visits,expdate);
}
/* ####################### End of count number of visits to current webpage ####################### */
</script>


<!-- Count number of visits to current webpage -->
<script>
VisitCounter();
</script>

<script id="Proactivechattrigger">
	// Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		// setting Context variables
        Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
            return {
                'Proactive Chat':{'value':'True','isDisplayable':true},
                'No. of visits':{'value':'2','isDisplayable':true},
                'Forums':{'value':'Surface Devices','isDisplayable':true},
            };
        });

        setTimeout(function(){
			var timeToWaitBeforeOfferingProactiveChatInMilliseconds = 5000;//Time to wait before offering proactive chat to webpage visitor
            var visits = GetCookie("timesPageVisited");
			//Check if webpage has been visited 2 or more times by the user.
            if (visits > 2) {		
				//Display proactive chat invite
                Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Do you have a question on Surface device? I am here to help."}, false);
                DeleteCookie("timesPageVisited");//Delete the cookie to reset the counter
            }
        },timeToWaitBeforeOfferingProactiveChatInMilliseconds);
    });
</script>

Σενάριο 3: Ο πελάτης ελέγχει την κατάσταση της ανοιχτής υπόθεσης υποστήριξης

Ο Jacob περιηγείται στη σελίδα υποστήριξης για συσκευές Microsoft Surface για να βρει περισσότερες πληροφορίες σχετικά με την ανοιχτή υπόθεση υποστήριξης. Ο Jacob βρίσκεται στη σελίδα για 10 δευτερόλεπτα και στη συνέχεια προσφέρεται μια προληπτική συνομιλία με το ακόλουθο μήνυμα.

Hi! How are you doing today? The status of the case:<caseid> is in progress. Would you like to get more details?

Δείγμα κώδικα

<!--Code to show proactive chat invite after visitor has spend given time on the webpage, with relevant details about user.-->
<script id="Proactivechattrigger">
	// Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		var timeToWaitBeforeOfferingProactiveChatInMilliseconds = 10000;//Time to wait before offering proactive chat to webpage visitor
		var caseId = '< your case id relevant to the user.>';//Set case id relevant to the user.
		// setting Context variables
        Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
            return {
                'Proactive Chat':{'value':'True','isDisplayable':true},
                'Case Id':{'value':caseId,'isDisplayable':true}
            };
        });
		
		//Show proactive chat invite after 'timeToWaitBeforeOfferingProactiveChatInMilliseconds' milliseconds
        setTimeout(function(){
            Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! How are you doing today? The status of the case: " + caseId + " is in progress. Would you like to get more details?"}, false)
        },timeToWaitBeforeOfferingProactiveChatInMilliseconds);
    });
</script>

Σενάριο 4: Ο πελάτης προσπαθεί να αποχωρήσει από μια ιστοσελίδα αφού αφιερώσει λίγο χρόνο σε αυτήν

Η Amy περιηγείται σε μια ιστοσελίδα για 15 δευτερόλεπτα και δεν είναι ικανοποιημένη με τις διαθέσιμες πληροφορίες. Όταν η Amy πρόκειται να αλλάξει καρτέλες στο πρόγραμμα περιήγησης web, αποστέλλεται στην Amy ένα προληπτικό αίτημα συνομιλίας με το ακόλουθο μήνυμα.

Hi! Just checking in to see if I can help answer any questions you may have.

Δείγμα κώδικα

//Code to show proactive chat invite when visitor tries to leave page after spending given time (15 seconds in this case) on the webpage. This invite is offered once and only for the first time. All subsequent tries to leave page are ignored and proactive chat is not offered in them. 
<script id="Proactivechattrigger">
	//Track if proactive chat has been already offered to the visitor
	var hasProactiveChatBeenOffered = false;	
	//Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		var timeToWaitBeforeEnablingOfferingProactiveChatInMillisecondsOnLeaving = 15000; //Time to wait before Offering proactive chat to webpage visitor
		
		//Enable showing proactive chat invite on leaving page after browsing page for 'timeToWaitBeforeEnablingOfferingProactiveChatInMillisecondsOnLeaving' milliseconds
        setTimeout(function(){
			//Show proactive chat invite on leaving page
			window.document.body.onmouseleave = function(){
				//Offer proactive chat if it has not been offered earlier during this visit
				if( hasProactiveChatBeenOffered == false )
				{
					// Set this to true as proactive chat has been almost offered.
					hasProactiveChatBeenOffered = true;
					//Setting Context variables
					Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
						return {
							'Proactive Chat':{'value':'True','isDisplayable':true},
							'Page URL':{'value': window.location.href,'isDisplayable':true},
						};
					});
					//Offer proactive chat
					Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Just checking in to see if I can help answer any questions you may have."}, false);
				}
			};
        },timeToWaitBeforeEnablingOfferingProactiveChatInMillisecondsOnLeaving);
    });
</script>

Σενάριο 5: Ο πελάτης περιηγήθηκε σε μια άλλη ιστοσελίδα και, στη συνέχεια, αφιερώνει χρόνο στην τρέχουσα ιστοσελίδα

Η Amy περιηγήθηκε στο έγγραφο FAQ του προϊόντος και βρίσκεται στη σελίδα της Γνωσιακής βάσης για περισσότερα από 15 δευτερόλεπτα. Στην Amy προσφέρεται προληπτικά μια συνεδρία συνομιλίας με το ακόλουθο μήνυμα.

Hi! Just checking in to see if I can help answer any questions you may have.

Δείγμα κώδικα

//Code to show proactive chat invite when visitor spends given time on current page, after coming from given last visited page
<script id="Proactivechattrigger">
	var lastVisitedPage = "www.contoso.com/FAQ";// last visited page. A visitor coming form this page will be shown proactive chat invite after given time on current page
	// Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		var timeToWaitBeforeOfferingProactiveChat = 15000;//Time to wait before Offering proactive chat to webpage visitor
		//Check if referrer page( read: https://www.w3schools.com/jsref/prop_doc_referrer.asp ) is same as last Visited page 
		if( window.document.referrer == lastVisitedPage) )
		{
			//Show proactive chat invite after browsing page for 'timeToWaitBeforeOfferingProactiveChat' milliseconds
			setTimeout(function(){
				//Setting Context variables
				Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
				return {
							'Proactive Chat':{'value':'True','isDisplayable':true},
							'Page URL':{'value': window.location.href,'isDisplayable':true},
							'Last Page URL':{'value': window.document.referrer,'isDisplayable':true}
						};
				});
				//Offer proactive chat
				Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Just checking in to see if I can help answer any questions you may have."}, false);
			},timeToWaitBeforeOfferingProactiveChat);
		}
    });
</script>

Σενάριο 6: Ο πελάτης συνδέεται από μια συγκεκριμένη γεωγραφική περιοχή

Η Klarissa συνδέεται στον ιστότοπό σας από τη Ρουριτανία, όπου η εταιρεία σας εκτελεί ειδική έκπτωση σε προϊόντα. Μπορείτε να ρυθμίσετε ένα έναυσμα για πελάτες που προέρχονται από μια συγκεκριμένη τοποθεσία που ξεκινά προληπτικά μια περίοδο λειτουργίας συνομιλίας. Ζητείται από την Klarissa να συνομιλήσει με το ακόλουθο μήνυμα.

Hi! Just checking in to see if I can help answer any questions you may have.

Δείγμα κώδικα

Αυτό το δείγμα κώδικα δείχνει πώς μπορείτε να χρησιμοποιήσετε τα API γεωγραφικής τοποθεσίας του Bing για να γνωρίζετε τη γεωγραφική περιοχή του πελάτη και να προσφέρετε αίτημα συνομιλίας με βάση αυτό. Περισσότερες πληροφορίες σχετικά με τα API τοποθεσίας του Bing: API τοποθεσιών των Χαρτών Bing.

//Code to show proactive chat invite if visitor is visiting the page in a particular country or region
<script id="Proactivechattrigger">
	// Wait for Chat widget to load completely
    window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
		var countryNameWhereProactiveChatInviteShouldBeOffered = 'Ruritania';//Country name where proactive chat invite should be offered, if user is visiting webpage from this country
		
		// Get Country name using Bing Geolocation API and proactively offer chat if visitor's country matches with given country name
		function GetCountryUsingBingGeoLocationAPIAndOfferProactiveChatIfVisitorCountryMatchesWithGivenCountry( latitude, longitude, bingMapApiKey, countryToMatch) {
			var xhttp = new XMLHttpRequest();
			xhttp.onreadystatechange = function() {
			if (this.readyState == 4)
				if(this.status == 200) {
					console.log(this.responseText);
					var currentCountryName = JSON.parse(this.responseText).resourceSets[0].resources[0].address.countryRegion;
					//Check if visitor's country matches with given Country name
					if( currentCountryName == countryToMatch){
						alert(currentCountryName);
						// setting Context variables
						Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
						    return {
						        'Proactive Chat':{'value':'True','isDisplayable':true},
						        'Country':{'value': currentCountryName ,'isDisplayable':true},
						        'Page URL':{'value': window.location.href,'isDisplayable':true},
						    };
						});
						//Show proactive chat invite
						Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Just checking in to see if I can help answer any questions you may have."}, false);
					}
				}
				else{
					console.log("Bing Geolocation API call has failed and returned error: " + this.statusText);
				}
			};
			xhttp.open("GET", 'https://dev.virtualearth.net/REST/v1/Locations/'+ latitude +','+ longitude +'?key='+ bingMapApiKey, true);
			xhttp.setRequestHeader("Content-type", "application/json");
			xhttp.send();
		}
		
		//fetching latitude and longitude is success
		function successGetlatLong(position) {
			var latitude = position.coords.latitude;
			var longitude = position.coords.longitude;
			console.log('Your latitude is :'+latitude+' and longitude is '+longitude);
			//convert current loaction to a country/ region via Bing Geolocation APIs
			var bingMapApiKey = 'Enter your Bing Map API key';// Get Bing Map API key here : https://learn.microsoft.com/bingmaps/getting-started/bing-maps-dev-center-help/getting-a-bing-maps-key
			GetCountryUsingBingGeoLocationAPIAndOfferProactiveChatIfVisitorCountryMatchesWithGivenCountry( latitude, longitude, bingMapApiKey, countryNameWhereProactiveChatInviteShouldBeOffered);// get Country name using Bing Geolocation API and offer proctiveChat if visitor's country matches with Country name where proactive chat invite should be offered
		}
		
		//fetching latitude and longitude has failed
		function errorGetlatLong() {
			console.log('It seems browser was not allowed to access location. Please allow browser to access location.');
		}
		
		//fetch latitude and longitude via browser
		if (navigator.geolocation) {
			navigator.geolocation.getCurrentPosition(successGetlatLong, errorGetlatLong);
		} else {
			console.log('It seems like Geolocation, which is required for this page, is not enabled in your browser. Please use a browser which supports it.');
		}
    });
</script>

Σενάριο 7: Προσφέρετε προληπτικά συνομιλία στους πελάτες εντός συγκεκριμένης χρονικής περιόδου

Ας υποθέσουμε ότι ο οργανισμός σας εκτελεί εκπτώσεις κατά την εορταστική περίοδο μεταξύ συγκεκριμένων ημερομηνιών και θέλετε να προσφέρετε προληπτικά αιτήματα συνομιλίας στους πελάτες για να δείτε αν έχουν απορίες.

Δείγμα κώδικα

Το παρακάτω δείγμα κώδικα δείχνει πώς μπορείτε να προσφέρετε προληπτικά προσκλήσεις συνομιλίας σε πελάτες όταν επισκέπτονται τον ιστότοπό σας σε μια χρονική περίοδο.

//Code to show proactive chat invite if visitor visits webpage between given time period
<script id="Proactivechattrigger">
	// Wait for Chat widget to load completely
    window.addEventListener("load", function handleLivechatReadyEvent(){//lcw:ready
		var startTimeOfTimePeriod = new Date('01 Jan 2019 00:00:00 GMT');//start time of time period in which proactive chat will be shown to webpage visitor
		var endTimeOfTimePeriod = new Date('01 Jan 2100 00:00:00 GMT');//end time of time period in which proactive chat will be shown to webpage visitor
		var currentDateTime = new Date();//current date and time
		
		//Make sure that endTimeOfTimePeriod is always greater and equal to startTimeOfTimePeriod
		if( endTimeOfTimePeriod < startTimeOfTimePeriod)
		{
			console.log("The time period given for proactive chat has start time: " + startTimeOfTimePeriod.toGMTString() + " more that the end time: " + endTimeOfTimePeriod.toGMTString() + " of time period. So, proactive chat will not be offered.");
			return;
		}
		
		//Check if current date time is between given time period
		if( startTimeOfTimePeriod < currentDateTime && endTimeOfTimePeriod > currentDateTime){
			// setting Context variables
			Microsoft.Omnichannel.LiveChatWidget.SDK.setContextProvider(function contextProvider(){
				return {
					'Proactive Chat':{'value':'True','isDisplayable':true},
					'Page URL':{'value': window.location.href,'isDisplayable':true},
				};
			});
			//Show proactive chat invite 
			Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat({message: "Hi! Just checking in to see if I can help answer any questions you may have."}, false);
		}
    });
</script>

Σενάριο 8: Προσφέρετε προληπτικά συνομιλία με προκαταρκτική έρευνα στους πελάτες

Ας υποθέσουμε ότι ο οργανισμός σας θέλει εξουσιοδότηση συγκατάθεσης για να ξεκινήσει μια συνομιλία με έναν πελάτη ή θέλει να ρωτήσει σχετικά με τα θέματα που σχετίζονται με το ερώτημα του πελάτη πριν δρομολογήσει την περίοδο λειτουργίας στον κατάλληλο εκπρόσωπο.

Δείγμα κώδικα

Το παρακάτω δείγμα κώδικα δείχνει πώς μπορείτε να προσφέρετε προληπτικά συνομιλία με μια ερώτηση πριν από την έρευνα στους πελάτες σας.

window.addEventListener("lcw:ready", function handleLivechatReadyEvent(){
 Microsoft.Omnichannel.LiveChatWidget.SDK.startProactiveChat( 
 "Hi! How are you doing today? Do you wish to start a chat?",
 true);
 });

startProactiveChat API
Διαχείριση προσαρμοσμένου περιβάλλοντος
Ξεκινήστε μια συνομιλία
Εμφάνιση προσαρμοσμένου περιβάλλοντος
Αναφορά API JavaScript ζωντανής συνομιλίας