Zendesk-Webwidget for Angular 2+
Zendesk-Webwidget for Angular 1.x see here
Via npm:
npm install ngx-zendesk-webwidget --save
The examples were made using the classic web widget
NgxZendeskWebwidgetModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxZendeskWebwidgetModule } from 'ngx-zendesk-webwidget';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxZendeskWebwidgetModule.forRoot()
],
bootstrap: [AppComponent]
})
export class AppModule { }
@NgModule({
exports: [
CommonModule,
NgxZendeskWebwidgetModule
]
})
export class SharedModule { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxZendeskWebwidgetModule, NgxZendeskWebwidgetConfig } from 'ngx-zendesk-webwidget';
import { AppComponent } from './app';
export class ZendeskConfig extends NgxZendeskWebwidgetConfig {
accountUrl = 'yourdomain.zendesk.com';
callback(zE) {
// You can call every command you want in here
// zE('webWidget', 'hide');
// zE('webWidget', 'show');
}
}
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
NgxZendeskWebwidgetModule.forRoot(ZendeskConfig)
],
bootstrap: [AppComponent]
})
export class AppModule { }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxZendeskWebwidgetModule, NgxZendeskWebwidgetConfig } from 'ngx-zendesk-webwidget';
import { AppComponent } from './app';
export class ZendeskConfig extends NgxZendeskWebwidgetConfig {
override lazyLoad = true;
accountUrl = 'yourdomain.zendesk.com';
callback(zE) {
// You can call every command you want in here
// zE('webWidget', 'hide');
// zE('webWidget', 'show');
}
}
@NgModule({
imports: [
BrowserModule,
HttpClientModule,
NgxZendeskWebwidgetModule.forRoot(ZendeskConfig)
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
NgxZendeskWebwidgetService
import { NgxZendeskWebwidgetService } from 'ngx-zendesk-webwidget';
@Component({
selector: 'app',
templateUrl: './app.html'
})
export class app {
constructor(private _NgxZendeskWebwidgetService: NgxZendeskWebwidgetService) { }
}
import { NgxZendeskWebwidgetService } from 'ngx-zendesk-webwidget';
@Component({
selector: 'app',
templateUrl: './app.html'
})
export class app {
constructor(private _NgxZendeskWebwidgetService: NgxZendeskWebwidgetService) {
this._NgxZendeskWebwidgetService_.initZendesk();
}
}
constructor(private _NgxZendeskWebwidgetService: NgxZendeskWebwidgetService) {
this._NgxZendeskWebwidgetService.zE('webWidget', 'identify', {
name: 'Fulano de Tal',
email: 'your_user_email@email.com'
});
this._NgxZendeskWebwidgetService.zE('webWidget', 'prefill', {
name: {
value: 'Fulano de Tal',
readOnly: true
},
email: {
value: 'your_user_email@email.com',
readOnly: true
}
});
this._NgxZendeskWebwidgetService.zE('webWidget', 'show');
}
logout() {
this._NgxZendeskWebwidgetService.zE('webWidget', 'hide');
}
zE('webWidget:<action>', '<event|property>', <parameters>)
: All commands follow the same basic syntax. Please see Zendesk Documentation for more information.lazyLoad
: Boolean for activate Lazyload initialization of Zendesk Web WidgettimeOut
: Timeout in milliseconds of the timer before opening the widget, zendesk unfortunately needs to load more files after the initial promise has been resolved, such as translation files. (default: 30 seconds)injectionTag
: You can identify which tag will be used as a reference for widget injection('head', 'body', 'script'). (Default: 'head')accountUrl
: Url of your domain (example.zendesk.com)callback
: Callback, executed after Zendesk loadedPlease report bugs and issues here.
MIT © Alison Vilela