Using the Olark api you can send your visitors a response if your agent does not reply to a message right away.
This script will automatically send a message to your visitor within 45 seconds of the agent not responding. Note that this script will only send a message to the visitor if the agent has never responded to them.
Important Notice: We’ll do our best to help with any questions you have. The API is intended to be self-serve for web developers, so we’re not able to write or debug your own code.
Script:
(function() {
var secondsUntilAutoDelay = 45;
var didSendMessageToVisitor = sessionStorage.getItem('didSendMessageToVisitor');
olark('api.chat.onMessageToVisitor', function() {
didSendMessageToVisitor = true;
sessionStorage.setItem('didSendMessageToVisitor', true);
});
olark('api.rules.defineRule', {
id: 'delayed_response',
description: 'Will send a response to the visitor after an agent doesn\'t respond.',
condition: function(pass) {
olark('api.visitor.getDetails', function(details) {
if (details.isConversing &&
!didSendMessageToVisitor &&
details.secondsSinceLastMessageToOperator >= secondsUntilAutoDelay) {
pass();
}
});
},
// Message the visitor, but also notify the agent that they
// hit this delay limit.
action: function() {
olark('api.chat.sendMessageToVisitor', {
body: 'Sorry about the delay, I\'m a bit busy at the moment. Be with you in just a moment.'
});
olark('api.chat.sendNotificationToOperator', {
body: 'Automated delay message has been sent to visitor.'
});
},
// Only do this once per visit.
perVisit: true
});
})();