AlisonVilela / ngx-zendesk-webwidget

ngx-zendesk-webwidget based on angular-zendesk-widget
37 stars 37 forks source link

ngx-zendesk-webwidget

Maintainability Build Status contributions welcome

Zendesk-Webwidget for Angular 2+

Zendesk-Webwidget for Angular 1.x see here

Installation

Via npm:

npm install ngx-zendesk-webwidget --save

Usage

The examples were made using the classic web widget

1. Import the 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 { }

SharedModule

@NgModule({
    exports: [
      CommonModule,
      NgxZendeskWebwidgetModule
    ]
})
export class SharedModule { }
Configuration
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 { }
Configuration with Lazyload
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 { }

2. Init the NgxZendeskWebwidgetService

For your application
import { NgxZendeskWebwidgetService } from 'ngx-zendesk-webwidget';

@Component({
  selector: 'app',
  templateUrl: './app.html'
})
export class app {

  constructor(private _NgxZendeskWebwidgetService: NgxZendeskWebwidgetService) { }

}
With Lazyload
import { NgxZendeskWebwidgetService } from 'ngx-zendesk-webwidget';

@Component({
  selector: 'app',
  templateUrl: './app.html'
})
export class app {

  constructor(private _NgxZendeskWebwidgetService: NgxZendeskWebwidgetService) {
    this._NgxZendeskWebwidgetService_.initZendesk();
  }

}

3. Example to usage

  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');
  }

API

NgxZendeskWebwidgetService

Web Widget (Messenger)

Web widget (Classic)

NgxZendeskWebwidgetConfig

Issues

Please report bugs and issues here.

To do

License

MIT © Alison Vilela

Change log

v3.0.1

v3.0.0

v2.1.1

v2.1.0

V2.0.0

V1.0.1

v1.0.0

v0.1.5

v0.1.4

v0.1.3

v0.1.2

v0.1.1

v0.1.0