API

$zopim.livechat

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>
Summary
$zopim.livechatZopim’s livechat API Some aspects of the Zopim widget can be customized.
Functions
setA convenience function to set more than 1 setting.
sayMake the visitor say something.
setNameSet the visitor’s name
setEmailSet the visitor’s email
setPhoneSet the visitor’s phone number
setLanguageShows the interface in the language specified.
setGreetingsSets greeting messages
setOnStatusAdds a callback function that’s called with the status whenever the online status changes.
setOnGreetingAdds a callback function that’s called with the greeting whenever the online status changes.

Functions

set

function set(hash)

A convenience function to set more than 1 setting.  Accepts a hash of settings.

Parameters

hashAn object of <setting_name> => <value> pairs

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>

setName

function setName(name)

Set the visitor’s name

Parameters

nameThe visitor’s name

setEmail

function setEmail(email)

Set the visitor’s email

Parameters

emailThe visitor’s email

setPhone

function setPhone(phone)

Set the visitor’s phone number

Parameters

phoneThe visitor’s phone number

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

subtagLanguage code listed at http://www.iana.org/assignments/language-subtag-registry

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

greetingsHash of <status> => [<short msg>, <long msg>]

Examples

setGreetings({
  'online':  ['online short message',  'online long message'],
  'offline': ['offline short message', 'offline long message'],
  'away':    ['away short message',    'away long message']
});

setOnStatus

function setOnStatus(f)

Adds a callback function that’s called with the status whenever the online status changes.  Remember to put your script after the Zopim script.

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.livechat
    .setOnStatus(updateStatus)
    .setOnGreeting(updateGreeting);
</script>
function set(hash)
A convenience function to set more than 1 setting.
function say(something,
suggestion)
Make the visitor say something.
function setName(name)
Set the visitor’s name
function setEmail(email)
Set the visitor’s email
function setPhone(phone)
Set the visitor’s phone number
function setLanguage(lang)
Shows the interface in the language specified.
function setGreetings(g)
Sets greeting messages
function setOnStatus(f)
Adds a callback function that’s called with the status whenever the online status changes.
function setOnGreeting(f)
Adds a callback function that’s called with the greeting whenever the online status changes.