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

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-WebChat / src / Chat.tsx View on Github external
componentDidMount() {
        // Now that we're mounted, we know our dimensions. Put them in the store (this will force a re-render)
        this.setSize();

        const botConnection = this.props.directLine
            ? (this.botConnection = new DirectLine(this.props.directLine))
            : this.props.botConnection
            ;

        if (this.props.resize === 'window') {
            window.addEventListener('resize', this.resizeListener);
        }

        this.store.dispatch({ type: 'Start_Connection', user: this.props.user, bot: this.props.bot, botConnection, selectedActivity: this.props.selectedActivity });

        this.connectionStatusSubscription = botConnection.connectionStatus$.subscribe(connectionStatus => {
                if (this.props.speechOptions && this.props.speechOptions.speechRecognizer) {
                    const refGrammarId = botConnection.referenceGrammarId;
                    if (refGrammarId) {
                        this.props.speechOptions.speechRecognizer.referenceGrammarId = refGrammarId;
                    }
                }
github UdacityMobileWebScholarship / udabot / Frontend / BotFramework-WebChat / src / Chat.tsx View on Github external
componentDidMount() {
        // Now that we're mounted, we know our dimensions. Put them in the store (this will force a re-render)
        this.setSize();

        const botConnection = this.props.directLine
            ? (this.botConnection = new DirectLine(this.props.directLine))
            : this.props.botConnection
            ;

        if (this.props.resize === 'window')
            window.addEventListener('resize', this.resizeListener);

        this.store.dispatch({ type: 'Start_Connection', user: this.props.user, bot: this.props.bot, botConnection, selectedActivity: this.props.selectedActivity });

        this.connectionStatusSubscription = botConnection.connectionStatus$.subscribe(connectionStatus =>{
                if(this.props.speechOptions && this.props.speechOptions.speechRecognizer){
                    let refGrammarId = botConnection.referenceGrammarId;
                    if(refGrammarId)
                        this.props.speechOptions.speechRecognizer.referenceGrammarId = refGrammarId;
                }
                this.store.dispatch({ type: 'Connection_Change', connectionStatus })
            }
github Capgemini-AIE / bot-framework-actions-on-google / lib / directline / DirectLineManager.js View on Github external
createConversation() {
    console.log(this._token);
    return new DirectLineWrapper(new DirectLine({
      token: this._token,
      webSocket: true
    }));
  }
  getToken(directlineSecret) {
github aiden / autobot / src / clients / botframework_client.ts View on Github external
constructor(directLineSecret: string, domain?: string) {
    super();
    this.directLine = new DirectLine({ domain, secret: directLineSecret, webSocket: !domain });
    this.subscribeToConnectionStatus();
  }
github SharePoint / sp-dev-fx-extensions / samples / react-application-botframework-chat / src / extensions / botFrameworkChatPopup / components / BotFrameworkChatPopupApplicationChat.tsx View on Github external
constructor(props) {
    super(props);
    const styleOptions = {
      hideScrollToEndButton: false,
      rootHeight: '50%',
      rootWidth: '50%'
    };
    this.state = {
      directLine: new DirectLine({
        secret: this.props.directLineSecret
      }),
      styleSetOptions: styleOptions,
      isOpen: false
    };
  }
github SharePoint / sp-dev-fx-webparts / samples / react-bot-framework / src / webparts / botFrameworkChatv4 / components / BotFrameworkChatv4.tsx View on Github external
const styleOptions = {
      backgroundColor: this.props.backgroundColor,
      botAvatarImage: this.props.botAvatarImage,
      userAvatarImage: this.props.userAvatarImage,
      hideUploadButton: this.props.hideUploadButton,
      sendBoxBackground: this.props.sendBoxBackground,
      sendBoxTextColor: this.props.sendBoxTextColor,
      bubbleBackground: this.props.bubbleBackground,
      bubbleTextColor: this.props.bubbleTextColor,
      bubbleFromUserTextColor: this.props.bubbleFromUserTextColor,
      bubbleFromUserBackground: this.props.bubbleFromUserBackground,
      userAvatarInitials: this.props.userAvatarInitials,
      botAvatarInitials: this.props.botAvatarInitials
      };
    this.state = {
      directLine: new DirectLine({
        secret: this.props.directLineSecret
      }),
      styleSetOptions: styleOptions
    };

    
  }
  public render(): React.ReactElement {
github Capgemini-AIE / bot-framework-actions-on-google / lib / directline / DirectLineManager.js View on Github external
resumeConversation(conversationId) {
    return new DirectLineWrapper(new DirectLine({
      token: this._token,
      webSocket: true,
      conversationId
    }));
  }
}
github microsoft / BotFramework-WebChat / packages / bundle / src / createDirectLine.js View on Github external
export default function createDirectLine({
  botAgent,
  conversationId,
  domain,
  fetch,
  pollingInterval,
  secret,
  streamUrl,
  token,
  watermark,
  webSocket
}) {
  return new DirectLine({
    botAgent,
    conversationId,
    domain,
    fetch,
    pollingInterval,
    secret,
    streamUrl,
    token,
    watermark,
    webSocket,
    createFormData: attachments => {
      const formData = new FormData();

      attachments.forEach(({ contentType, data, filename, name }) => {
        formData.append(name, new Blob(data, { contentType }), filename);
      });