我已经使用Microsoft botframework和nodejs构建了一个机器人。现在,我想将其部署到本地计算机上,然后再托管它并获取https url。我知道它应该在IIS上运行,但我不知道从哪里开始。谁能帮助我将其部署到本地计算机上以及如何托管它?
答案 0 :(得分:1)
您需要执行以下操作
安装Restify
npm install --save restify
设置您的应用程序以使用Restify,这是示例代码:
var restify = require('restify');
var builder = require('botbuilder');
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
// Receive messages from the user and respond by echoing each message back (prefixed with 'You said:')
var bot = new builder.UniversalBot(connector, function (session) {
session.send("You said: %s", session.message.text);
});
使用
运行您的机器人node app.js
下载一个打开的BotFramework Emulator并将其设置为指向托管您的机器人的uri,即: http://localhost:3980/api/messages