← view more API documentation

api.chat.onBeginConversation

Whenever a visitor or operator sends the first message, the given callback will be triggered.

Examples

Olark already sends some nice information to the operator when the chat first begins, but you can send your own information too. Let's say a visitor on your site is a premium customer:

olark('api.chat.onBeginConversation', function() {
    if (currentVisitorIsPremium) {
        olark('api.chat.sendNotificationToOperator', {body: "this is a premium customer"});
    }
});

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.