Web SDK API

Open

zE('messenger', 'open');

Opens the Web SDK.

Close

zE('messenger', 'close');

Closes the Web SDK.

Set locale

zE('messenger:set', 'locale', newLocale<string>)

Sets the locale of the Web SDK. It overrides the Web SDK's default behavior of matching the same language an end user has set in their web browser.

The command takes a locale string as an argument. For a list of supported locales and associated codes, use the following Zendesk public REST API endpoint: https://support.zendesk.com/api/v2/rosetta/locales/public.json.

Note: This code should be placed immediately after the Web SDK code snippet.

Parameters
  • newLocale: String. The locale string to change the locale to.

Set zIndex

zE('messenger:set', 'zIndex', newZIndex<number>);

Sets the CSS property z-index on all the iframes for the Web SDK.

When two elements overlap, the z-index values of the elements determine which one covers the other. An element with a greater z-index value covers an element with a smaller one.

By default, all iframes in the Web SDK have a z-index value of 999999.

Parameters
  • newZIndex: Number. The z-index value to use for all iframes for the Web SDK
Example
zE('messenger:set', 'zIndex', 123);

Set cookies

zE('messenger:set', 'cookies', isEnabled<boolean>);

The Web SDK uses a mixture of cookies as well as local and session storage in order to function.

If the end user has opted out of cookies, you can use the command below to let the Web SDK know that it is unable to use any of these storage options.

Currently, disabling cookies will result in the Web SDK being hidden from the end user and all values in local and session storage being deleted.

Parameters
  • isEnabled: Boolean. If false, the Web SDK will be hidden from view and all stored data will be deleted.
Example
zE('messenger:set', 'cookies', false);