How to use the botframework-webchat.DirectLine function in botframework-webchat

To help you get started, we’ve selected a few botframework-webchat examples, based on popular ways it is used in public projects.

github SharePoint / sp-dev-fx-extensions / samples / react-msal-bot / spfx / src / extensions / graphBot / components / GraphBot.tsx View on Github external
private async _login()  {

        this.setState({
            isBotInitializing :true,
            showPanel: true,
        });

        // Get the conversation id if there is one. Otherwise, a new one will be created
        const conversationId = this._storage.local.get(this.CONVERSATION_ID_KEY);

        // Initialize the bot connection direct line
        this._botConnection = new DirectLine({
            secret: this._directLineSecret,
            webSocket: false, // Needed to be able to retrieve history
            conversationId: conversationId ? conversationId : null,
        });

        this._botConnection.connectionStatus$
        .subscribe((connectionStatus) => {
            switch (connectionStatus) {
                // Successfully connected to the converstaion.
                case ConnectionStatus.Online :
                    if (!conversationId) {
                        // Store the current conversation id in the browser session storage
                        // with 15 minutes expiration
                        this._storage.local.put(
                            this.CONVERSATION_ID_KEY, this._botConnection["conversationId"], 
                            Util.dateAdd(new Date(), "minute", 15)
github microsoft / BotFramework-Emulator / src / client / mainView.tsx View on Github external
}

                let botChanged = false;
                if (this.botId !== settings.serverSettings.activeBot) {
                    this.botId = settings.serverSettings.activeBot || '';
                    botChanged = true;
                }

                if (conversationChanged || userChanged || botChanged) {
                    if (this.directline) {
                        this.directline.end();
                        this.directline = undefined;
                    //    log.debug(`ended conversation`);
                    }
                    if (this.conversationId.length && this.userId.length && this.botId.length) {
                        this.directline = new BotChat.DirectLine({
                            secret: settings.conversation.conversationId,
                            token: settings.conversation.conversationId,
                            domain: `${Emulator.serviceUrl}/v3/directline`,
                            webSocket: false
                        });
                    //    log.debug(`started new conversation`);
                    }
                    this.reuseKey++;
                    this.forceUpdate();
                }
            } catch(e) {
                //log.error(e.message);
            }
            this.setState({
              showUpdateDialog: settings.update.showing,
              updateVersion: settings.update.version