Once the package is installed, import the Dialoguewise module into the app.module. For this you will need to add
import {DialogueWiseModule} from 'dialoguewise';
and DialogueWiseModule under imports. Your code should now look something like this.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import {DialogueWiseModule} from 'dialoguewise';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
DialogueWiseModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Now you are ready to call the Dialoguewise API from your component and get the content. You will need to import the DialogueWiseService and GetContentsRequest
import {DialogueWiseService,GetContentsRequest} from 'dialoguewise';
Now prepare the payload for which you will need to pass the access token and slug.
var request:GetContentsRequest = new GetContentsRequest();
request.accessToken="[Access Token]";
request.slug="[The Slug]";
If your dialogue uses variables and you wish to pass variable values then you will need to set the variableList property as well.
request.variableList = new Map<string,[Datatype you want to pass like string or number]>();
request.variableList.set("@variableName",[The variable value]);
You’re all set now. You can call the getContents method and pass the payload.
this.dialoguewise.getContents(request).subscribe(res=>
//Your content will be available in the res object
,null,()=>{
//Do stuff once content is delivered
});
A sample project is available on Github which can give you a better understanding.