我使用 microsoft botframework 和 nodejs 构建了一个机器人。现在,我想将其部署到本地计算机,然后托管它并获取 https url。我知道它应该在 IIS 上运行,但我不知道首先从哪里开始。谁能帮助我将其部署到本地计算机上以及如何托管它?
这是一个很好的起点! https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-quickstart?view=azure-bot-service-3.0
您需要执行以下操作
-
安装 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 模拟器并将其设置为指向托管您的机器人的 uri,即:http://localhost:3980/api/messages http://localhost:3980/api/messages
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)