我正在尝试使用新的Microsoft Bot框架和Node.JS创建一个bot。Microsoft Bot Framework的verifyBotFramework()总是返回Forbidden
问题是,即使我认为我给verifyBotFramework()方法正确的AppId和应用程序的秘密,我总是被禁止。
机器人在模拟器中工作得很好,但是当我试图通过电报达到它时,它说“禁止”。
此外,我不能使用“测试连接到你的机器人”,因为它甚至不会返回错误消息。
这里去我的代码:
var restify = require('restify');
var builder = require('botbuilder');
var server = restify.createServer();
//Criando bot e adicionando diálogos
var bot = new builder.BotConnectorBot();
bot.add('/', new builder.CommandDialog()
.matches('^set name', builder.DialogAction.beginDialog('/profile'))
.matches('^quit', builder.DialogAction.endDialog())
.onDefault(function(session) {
if (!session.userData.name) {
session.beginDialog('/profile');
} else {
session.send('Hello, %s!', session.userData.name);
}
})
);
bot.add('/profile', [
function(session) {
if (session.userData.name) {
builder.Prompts.text(session, 'What would you like me to call you instead?');
} else {
builder.Prompts.text(session, 'Hey there =). What\'s your name?');
}
},
function(session, results) {
session.userData.name = results.response;
session.endDialog();
}
]);
//Configurando Restify
server.use(bot.verifyBotFramework({ appId: 'myappid', appSecret: 'myappsecret' }));
server.post('/v1/messages', bot.listen());
server.listen(process.env.port || 3978, function() {
console.log('%s listening to %s', server.name, server.url);
});
不,我没有使用 “myappsecret” 和 “myappid”,我刚刚更换他们在这里。 PS:我正在使用由框架控制面板生成的应用程序密钥。我尝试了主要和次要应用程序的秘密。
使用Let's Encrypt证书和Key设置HTTPS解决了问题。 –
请注意,自Bot Framework SDK版本3+以后,您不再需要调用'verifyBotFramework'。 –