【问题标题】:Custom Bot for Microsoft Teams getting "BotAuthenticator failed to authenticate incoming request!" errorMicrosoft Teams 的自定义 Bot 收到“BotAuthenticator 无法验证传入请求!”错误
【发布时间】:2017-11-19 10:25:42
【问题描述】:

我正在使用 Bot Framework 为 Microsoft 团队制作自定义机器人。我目前在本地托管机器人并通过 ngrok 进行隧道传输,并且我正在使用 /api/messages URL。我已经在机器人框架中注册了机器人,并将机器人句柄放在 BotId 中,将应用程序 ID 放在 MiscrosoftAppId 中,并将应用程序密码放在我的 Web.config 中的 MicrosoftAppPassword 中。 Teams 频道已启用,并且在 Bot Framework 页面上具有“正在运行”状态。该机器人在模拟器上运行,并在 Bot Framework 页面上的测试连接上运行,但它不在 Microsoft Teams 中运行。

这是发送到我的机器人的内容:

"type": "message",
"id": "1497620296742",
"timestamp": "2017-06-16T13:38:19.303Z",
"localTimestamp": null,
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"channelId": "msteams",
"from": {
    "id": "29:1F9b3IgxC3x5ynp7nVxdSQ0bQ9MNyf7uKDZHrrCfRLyBbjOmdWSY4gyFLuR8cTRFmbXOeDN4f_uI65xSem6M5OA",
    "name": "Ronnei, Evan T"
},
"conversation": {
    "isGroup": true,
    "id": "19:d02a9a4678924803964e6af1d9afc1ab@thread.skype;messageid=1497558943513",
    "name": null
},
"recipient": null,
"textFormat": "plain",
"attachmentLayout": null,
"membersAdded": null,
"membersRemoved": null,
"topicName": null,
"historyDisclosed": null,
"locale": null,
"text": "Test Bot",
"summary": null,
"attachments": [
    {
        "contentType": "text/html",
        "contentUrl": null,
        "content": "<div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">Test Bot</span></div>",
        "name": null,
        "thumbnailUrl": null
    }
],
"entities": [
    {
        "type": "clientInfo",
        "locale": "en-US",
        "country": "US",
        "platform": "Windows"
    }
],
"channelData": {
    "teamsChannelId": "19:d02a9a4678924803964e6af1d9afc1ab@thread.skype",
    "teamsTeamId": "19:e218343840af4d4397faf47bd3f4eada@thread.skype",
    "channel": {
        "id": "19:d02a9a4678924803964e6af1d9afc1ab@thread.skype"
    },
    "team": {
        "id": "19:e218343840af4d4397faf47bd3f4eada@thread.skype"
    },
    "tenant": {
        "id": "a9691d3f-49e3-46a8-8b23-ddad274d0523"
    }
},
"action": null,
"replyToId": null,
"value": null,
"name": null,
"relatesTo": null

它给了我这个 401 Unauthorized 错误:

BotAuthenticator failed to authenticate incoming request!

当涉及到所有这些东西时,我是一个初学者。我遵循了 Bot Framework 文档中的可用教程,但它仍然不适用于 Teams。我有点卡在这一点上。让我知道是否需要提供更多信息。

显然我没有足够的声誉来发布更多代码......所以这是我的 manifest.json:https://pastebin.com/xK7y2VHX

【问题讨论】:

  • 您能否再次检查 AppId 和 AppPassword 值是否正确?
  • 他们是正确的。我什至生成了一个新密码并使用它来确保。

标签: c# botframework microsoft-teams


【解决方案1】:

太好了,你的机器人已经开始工作了。您是否创建了 manifest.json 文件并将其旁加载到 Teams 中?您的清单包含 appID、botID 和有关您的机器人的整体信息。如果没有,这里是packaging instructions。此页面下方有一个页面显示清单架构。如果您已经侧载它并且仍然遇到问题,请再次发布!

【讨论】:

  • 我的机器人不工作。我没有将机器人作为应用程序侧载,尽管我确实尝试过但无济于事。我正在使用自定义机器人功能,因为我没有计划将其作为应用程序发布,因为它纯粹是内部的。
  • 与 Teams 相关的“自定义机器人”被描述为 here,这看起来不像您正在做的事情。当您通过 Bot Framework 注册一个 bot 时,您实际上是在创建一个合适的 bot,因此您需要按照 MSDN 上的说明对其进行打包和旁加载。当您获取通道数据负载时,听起来您已经成功完成了,是吗?
  • 好吧,如果我需要侧载机器人,那么我需要修复我的 manifest.json,因为侧载机器人似乎没有达到实际连接。这是我的 manifest.json。我会用它来编辑我的主要帖子。我不确定我这样做是否正确。我不知道要在“packageName”字段中输入什么,而且有关架构的文档也没有提供超级丰富的信息。
【解决方案2】:

您附加的清单存在一些问题:

  1. bots.botsId 需要成为您的 botframework 机器人的 guid
  2. needsChannelSelectorisNotificationOnly 都应该是布尔值,而不是字符串(例如 "needsChannelSelector": false)

(packageName 不是阻塞元素,但最好是反向域名表示法中的唯一字符串,如果适用的话。)

您还可以与我们的简单机器人程序包here 进行比较,并确保您也查看了packagingsideloading 说明。

【讨论】:

  • 我现在可以通过侧载包成功访问我的机器人了,谢谢。
猜你喜欢
  • 1970-01-01
  • 2021-02-19
  • 2019-10-28
  • 2017-11-05
  • 2020-12-17
  • 2019-09-16
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
相关资源
最近更新 更多