Microsoft Bot Frameworkを試しています。私の実験では、 "Hello World"を既存のWebアプリケーションに統合しようとしています。私のWebアプリケーションは、高速のNode.jsアプリケーションです。Microsoft BotフレームワークとNode Express Webサイトの統合
私のNode.jsアプリケーションでは、ボットにメッセージを送信できるテキストボックスを持つWebページが必要です。基本的には、Webページにフレームワークチャネルエミュレータを模倣しようとしています。これを実行しようとする試みで、私は次のようでWebページを持っている。そして、
<form>
<div class="input-group">
<input id="message" type="text" class="form-control" placeholder="">
<span class="input-group-btn">
<button id="sendButton" class="btn btn-secondary" type="button">send</button>
</span>
</div>
</form>
...
$('#sendButton').click(onSendButtonClick);
function onSendButtonClick() {
var message = $('#message').val();
if (message) {
$.post('/my-bot', function(data, status) {
console.log(data);
console.log(status);
});
}
return false;
}
bot.html
、サーバ側で、私の中にExpressを使用しているNode.jsアプリには次のものがあります:
// This route is intended to listen for messages POSTed from the text box on my web site.
app.post('/my-bot', function(req, res) {
try {
// Not sure about this...
let connector = new BotBuilder.ConsoleConnector().listen();
let bot = new BotBuilder.UniversalBot(connector);
bot.dialog('/', function (session) {
session.send('Hello World');
});
} catch (ex) {
res.status(500);
res.end();
}
});
// The following serves up my web page
app.use('/my-bot', function(req, res) {
let view = './bot.html';
res.render(view, {});
});
私はいません「Hello World」を私のWebページに戻す方法を教えてください。 session.send
への呼び出しが表示されますが、session
とres
オブジェクトを接続する方法はありません。あるいは私は建築全体を誤解していますか?