API reference
ZendeskWebWidget service
Section titled “ZendeskWebWidget service”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.
Properties
Section titled “Properties”| 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 |
Methods
Section titled “Methods”show(): void
Section titled “show(): void”Shows the Zendesk widget button if it’s currently hidden.
widget.show();hide(): void
Section titled “hide(): void”Hides the Zendesk widget button if it’s currently visible.
widget.hide();open(): void
Section titled “open(): void”Opens the Zendesk chat window if it’s currently closed.
widget.open();close(): void
Section titled “close(): void”Closes the Zendesk chat window if it’s currently open.
widget.close();showAndOpen(): void
Section titled “showAndOpen(): void”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',});login(token: string): Promise<void>
Section titled “login(token: string): Promise<void>”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}