在 Messaging Extension (Microsoft Teams) 上获取用户信息
Fetching user information on Messaging Extension (Microsoft Teams)
我有一个将与我们的 VoIP 系统一起使用的消息扩展。
假设我与另一位用户进行了 1:1 对话。我希望我的消息扩展能够获取其他用户的信息(姓名、电子邮件、AadObjectId 等)。我得到的最接近的信息是 1:1 与该用户聊天的对话 ID。然后我尝试了以下两种方法:
SDK:
List<ChannelAccount> teamMembers = (await turnContext.TurnState.Get<IConnectorClient>().Conversations.GetConversationMembersAsync(turnContext.Activity.Conversation.Id).ConfigureAwait(false)).ToList();
以及具有对话 ID 的直接端点:
https://smba.trafficmanager.net/amer/v3/conversations/{REDACTEDCONVERSATIONID}/members
两者都给我错误 403(禁止)消息:
"error": {
"code": "BotNotInConversationRoster",
"message": "The bot is not part of the conversation roster."
}
我们真的需要消息传递扩展来提取这些信息,有什么办法可以做到吗?
我正在使用 BotFramework SDK,最新版本
因此,正如您所发现的那样,如果实际上并未安装机器人,则无法直接通过机器人(即通过 'conversations' 端点)按照您尝试的方式执行此操作特定位置(1-1 聊天、频道等)。然而,这绝对 - 是 - 可能的,只是通过另一条路线。您需要做的是使用 Microsoft Graph,特别是从本月开始获取 conversation members. However, in order to do this, you'll need to implement sign in in your Message Extension. Fortunately, there was a discussion on this exact topic in the latest Teams community call 的操作。该示例在节点中,但同样适用于 C#(我看到你正在使用的)。
我有一个将与我们的 VoIP 系统一起使用的消息扩展。
假设我与另一位用户进行了 1:1 对话。我希望我的消息扩展能够获取其他用户的信息(姓名、电子邮件、AadObjectId 等)。我得到的最接近的信息是 1:1 与该用户聊天的对话 ID。然后我尝试了以下两种方法:
SDK:
List<ChannelAccount> teamMembers = (await turnContext.TurnState.Get<IConnectorClient>().Conversations.GetConversationMembersAsync(turnContext.Activity.Conversation.Id).ConfigureAwait(false)).ToList();
以及具有对话 ID 的直接端点:
https://smba.trafficmanager.net/amer/v3/conversations/{REDACTEDCONVERSATIONID}/members
两者都给我错误 403(禁止)消息:
"error": {
"code": "BotNotInConversationRoster",
"message": "The bot is not part of the conversation roster."
}
我们真的需要消息传递扩展来提取这些信息,有什么办法可以做到吗?
我正在使用 BotFramework SDK,最新版本
因此,正如您所发现的那样,如果实际上并未安装机器人,则无法直接通过机器人(即通过 'conversations' 端点)按照您尝试的方式执行此操作特定位置(1-1 聊天、频道等)。然而,这绝对 - 是 - 可能的,只是通过另一条路线。您需要做的是使用 Microsoft Graph,特别是从本月开始获取 conversation members. However, in order to do this, you'll need to implement sign in in your Message Extension. Fortunately, there was a discussion on this exact topic in the latest Teams community call 的操作。该示例在节点中,但同样适用于 C#(我看到你正在使用的)。