Microsoft Bot Framework 验证 Bot Framework() 总是返回 Forbidden

Microsoft Bot Framework's verifyBotFramework() always returning Forbidden

我正在尝试使用新的 Microsoft Bot Framework 和 Node.JS 创建一个机器人。

问题是,即使我为 verifyBotFramework() 方法提供了正确的 AppId 和 App Secret,我仍然被禁止。

该机器人在模拟器中运行良好,但当我尝试通过 Telegram 访问它时,它显示 "Forbidden"。

此外,我无法使用 "Test connection to your bot",因为它甚至 return 都没有错误消息。

这是我的代码:

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: 我用的是框架控制面板生成的App Secret。我尝试了主要和次要的应用程序秘密。

确保您使用的是 HTTPS。如果您使用的是 HTTP,则需要禁用基本身份验证,因为 BotFramework 不会明文发送您的 appSecret。