简体   繁体   English

bot框架和Microsoft团队-如何获得与团队相关的所有渠道?

[英]bot framework and Microsoft teams - how to get all channels associated to a team?

I am trying to get all channels associated with a specific team so that my bot can send proactive messages. 我试图获取与特定团队相关的所有渠道,以便我的机器人可以发送主动消息。 Based on the reading I've done, I need to use the FetchChannelList method in the Microsoft.Bot.Connector.Teams namespace, in the TeamsOperationsExtensions class. 基于我已完成的阅读,我需要在TeamsOperationsExtensions类的Microsoft.Bot.Connector.Teams命名空间中使用FetchChannelList方法。

If I do this: 如果我这样做:

var connector = new ConnectorClient(new Uri(activity.ServiceUrl)); ConversationList channels = connector.GetTeamsConnectorClient().Teams.FetchChannelList(activity.GetChannelData<TeamsChannelData>().Team.Id);

channels is null. channel为空。 If I break it down to only connector.GetTeamsConnectorClient(), that is not null, but connector.GetTeamsConnectorClient().Teams.FetchChannelList(activity.GetChannelData().Team.Id) is. 如果我将其细分为仅connector.GetTeamsConnectorClient(),则不为空,但connector.GetTeamsConnectorClient()。Teams.FetchChannelList(activity.GetChannelData()。Team.Id)则为null。

To break it down further, I tried to get activity.GetChannelData(). 为了进一步分解,我尝试获取activity.GetChannelData()。 Only the Tenant property is not null. 只有“租户”属性不为空。 All the others (Channel, Team, EventType and Notification) are null. 所有其他(渠道,团队,事件类型和通知)均为空。

I am using tunnelrelay, which forwards messages sent to the bot's public endpoint to a private endpoint, and am using tenant filter authentication in the messages controller. 我正在使用tunnelrelay,它将发送到bot的公共终结点的消息转发到私有终结点,并在消息控制器中使用租户筛选器身份验证。 Not sure if that would cause any problems? 不确定是否会引起任何问题? (When I watch messages coming in through tunnel relay, I see there too that only Tenant is the only channeldata property which is not null. Here's what I see in tunnelrelay: "entities":[{"locale":"en- US","country":"US","platform":"Windows","type":"clientInfo"}],"channelData":{"tenant":{"id":"our_tenant_id"}}} (当我看到通过隧道中继传入的消息时,我也看到只有Tenant是唯一不为null的channeldata属性。这是我在tunnelrelay中看到的内容: "entities":[{"locale":"en- US","country":"US","platform":"Windows","type":"clientInfo"}],"channelData":{"tenant":{"id":"our_tenant_id"}}}

Also, regarding the teamID expected as a parameter to the FetchChannelList method, how do I find out what that is for a given team other than the GetChannelData() method? 另外,关于期望作为FetchChannelList方法参数的teamID,我如何找出除GetChannelData()方法之外的给定团队的含义? I tried the powershell cmdlet Get-Team (for example: Get-Team -User me@abc.com). 我尝试了Powershell cmdlet Get-Team(例如:Get-Team -User me@abc.com)。 It returns a distinct groupId for each team I am a part of, but I'm assuming groupId != TeamId. 它会为我所属的每个团队返回一个不同的groupId,但我假设groupId!= TeamId。 Is that correct? 那是对的吗? And, where can I find the teamId that the FetchChannelList is expecting other than the GetChannelData method? 而且,除了GetChannelData方法之外,在哪里可以找到FetchChannelList期望的teamId?

Thanks in advance for any help! 在此先感谢您的帮助!

The problem here was that the message to the bot (the activity) was a direct message, not a part of a channel conversation. 这里的问题是发给机器人的消息(活动)是直接消息,而不是频道对话的一部分。 Apparently, the Channel and Team properties are only available in a channel conversation. 显然,“频道”和“团队”属性仅在频道对话中可用。

Also, regarding the team ID, one way to get it outside of code is to click the "..." next to the team and click "get link to team". 另外,关于团队ID,将其获取到代码之外的一种方法是单击团队旁边的“ ...”,然后单击“获取团队链接”。 You will see something like: https://teams.microsoft.com/l/team/19%3a813345c7fafe437e8737057505224dc3%40thread.skype/conversations?groupId=Some_GUID&tenantId=Some_GUID 您将看到类似以下内容的东西: https : //teams.microsoft.com/l/team/19%3a813345c7fafe437e8737057505224dc3%40thread.skype/conversations?groupId=Some_GUID&tenantId=Some_GUID

The line after team/ (19%3a813345c7fafe437e871111115934th3%40thread.skype) contains the teamId, but not exactly. team /(19%3a813345c7fafe437e871111115934th3%40thread.skype)之后的行包含teamId,但不完全相同。 If you replace the first % and the two characters immediately following it with : and the second % and the two characters immediately following it with @, that is your teamid. 如果将第一个%和紧随其后的两个字符替换为:,将第二个%和紧随其后的两个字符替换为@,这就是您的团队ID。 So, from: 因此,来自:

19%3a813345c7fafe437e871111115934th3%40thread.skype 19%3a813345c7fafe437e871111115934th3%40thread.skype

the team ID is: 团队ID为:

19:813345c7fafe437e871111115934th3@thread.skype 19:813345c7fafe437e871111115934th3@thread.skype

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Microsoft Teams 上的 Microsoft Bot Framework 中在应用安装时从团队中提取用户 - How do i pull users from a team in Microsoft Bot Framework on Microsoft Teams on app install 从Microsoft Teams的Bot Framework获取GroupsId - Get GroupsId from Bot Framework in Microsoft Teams Microsoft Bot Framework-如何从团队渠道获取用户数据 - Microsoft Bot Framework - How to get user data from team channel 将 MS Bot Framework Chatbot 添加到所有 MS Teams 频道 - Add MS Bot Framework Chatbot to all MS Teams Channels Microsoft Bot Framework 和 Microsoft Teams - Microsoft Bot Framework and Microsoft Teams 如何调试在 Microsoft Teams 上运行的 Bot Framework BOT - How to debug a Bot Framework BOT running on Microsoft Teams Microsoft Bot Framework 团队身份验证 - Microsoft Bot Framework Teams Authentication 如何在 Microsoft Teams for Microsoft Bot Framework 中检测用户的语言? - How to detect user's language in Microsoft Teams for Microsoft Bot Framework? 如何在 Microsoft Teams for Microsoft Bot Framework 中检测键盘语言? - How to detect keyboard language in Microsoft Teams for Microsoft Bot Framework? 使用Microsoft Bot Framework V4主动向Microsoft Teams中的团队聊天发送消息 - Proactively send message to a Team chat in Microsoft Teams using Microsoft Bot Framework V4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM