2017-11-09 3 views
1

NodeJS를 사용하여 봇을 새로 고침하거나 초기화 할 때마다 환영 메시지를 표시하는 봇을 만듭니다 (참고 : 처음에는 아무것도 입력하지 않았습니다).Azure 봇 프레임 워크 : 환영 메시지 표시

나는 다음 코드를 사용하고

var bot = new builder.UniversalBot(connector, [ 
    function (session) { 
     builder.Prompts.text(session, 'Hi! What is your name?'); 
    } 
]); 

그러나 이것은 당신이 conversationUpdate을 사용할 필요가 같은

enter image description here

답변

0

이 보이는 뭔가를 입력 할 때 그것은 단지 나에게 메시지를 제공 나에게 도움이되지 않습니다 콜백. skype example

bot.on('conversationUpdate', function(message) { 
    // Send a hello message when bot is added 
    if (message.membersAdded) { 
     message.membersAdded.forEach(function(identity) { 
      if (identity.id === message.address.bot.id) { 
       var reply = new builder.Message().address(message.address).text("Hi! What is your name?"); 
       bot.send(reply); 
      } 
     }); 
    } 
}); 
에서 파생 된 다음 스 니펫을 시도해보세요.