Ms Teams HelloWorld 示例:模拟器不工作:401 未经授权

Ms Teams HelloWorld Sample: Emulator not working: 401 Unauthorized

我有 HelloWorld 应用示例 运行(浏览器启动:http://localhost:3333/

在 Bot Framework Emulator 中,我打开一个 Bot (http://localhost:3333/api/messages) 并连接。

我写了一条消息,我看到了:

Cannot post activity. Unauthorized.
POST 401 directline.postActivity

我试过使用和不使用 ngrok,但我想这不是问题所在。

有什么问题吗?

谢谢,

迭戈

我明白了。一旦我看到 Emulator 需要空 'Appid' 和 'PasswordId' 值 (appsettings.json),我就尝试在 Teams 客户端中获取我的 BOT 运行。

现在我在本地有我的应用程序 运行,并且在 Teams 客户端中创建了一个 Bot,它可以使用 ngrok 重定向与其交互

关键是从使用与 Azure 门户中相同的用户登录的团队客户端(不在 dev.botframework.com/bots 中)创建机器人,并使用 App Studio。 然后在 Azure 门户 (NewApp) 中自动创建一个应用程序。

重要:

  • appsettings.json 中的 App Id 是从 App Studio Bots 选项创建的。它也在 Azure 门户中:App registrations-NewApp-'Application (client) ID'。在 botframework 中也有两次(NewBot 设置:'Bot handle' 和 'Configuration'-'Paste your appId below...')

  • 在 App Studio 'app creation' 中还有另一个 'App ID' 在应用程序详细信息中。不需要相同。

  • appsettings.json中的应用程序密码是在 App Studio 中创建的(应用程序密码 -> 生成)。它也在 Azure 门户中:App registrations-NewApp-Certificates&secrets/Client secrets
  • ngrok url 必须添加到 App Studio 机器人中(消息端点:“https://xxxxxx.ngrok.io”)。它也在 botframework 中(NewBot 设置-消息端点)