我正在尝试构建一个支持在NodeJS中调用Skype并在Azure上部署的机器人。但是,演示在聊天和呼叫连接器上进行侦听的示例代码似乎假设您在本地运行并使用ngrok来使您的bot可以访问。
例如:
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 chatConnector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var chatBot = new builder.UniversalBot(chatConnector);
server.post('/api/messages', chatConnector.listen());
// Create calling bot
var connector = new calling.CallConnector({
callbackUrl: process.env.CALLBACK_URL,
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
var bot = new calling.UniversalCallBot(connector);
server.post('/api/calls', connector.listen());
有一些适用于Azure的示例,例如:
var connector = useEmulator ? new builder.ChatConnector() : new botbuilder_azure.BotServiceConnector({
appId: process.env['MicrosoftAppId'],
appPassword: process.env['MicrosoftAppPassword'],
stateEndpoint: process.env['BotStateEndpoint'],
openIdMetadata: process.env['BotOpenIdMetadata']
});
if (useEmulator) {
var restify = require('restify');
var server = restify.createServer();
server.listen(3978, function() {
console.log('test bot endpont at http://localhost:3978/api/messages');
});
server.post('/api/messages', connector.listen());
} else {
module.exports = { default: connector.listen() }
console.log("Running in Azure");
}
但是当我需要听两个连接器时,我不清楚它是如何工作的。有可能让这个工作吗?如果是这样,我需要在module.exports中设置什么?