If you install the BotFramework-WebChat version greater than 0.10.7
, you can directly use the BotFramework-WebChat in ng application.
- Install the webchat sdk:
npm install botframework-webchat
fill the style files in .angular-cli.json
file:
"styles": [
"../node_modules/botframework-webchat/botchat.css",
"../node_modules/botframework-webchat/botchat-fullwindow.css"
],
Try the sample in component as discussed at https://github.com/Microsoft/BotFramework-WebChat/issues/478:
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {App} from "botframework-webchat";
@Component({
selector: 'app-root',
template: `<div id="bot-chat-container" #botWindow></div>`,
})
export class AppComponent implements OnInit {
@ViewChild("botWindow") botWindowElement: ElementRef;
ngOnInit(): void {
App({
directLine: {secret: 'secret goes here'},
user: {id: 'user'},
bot: {id: 'bot'},
}, this.botWindowElement.nativeElement)
}
}