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.departments

Control the departments in your account.

Summary
$zopim.livechat.departmentsControl the departments in your account.
Functions
filterDisplay only the specified departments in the pre-chat form.
setVisitorDepartmentSet the visitor’s default department for the current session.
clearVisitorDepartmentClear the visitor’s default department.
getDepartmentReturn an object containing information about the specified department, including its id, name and status.
getAllDepartmentsReturn a list of all enabled departments containing information about each department including its id, name and status.
setLabelSet the department label.

Functions

filter

function filter(/* department1[, department2[, department3[, ...]]] */)

Display only the specified departments in the pre-chat form.  All other departments will be hidden regardless of their status.

Department names are matched in a case-insensitive manner.

Passing in no arguments causes all departments to be displayed.  If none of department names or IDs passed in are valid (e.g. an empty string is passed in), the department dropdown menu will be hidden.

Parameters

department1, department2, ...ID(s) or name(s) of department(s) to be displayed

Example

#NORUN
<script>

  $zopim(function() {
    $zopim.livechat.departments.filter('Marketing', 'Sales');
  });

</script>

setVisitorDepartment

function setVisitorDepartment(id)

Set the visitor’s default department for the current session.

Chat requests will be routed to this department unless the visitor selects another department in the pre-chat form or the department is offline.

Note: If the visitor has already started chatting, changes to the default department will not affect the department of the started chat.  The changes to the default department will also not take effect until a page change or refresh.  The department of the started chat will persist and be taken as the default department until a page change or refresh, even when the visitor has explicitly ended the chat.

Offline messages will also be routed to this department.

Parameters

id (number or string)Id or name of the department to be set

Example

#NORUN
<script>

  $zopim(function() {
    $zopim.livechat.departments.setVisitorDepartment('Marketing');
  });

</script>

clearVisitorDepartment

function clearVisitorDepartment()

Clear the visitor’s default department.

Note: If the visitor has already started chatting, changes to the default department will not affect the department of the started chat.  The changes to the default department will also not take effect until a page change or refresh.  The department of the started chat will persist and be taken as the default department until a page change or refresh, even when the visitor has explicitly ended the chat.

getDepartment

function getDepartment(id)

Return an object containing information about the specified department, including its id, name and status.  Return undefined if the department is not found or not enabled.

Note: This function should only be called after the widget is connected (see example).

Parameters

id (number or string)Id or name of the department

Example

#NORUN
<script>

  $zopim(function() {
    $zopim.livechat.setOnConnected(function() {
      var marketing_department = $zopim.livechat.departments.getDepartment('Marketing');
      // do something
    });
  });

</script>

getAllDepartments

function getAllDepartments()

Return a list of all enabled departments containing information about each department including its id, name and status.

Note: This function should only be called after the widget is connected (see example).

Example

#NORUN
<script>

  $zopim(function() {
    $zopim.livechat.setOnConnected(function() {
      var all_departments = $zopim.livechat.departments.getAllDepartments();
      // do something
    });
  });

</script>

setLabel

function setLabel(label)

Set the department label.

Parameters

labelA string to be used

Example

<script>

  $zopim(function() {
    $zopim.livechat.departments.setLabel('Select a department');
  });

</script>
function filter(/* department1[, department2[, department3[, ...]]] */)
Display only the specified departments in the pre-chat form.
function setVisitorDepartment(id)
Set the visitor’s default department for the current session.
function clearVisitorDepartment()
Clear the visitor’s default department.
function getDepartment(id)
Return an object containing information about the specified department, including its id, name and status.
function getAllDepartments()
Return a list of all enabled departments containing information about each department including its id, name and status.
function setLabel(label)
Set the department label.