← view more API documentation

api.chat.sendNotificationToVisitor

Send a notification message to the visitor. The message will look like a notification, and will not show up as coming from a particular operator.

  • options.body the contents of the notification to send the visitor

Examples

Assure a visitor that the operator will be back later if there is no response from an operator in 60 seconds:

var lastMessageTimeout;
olark('api.chat.onMessageToVisitor', function(){
    clearTimeout(lastMessageTimeout);
    lastMessageTimeout = setTimeout(function(){
        olark('api.chat.sendNotificationToVisitor', {body: "the operator just stepped out for a moment"})
    }, 60000);
});

Discussion

Feel free to propose good uses for this method, or even drop us some suggestions for improvement! You can also join our mailing list to collaborate with other developers and get updates from us.