olark('api.chat.onCommandFromOperator',
	function(event) {
		// Callback function
	}
);

Arguments

  • event.command.body
    the contents of the message, e.g. 'this is a lead' (optional)
  • event.command.name
    the name of the command, e.g. 'track' (required)

Notes

Whenever a command is sent from the visitor, e.g. !track this is a lead, this will call the given callback with an event object.

Commands must begin with an exclamation point ! and come at the start of a message. You can also see a list of the default operator commands in our help section. To see these while chatting, type !help into a chat at any time to see the list of commands you can perform. Your visitors will not see the command unless specified.

Push the visitor to your FAQ page

Use the command !faq to send a visitor to your FAQ page:

<script>
olark('api.chat.onCommandFromOperator', function(event) {

    // Checks for the !faq command
    if (event.command.name == 'faq') {

        // Let the customer know what you're about to do
        olark('api.chat.sendMessageToVisitor', {
            body: "Let me point you to our FAQ page"
        });

        // Redirect the visitor's browser to your FAQ page
        window.location = "http://www.example.com/pages/faq"

    }

});
</script>

Add an optional piece of information

Create a custom command to notify a new chatter that there is a queue. By using !q and adding an integer, such as 2 after it, !q 2, you add a custom time into the message. This example tells the visitor that the operator will be with them in 2 minutes. If the operator entered !q 3, it would say 3 minutes. This example also tells the operator what has been sent.

<script>
olark('api.chat.onCommandFromOperator', function(event) {

    // Checks for the !q command
    if (event.command.name == 'q') {

        // Let the customer know what you're about to do
        olark('api.chat.sendMessageToVisitor', {
        body: "Hi there, chat is really busy, I'll be with you in " + (event.command.body) + " minutes"
        });

        olark('api.chat.sendNotificationToOperator', {
        body: "Telling customer you will be with them in " + (event.command.body) + " minutes"
        });

    }

});
</script>

Make a comment to follow up with a visitor

Create a custom followup command to add some notes about following up with this customer to your CRM:

<script>
olark('api.chat.onCommandFromOperator', function(event) {

    // Checks for the !comment command
    if (event.command.name == 'comment') {

        // This is an example of how you might send the event to your CRM
        // Check out the API of your CRM provider to see how to do this
        yourCRM.addNoteToCustomer(event.command.body);

    }

});
</script>