api.chat.onCommandFromOperator
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
event.command.namethe name of the command (e.g. "track")event.command.bodythe contents of the message (e.g. "this is a lead")
Examples
Use the command "!faq" to send a visitor to your FAQ page:
olark('api.chat.onCommandFromOperator', function(event) {
if (event.command.name == 'faq') {
window.location = "http://www.example.com/pages/faq"
}
});
Use the command "!note follow up with this customer" to add some notes about following up with this customer to your CRM:
olark('api.chat.onCommandFromOperator', function(event) {
if (event.command.name == 'note') {
yourCRM.addNoteToCustomer(event.command.body);
}
});
Olark also has a bunch of operator !commands built-in. Just type "!help" at any time to see the list of commands you can perform.
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.