【发布时间】:2018-08-27 22:06:49
【问题描述】:
使用 Microsoft Bot Framework,我创建了一个聊天机器人,并且我能够使用本地模拟器测试该机器人。 Bot 服务还处理 LUIS,一切正常。我的机器人服务在web.config 中有MicrosoftAppId 和MicrosoftAppPassword。
我将服务部署到 Azure。然后在浏览器中嵌入了一个网络聊天(Github),但它不起作用。错误说
Buffer="{
"message": "An error has occurred.",
"exceptionMessage": "Unauthorized",
"exceptionType": "Microsoft.Bot.Connector.MicrosoftAppCredentials+OAuthException",
"stackTrace": " at Microsoft.Bot.Sample.LuisBot.MessagesController.<Post>d__0.MoveNext()
......
"innerException": {
"message": "An error has occurred.",
"exceptionMessage": "Response status code does not indicate success: 401 (Unauthorized).",
"exceptionType": "System.Net.Http.HttpRequestException",
"stackTrace": " at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\r\n at Microsoft.Bot.Connector.MicrosoftAppCredentials.<RefreshTokenAsync>d__26.MoveNext()"
我相信当我传递我的网络聊天密钥时(我也尝试传递生成的令牌但没有运气),那么它应该被自动授权(传递 App Id 和 Password)。不是吗?
- 浏览器嵌入式网络聊天出现未经授权的错误。
- 在网络聊天窗口中测试会出现同样的错误。
我还尝试通过删除 MicrosoftAppId 和 MicrosoftAppPassword 来部署 Bot 服务,但没有任何变化。
这对我来说都是全新的。有人可以帮我弄清楚这个问题吗?也可以公开提供我的 Microsoft App Id 吗?
编辑 1
在浏览器中实现网络聊天控件。
- 创建了 ASP.Net 空网站并有一个 HTML 页面 (index.html)。
- 以下代码写在 index.html 页面中。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="bot" />
<hr />
<iframe width="400" height="300" src='https://webchat.botframework.com/embed/#Web_App_Bot_Name#?s=Web_Chat_Secret_Key'></iframe>
</body>
</html>
【问题讨论】:
-
也是一个旁注。在我的办公室笔记本电脑中,由于安全问题,IT 团队不允许我安装 ngrok。因此我无法在本地调试我的服务。
-
是的,您可以毫无顾虑地公开分享您的 Microsoft 应用 ID(只是不要分享任何机密或 Microsoft 应用密码)。请提供您用于嵌入网络聊天控件的代码(不含密码)。另外,请提供您的 Microsoft 应用 ID。
标签: botframework bots azure-bot-service web-chat