2017-03-21 5 views
0

私はMS Bot Frameworkで単純な天気ボットを作成しようとしていますが、私はPrompts.textがすぐに表示される実際にユーザの入力を待っている過去をスキップします(エミュレータでのテスト)。BotFramework Prompts.text()はすぐに滝の次のステップにスキップします

私は、コードの束が、次はまだreprosをカットしました:場所は、コードの3行目にfindEntity呼び出しによって発見されていない場合には

bot.dialog('checkWeather', [ 
    function (session, args, next) { 
     var location = builder.EntityRecognizer.findEntity(args.intent.entities, "builtin.weather.absolute_location"); 

     if (!location) { 
      session.beginDialog("getLocation"); 
     } else { 
      session.privateConversationData.location = location.entity; 
     } 

     next(); 
    }, 
    function (session, results, next) { 
     var location = session.privateConversationData.location; 

     session.send('Okay! I am going to check the weather in %s!', location); 
    } 
]) 
    .triggerAction({ matches: 'builtin.intent.weather.check_weather' }); 

bot.dialog('getLocation', [ 
    function (session) { 
     builder.Prompts.text(session, 'For which area would you like me to check the weather?'); 
    }, 
    function (session, results) { 
     session.privateConversationData.location = results.response; 
     console.log('Location entered was: %s', results.response); 
     session.endDialog(); 
    } 
]); 

、されて、何が起こりますかgetLocationダイアログに移動し、ユーザーが応答で何かを入力するのを待たずに直ちにそれを通過します。

ChatConnector: message received. 
session.beginDialog(*:checkWeather) 
checkWeather - waterfall() step 1 of 2 
checkWeather - session.beginDialog(getLocation) 
.getLocation - waterfall() step 1 of 2 
.getLocation - session.beginDialog(BotBuilder:Prompts) 
..Prompts.text - session.send() 
..Prompts.text - session.sendBatch() sending 1 messages 
..Prompts.text - session.endDialogWithResult() 
.getLocation - waterfall() step 2 of 2 
Location entered was: undefined 
.getLocation - session.endDialog() 
checkWeather - waterfall() step 2 of 2 
checkWeather - session.send() 
checkWeather - session.sendBatch() sending 1 messages 

とボットフレームワークエミュレータ自体にメッセージがボットにクライアントから送信されていなかったことがわかります:私は、表示されるコンソール出力から

[21:32:14] -> POST 202 [message] Hows the Weather 
[21:02:14] <- GET 200 getUserData 
[21:02:14] <- GET 200 getPrivateConversationData 
[21:02:15] <- POST 200 setPrivateConversationData 
[21:02:15] <- POST 200 Reply[message] For which area would you like me to check the weat... 
[21:02:15] <- POST 200 setPrivateConversationData 
[21:02:15] <- POST 200 Reply[message] Okay! I am going to check the weather in undefined... 

私は」確信していますここでは単純なものがありませんが、私はそれを見つけることができません。誰かが何かアイデアを持っているなら、私はそれらを聞いてみたい!

答えて

2

checkWeatherの滝の最初のステップでnext()コールをelseブロックに移動します。プロンプトの後のコードはまだ実行されているので、新しいダイアログを入力してすべてを混乱させた後、次のコードを呼び出していました。

だからあなたの最初の関数は

function (session, args, next) { 
    var location = builder.EntityRecognizer.findEntity(args.intent.entities, "builtin.weather.absolute_location"); 

    if (!location) { 
     session.beginDialog("getLocation"); 
    } else { 
     session.privateConversationData.location = location.entity; 
     next(); 
    } 
} 
のようになります。
関連する問題