$zopim.livechat
Zopim Live Chat API
Some aspects of the Zopim widget can be customized. For example, you can generate Javascript to set a visitor’s name and email after logging in. If our language auto-detection is not accurate, you can override it with setLanguage.
Most API functions return the API object itself so you can chain multiple calls together.
IMPORTANT: The only 2 calls you can make safely after the given Zopim script are
- $zopim(function() { ... })
- $zopim.set({ .... })
All other API calls should be wrapped inside a $zopim(function() { ... }).
Also, see the component specific classes, $zopim.livechat.bubble and $zopim.livechat.window.
Examples
<script>
$zopim(function() {
$zopim.livechat.setName('Logged in name');
$zopim.livechat.setEmail('user@somewhere.com');
});
</script><script>
$zopim(function() {
$zopim.livechat.set({
language: 'fr',
name: 'Visitor',
email: 'visitor@site.com',
onStatus: function(s) { alert(s) }
});
});
</script>| $zopim. | Zopim Live Chat API |
| Functions | |
| set | A convenience function to set more than 1 setting. |
| say | Make the visitor say something. |
| setName | Set the visitor’s name |
| setEmail | Set the visitor’s email |
| setNotes | Set the visitor’s notes, which will show up on the Dashboard. |
| setLanguage | Shows the interface in the language specified. |
| setGreetings | Sets greeting messages |
| setOnStatus | Adds a callback function that’s called with the status whenever the online status changes. |
| setOnGreeting | Adds a callback function that’s called with the greeting whenever the online status changes. |
| setStatus | Sets visitor status to ‘active’ or ‘idle’. |
say
function say( something, suggestion )
Make the visitor say something. If the 2nd parameter is true, it’ll only be a suggestion :)
Examples
<table width="100%" style="font-family: Arial" cellspacing="0" cellpadding="0">
<tr>
<th>Product</th>
<th>Price</th>
</tr>
<tr>
<td><img src="/images/sesame.jpg"> Sesame </td>
<td>20,000 raisins</td>
</tr>
<tr>
<td><img src="/images/pistachio.jpg"> Pistachio </td>
<td><a href="javascript:void($zopim.livechat.say('I\'d like a quote for Pistachio!'))">ask!</a></td>
</tr>
</table>setNotes
function setNotes( notes )
Set the visitor’s notes, which will show up on the Dashboard.
Parameters
| notes | Notes, maximum 2048 UTF-8 characters. Newlines are allowed. |
Examples
Chinchillas:
<a href="javascript:void($zopim.livechat.setNotes('Added white chinchilla to basket'))">Add White to Basket</a>
<a href="javascript:void($zopim.livechat.setNotes('Added standard grey chinchilla to basket'))">Add Standard Grey to Basket</a>setLanguage
function setLanguage( lang )
Shows the interface in the language specified. Please visit http://translate.zopim.com/ to see the list of supported languages.
Parameters
| subtag | Language code listed at http://www.iana.org |
Examples
Pick a language:
<a href="javascript:void($zopim.livechat.setLanguage('en'))">English</a>
<a href="javascript:void($zopim.livechat.setLanguage('pt'))">Portuguese</a>
<a href="javascript:void($zopim.livechat.setLanguage('sv'))">Swedish</a>
<a href="javascript:void($zopim.livechat.setLanguage('zh_CN'))">Chinese</a>setGreetings
function setGreetings( g )
Sets greeting messages
Parameters
| greetings | Hash of <status> => [<short msg>, <long msg>] |
Examples
$zopim(function() {
$zopim.livechat.setGreetings({
'online': ['online short message', 'online long message'],
'offline': ['offline short message', 'offline long message'],
'away': ['away short message', 'away long message']
});
});setOnGreeting
function setOnGreeting( f )
Adds a callback function that’s called with the greeting whenever the online status changes. The callback function will be called with an object with 2 properties: bar & window, corresponding to the appropriate greeting. Remember to put your script after the Zopim script.
Example
Livechat is: <b id="chat_status">checking...</b><br/>
Bar: <i id="chat_greeting_bar"></i><br/>
Window: <i id="chat_greeting_window"></i><br/>
<script>
function updateStatus(s) {
document.getElementById('chat_status').innerHTML = s;
}
function updateGreeting(g) {
document.getElementById('chat_greeting_bar').innerHTML = g.bar;
document.getElementById('chat_greeting_window').innerHTML = g.window;
}
$zopim(function() {
$zopim.livechat
.setOnStatus(updateStatus)
.setOnGreeting(updateGreeting);
});
</script>A convenience function to set more than 1 setting.
function set( hash )
Make the visitor say something.
function say( something, suggestion )
Set the visitor’s name
function setName( name )
Set the visitor’s email
function setEmail( )
Set the visitor’s notes, which will show up on the Dashboard.
function setNotes( notes )
Shows the interface in the language specified.
function setLanguage( lang )
Sets greeting messages
function setGreetings( g )
Adds a callback function that’s called with the status whenever the online status changes.
var last_known_status; api.on( 'status', function(s) { last_known_status = s } ); function setOnStatus(f)
Adds a callback function that’s called with the greeting whenever the online status changes.
function setOnGreeting( f )
Sets visitor status to ‘active’ or ‘idle’.
function setStatus( s )
