Skip to content

API reference

ZendeskWebWidget is @Injectable() without providedIn: 'root', so inject(ZendeskWebWidget) throws unless provideZendeskWebWidget() is in your providers.

Every method except login() degrades gracefully when the Zendesk script has not loaded: it logs a warning and returns. show(), hide(), open(), and close() also return early when the widget is already in the requested state, so if the signal and Zendesk’s own state ever drift, those calls silently do nothing.

| Property | Type | Description | | ----------- | ----------------- | --------------------------------------------------- | | isOpen | Signal<boolean> | Computed signal indicating if the widget is open | | isVisible | Signal<boolean> | Computed signal indicating if the widget is visible |

Shows the Zendesk widget button if it’s currently hidden.

widget.show();

Hides the Zendesk widget button if it’s currently visible.

widget.hide();

Opens the Zendesk chat window if it’s currently closed.

widget.open();

Closes the Zendesk chat window if it’s currently open.

widget.close();

Convenience method that shows the widget and opens the chat window. It also replays the userConversationFields returned by the auth method configured through withZendeskWebWidgetAuth. Fields passed to setFields() are not replayed.

widget.showAndOpen();

setFields(fields: Record<string, string>): void

Section titled “setFields(fields: Record<string, string>): void”

Sets custom conversation fields that will be visible to support agents.

Object keys must be Zendesk conversation-field IDs, not display names — the service maps each entry to { id: key, value }. Arbitrary keys silently no-op on Zendesk’s side.

widget.setFields({
'360000123456': '12345',
'360000123457': 'premium',
});

Authenticates a user with a JWT token. Rejects if the Zendesk script has not loaded yet, so wrap the call:

try {
await widget.login('your-jwt-token');
} catch {
// Script not loaded — the widget is unavailable this page load
}