Zopim is now called Zendesk Chat. All API functionality will continue to work as normal and the namespace will not change in the immediate future.

Javascript API

$zopim.livechat.window

Customize and control the chat window.

Summary
$zopim.livechat.windowCustomize and control the chat window.
Functions
setColorSet the color of the widget.
setSizeSet the size of the chat window.
showShow the chat window.
hideHide the chat window.
onShowRegister a callback to be fired when the chat window is shown.
onHideRegister a callback to be fired when the chat window is hidden.
setTitleSet the title of the chat window.
toggleToggle the visibility of the chat window.
getDisplayGet the current visibility of the chat window.
setOffsetVerticalSet the vertical offset of the chat window from the edge of the browser window.
setOffsetHorizontalSet the horizontal offset of the chat window from the edge of the browser window.
setPositionSet position of the chat window.
openPopoutAttempts to open the live chat widget in a new window.

Functions

setColor

Set the color of the widget.

Important: This function is deprecated and may be removed in the future.  Use “$zopim.livechat.theme.setColor” instead.

Note: theme.reload must be called after setColor for changes to take effect (see example below).

Parameters

colorWidget color, in hexadecimal format (‘#AABBCC’)

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.setColor('#FFCC00');
    $zopim.livechat.theme.reload(); // apply new theme settings
  });

</script>

setSize

Set the size of the chat window.  Allowed values: small, medium, large.

Parameters

sizeChat window size (string)

Example

Select size:
<a href="javascript:void($zopim.livechat.window.setSize('small'))">Small</a>
<a href="javascript:void($zopim.livechat.window.setSize('medium'))">Medium</a>
<a href="javascript:void($zopim.livechat.window.setSize('large'))">Large</a>

show

function show()

Show the chat window.

Mobile Widget (non-overlay mode only)

  • If on a mobile device, attempts to open the live chat widget in a new window instead.
  • May not work on some devices or configurations.
  • Important: Should only be called from a user event listener callback.  See example for openPopout.

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.show();
  });

</script>

hide

function hide()

Hide the chat window.

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.hide();
  });

</script>

onShow

function onShow(callback)

Register a callback to be fired when the chat window is shown.

Note: the callback will not be fired if the chat window was shown using an API call.

Parameters

callbackFunction to be registered

onHide

function onHide(callback)

Register a callback to be fired when the chat window is hidden.

Note: the callback will not be fired if the chat window was hidden using an API call.

Parameters

callbackFunction to be registered

setTitle

function setTitle(title)

Set the title of the chat window.

Parameters

titleChat window title (string)

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.setTitle('Zopim Chat Support');
  });

</script>

toggle

function toggle()

Toggle the visibility of the chat window.

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.toggle();
  });

</script>

getDisplay

function getDisplay()

Get the current visibility of the chat window.

Example

<script>

  $zopim(function() {
    alert('Chat window is visible: ' + $zopim.livechat.window.getDisplay());
  });

</script>

setOffsetVertical

function setOffsetVertical(distance)

Set the vertical offset of the chat window from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window, in pixels (number)

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.setOffsetVertical(20);
  });

</script>

setOffsetHorizontal

function setOffsetHorizontal(distance)

Set the horizontal offset of the chat window from the edge of the browser window.

Parameters

distanceDistance from the edge of the browser window (in pixels)

Example

<script>

  $zopim(function() {
    $zopim.livechat.window.setOffsetHorizontal(30);
  });

</script>

setPosition

function setPosition(position)

Set position of the chat window.

Allowed values

  • br (Bottom right)
  • bl (Bottom left)
  • tr (Top right)
  • tl (Top left)

Parameters

positionChat window position (string)

Example

Select chat window position:
<a href="javascript:void($zopim.livechat.window.setPosition('br'))">Bottom right</a>
<a href="javascript:void($zopim.livechat.window.setPosition('bl'))">Bottom left</a>
<a href="javascript:void($zopim.livechat.window.setPosition('tr'))">Top right</a>
<a href="javascript:void($zopim.livechat.window.setPosition('tl'))">Top left</a>

openPopout

function openPopout()

Attempts to open the live chat widget in a new window.  On the mobile widget, this API will ignore the “Overlay Window” setting in dashboard and open a new window/tab.  If simply showing the mobile overlay window is the intended behavior, use “$zopim.livechat.window.show” instead.

May not work on some devices or configurations.

Important: Should only be called from a user event listener callback.  See example.

Example

<a href="javascript:void($zopim.livechat.window.openPopout())">Open chat in new window</a>
function show()
Show the chat window.
function hide()
Hide the chat window.
function onShow(callback)
Register a callback to be fired when the chat window is shown.
function onHide(callback)
Register a callback to be fired when the chat window is hidden.
function setTitle(title)
Set the title of the chat window.
function toggle()
Toggle the visibility of the chat window.
function getDisplay()
Get the current visibility of the chat window.
function setOffsetVertical(distance)
Set the vertical offset of the chat window from the edge of the browser window.
function setOffsetHorizontal(distance)
Set the horizontal offset of the chat window from the edge of the browser window.
function setPosition(position)
Set position of the chat window.
function openPopout()
Attempts to open the live chat widget in a new window.