2017-11-28 5 views
0

私はMicrosoft Bot Frameworkのボットを作成しました。私はLUIS言語モデルを使用しました。以下 は、コードの私の作品である:ここではMicrosoft Bot Framework(Node.js)のダイアログを切り替える

bot.use(builder.Middleware.dialogVersion({ version: 1.0, resetCommand: /^reset/i })); 
bot.dialog('/', intents); 

intents.matches('GoogleHome', [ 

    function (session, args) { 
    if(builder.EntityRecognizer.findEntity(args.entities, 'cookingtips')) 
    { 
      quickReply(session, args) 
    } 
    if(builder.EntityRecognizer.findEntity(args.entities, 'wakingtips')) 
    { 
      //My rest of the code 
    } 

}]) 

は、私は何も起こりません迅速な回答とクリックの上を取得することができる午前私のquickReply

function quickreply(session, args){ 

    var msg = new builder.Message(session) 
       .text("Let me know the date and time you are comfortable with..") 
       .suggestedActions(
        builder.SuggestedActions.create(
         session,[ 
          builder.CardAction.imBack(session, "CookingTips", "CookingTips"), 
          builder.CardAction.imBack(session, "WalkingTips", "WalkingTips") 

         ] 
        ) 
       ); 
      builder.Prompts.choice(session, msg, ["CookingTips", "WalkingTips"]), function(session,results) { 
      console.log(results); 
      session.send('So I understand you want a cooking tip ' + results + ' right now'); 
      session.endDialog(); 
     }} 

ためのコードです。私は私のコンソールで以下を参照してください。

.BotBuilder:prompt-choice - Prompt.returning([object Object]) 
.BotBuilder:prompt-choice - Session.endDialogWithResult() 
/- Session.endDialogWithResult() 

代わりに、私はメッセージが私のLUISに送られたか、少なくともコールバック関数で記述されたよう確認メッセージを表示するために、これをしたいです。どうしたらいいですか?

答えて

0

quickReply()関数は新しいダイアログを作成しないため、endDialog()は現在のダイアログを終了し、親ダイアログを持たないため再開できません。

intents.matches('GoogleHome', [ 

    function (session, args, next) { 
    if(builder.EntityRecognizer.findEntity(args.entities, 'cookingtips')) 
    { 
      quickReply(session, args, next) 
    } 
    if(builder.EntityRecognizer.findEntity(args.entities, 'wakingtips')) 
    { 
      //My rest of the code 
    } 

},(session,result)=>{ 
//get the user choice here 
    console.log(result); 
    session.send(JSON.stringify(result)); 
}]) 

quickReply

function quickRelpy(session, args, next) { 
    var msg = new builder.Message(session) 
     .text("Let me know the date and time you are comfortable with..") 
     .suggestedActions(
      builder.SuggestedActions.create(
       session, [ 
        builder.CardAction.imBack(session, "CookingTips", "CookingTips"), 
        builder.CardAction.imBack(session, "WalkingTips", "WalkingTips") 

       ] 
      ) 
     ); 
    builder.Prompts.choice(session, msg, ["CookingTips", "WalkingTips"]); 
} 
+0

こんにちはゲイリー:

あなたは、値を渡すようにコードを修正するnext中央をleverateすることができます。私は試しましたが、正しく動作しませんでした。ユーザーの選択肢を得るためのコードを記入できますか?私はそれを正しくやっていると感じています。 – CTD

+0

いくつかのコードスニペットを追加すると、より明確になります。基本的には、あなたのボットは、次の滝でユーザーのメッセージを受信します。 –

関連する問題