nsc_Visitor.messagesCount( [from] )

allows for getting the number of messages in an ongoing chat.

Accepts the optional parameter from that designates the message type (by visitor or operator). Can assume the visitor and operator values accordingly. If the method is called without specifying the type, the overall number of messages in the current chat will be returned.

The return integer specifies the number of messages.

Use-case

$(function() {
    // Adding a listener for the visitor's message sending event
    $(document).on('netroxmessagesend', function(event) {
        if (nsc_Visitor.messagesCount() > 100) {    // If the chat has over 100 messages
            alert("Do you have any hobbies aside from conversing with consultants?");
        }
    });
});

All rights reserved. Copyright © 2017 Netrox SC
Host CMS