olark('api.chat.setOperatorGroup', {
	group: // Group ID from https://www.olark.com/op
});

Arguments

  • options.group
    the Group ID that you want to lock to

Notes

Note: This method requires a plan that supports the Groups feature.

Locks the visitor to a specific group of operators. All messages from the visitor will now go to that group of operators instead of all operators. See the operator configuration page to find the Group ID.

Choose operator group by button click

When the visitor clicks the Talk to our Sales Team button, lock to the Sales Group specifically.

<script>
    document.getElementById('talk-to-sales').onclick = function() {

        olark('api.chat.setOperatorGroup', {
            group: 'abcdef123456'
        });

        olark('api.box.expand');

    }
</script>

This example assumes that the Sales Group ID is ‘abcdef123456’. You can find the Group ID on the operator configuration page.

Switch to a backup operator group

This is a special rule that notifies a backup group of operators when a customer initiates a conversation but doesn’t receive a response within a minute.

Note: This script may not work well without routing to ALL operators enabled in the Setup page.

<script>
// Creates a new Targeted Chat rule
olark('api.rules.defineRule', {

    id: '44',
    description: "notify backup team if customers aren't responded to within 60 seconds ",
    condition: function(pass) {

        // Retrieve info about the chat
        olark('api.visitor.getDetails', function(details) {

            // Trigger this action if message hasn't been responded to within 60 seconds (NOTE: This will trigger if an operator initiates a message)

            if ((details.messageCountForThisVisit < 2) && (details.secondsSinceLastMessage > 60) && (details.isConversing)) {
                pass();
            }

        });
    },
    action: function() {

        // Change the group to the backup group using their Group ID
        olark('api.chat.setOperatorGroup', {
            group: 'YOURBACKUPGROUPID'
        });

        // Send a notification to the backup group operators
        olark('api.chat.sendNotificationToOperator',
        {
            body: "Visitor has been waiting more than 60 seconds"
        });

    },

    // Trigger the rule page change if customer still hasn't received response
    perPage: true

});
</script>