Zopim’s livechat 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.
Also, see the component specific classes, $zopim.livechat.bubble and $zopim.livechat.window.
<script>
$zopim.livechat.set({
language: 'fr',
name: 'Visitor',
email: 'visitor@site.com',
onStatus: function(s) { alert(s) }
});
</script>| $zopim. | Zopim’s livechat API Some aspects of the Zopim widget can be customized. |
| 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 |
| setPhone | Set the visitor’s phone number |
| 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. |
function say( something, suggestion )
Make the visitor say something. If the 2nd parameter is true, it’ll only be a suggestion :)
<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>
function setLanguage( lang )
Shows the interface in the language specified. Please visit http://translate.zopim.com/ to see the list of supported languages.
| subtag | Language code listed at http://www.iana.org |
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>
function setGreetings( g )
Sets greeting messages
| greetings | Hash of <status> => [<short msg>, <long msg>] |
setGreetings({
'online': ['online short message', 'online long message'],
'offline': ['offline short message', 'offline long message'],
'away': ['away short message', 'away long message']
});
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.
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.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 phone number
function setPhone( phone )
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.
function setOnStatus( f )
Adds a callback function that’s called with the greeting whenever the online status changes.
function setOnGreeting( f )