2017-12-22 10 views

답변

2

당신은이에 대한 웹 채팅 컨트롤의 백 채널을 사용할 수

 const user = { 
     id: 'userid', 
     name: 'username' 
     }; 
     const bot = { 
     id: 'botid', 
     name: 'botname' 
     }; 

    const botConnection = new BotChat.DirectLine({ 
     secret: 'SECRET' 
     }); 

     BotChat.App({ 
     bot: bot, 
     botConnection: botConnection, 
     user: user 
     }, document.getElementById('BotChatGoesHere')); 

     botConnection.activity$ 
     .filter(function (activity) { 
      return activity.type === 'event' && activity.name === 'changeBackground'; 
     }) 
     .subscribe(function (activity) { 
      console.log('"changeBackground" received with value: ' + activity.value); 
      changeBackgroundColor(activity.value); 
     }); 

     function changeBackgroundColor(newColor) { 
     document.body.style.backgroundColor = newColor; 
     } 

이 예는 로봇이 웹 채팅 및 변경 페이지의 backgroundColor를하는 changeBackground 이벤트를 보낼 수있는 방법을 보여줍니다.

은에서 : 대신 changeBackground 이벤트의 https://github.com/Microsoft/BotFramework-WebChat/blob/master/samples/backchannel/index.html

, 당신은 자바 스크립트 location.reload을()는 reloadPage 이벤트를 전송하고 호출 할 수 있습니다.