You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Teams Toolkit HelloWorld聊天机器人消息发送失败求助

Teams Toolkit Command Bot调试发送消息报错:用户ID无效(errorCode 201)

问题概述

通过VSCode Teams Toolkit创建默认Command Bot项目,完成365商业租户的所有前置配置后启动调试:

  • 所有前置检查通过,成功将本地调试机器人添加到Teams网页版
  • 发送任意消息或调用自带helloWorld命令时,触发“Failed to send message”错误
  • 网络请求返回errorCode 201、errorSubCode 1,提示“One or more of the user ids provided are not valid”
  • ngrok反向代理通信正常,未修改任何项目代码

请求负载示例:

{
  "members": [
    {
      "id": "8:orgid:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "role": "Admin"
    },
    {
      "id": "28:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "role": "Admin"
    }
  ],
  "properties": {
    "threadType": "chat",
    "chatFilesIndexId": "2",
    "uniquerosterthread": "true",
    "fixedRoster": "true"
  }
}

响应内容示例:

{
  "errorCode": 201,
  "message": "One or more of the user ids provided are not valid.",
  "standardizedError": {
    "errorCode": 201,
    "errorSubCode": 1,
    "errorDescription": "One or more of the user ids provided are not valid."
  }
}

解决步骤

  1. 验证租户ID与用户ID一致性
    检查请求中8:orgid:后的租户ID是否与你当前365商业租户的ID完全匹配。可在Azure AD租户属性中查看官方租户ID,对比请求中的对应字段,排除ID输入或缓存错误。

  2. 重新生成应用注册与机器人配置

    • 在VSCode的Teams Toolkit面板中,删除当前调试环境的Teams应用
    • 执行“Provision”命令,让Toolkit重新创建应用注册和机器人相关配置
    • 删除项目根目录下的.fx缓存文件夹,重新启动调试
  3. 确认机器人权限与管理员同意

    • 登录Azure门户,找到机器人对应的应用注册
    • 检查“API权限”中是否包含Microsoft Graph的Chat.ReadWrite、ChannelMessage.Send等必要权限
    • 确保所有已添加的权限完成管理员同意(作为租户管理员可直接操作)
  4. 切换Teams客户端测试
    改用Teams桌面客户端添加调试机器人,避免网页版缓存的旧用户ID数据干扰,添加后再次发送消息验证。

  5. 指定ngrok区域匹配租户位置
    若ngrok默认区域与租户所在区域不匹配,可能导致ID解析异常。启动ngrok时指定对应区域,例如:

    ngrok http --region=eu 3978
    

    (根据租户实际区域调整,如us、ap等)

内容的提问来源于stack exchange,提问作者knakada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 16:40:26