我努力让bot-framework-emulator和Bot Builder for Node.js Builder在Linux下工作。
由于Linux的bot-framework-emulator需要mono,我决定在Docker下使用以下Dockerfile运行它:
FROM mono:latest
EXPOSE 9000
COPY . BotFrameworkEmulator-Console/
CMD [ "mono", "./BotFrameworkEmulator-Console/BFEmulator.exe" ]
我用命令启动它(也暴露端口9000):
docker run -it --rm -p 9000:9000 bfemulator
它开始很好,似乎工作。这是第一个问题。 bot-framework-emulator页面声明:
对于在Mac和Linux上开发的人,我们创建了一个仅使用单声道的控制台版本。
这是否意味着它不包含Web界面作为bot emu的Windows变体?因为 netstat -al 报告比BFEmulator.exe正在侦听端口9000,但是当我访问localhost:9000时无法从docker主机访问。它不能从docker容器内部访问。
第二个问题是我甚至无法使用BFEmulator的控制台模式。在我的主机上,我运行了nodejs docker bot示例,当部署到" Microsoft Bot Framework"时,它工作正常。
以下是示例代码:
var restify = require('restify');
var builder = require('botbuilder');
//=========================================================
// Bot Setup
//=========================================================
// 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 bot
var connector = new builder.ChatConnector({
appId: process.env.npm_package_config_MICROSOFT_APP_ID,
appPassword: process.env.npm_package_config_MICROSOFT_APP_PASSWORD
});
var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());
//=========================================================
// Bots Dialogs
//=========================================================
bot.dialog('/', [
function (session) {
builder.Prompts.text(session, 'Hi! What is your name?');
},
function (session, results) {
session.send('Hello %s!', results.response);
}
]);
但是当使用BFEmulator运行时,上面的bot服务器会报告:
ChatConnector: message received.
Error: Request to 'http://172.17.0.1:3978/v3/botstate/emulator/users/617d3bf8' failed: [404] Not Found
at Request._callback (/home/finch/dev/mapilary/mapilary-bot/node_modules/botbuilder/lib/bots/ChatConnector.js:413:46)
at Request.self.callback (/home/finch/dev/mapilary/mapilary-bot/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/home/finch/dev/mapilary/mapilary-bot/node_modules/request/request.js:1060:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/home/finch/dev/mapilary/mapilary-bot/node_modules/request/request.js:980:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
我理解路径v3/botstate/emulator/users
未在bot示例中声明。所以我的问题是可以在nodejs bot builder中使用模拟器吗?