[英]Get all team members when bot is installed in MS Teams
I'm trying to implement Proactive Messaging with a MS Teams bot.我正在尝试使用 MS Teams 机器人实施主动消息传递。 According to the docs i have to get a conversationReference
before sending any message to the user so I implemented the onMembersAdded
event listener as follows:根据文档,我必须在向用户发送任何消息之前获得conversationReference
,因此我实现了onMembersAdded
事件监听器,如下所示:
class TeamsBot extends TeamsActivityHandler {
constructor() {
super();
this.onConversationUpdate(async (context, next) => {
this.addConversationReference(context);
});
this.onMembersAdded(async (context, next) => {
const membersAdded = context.activity.membersAdded;
for (let cnt = 0; cnt < membersAdded.length; cnt++) {
if (membersAdded[cnt].id !== context.activity.recipient.id) {
this.addConversationReference(context);
}
}
await next();
});
}
The problem is that I get notified only of the user that is installing the app even tough my Team (and channel) has plenty of members:问题是我只收到安装应用程序的用户的通知,即使我的团队(和频道)有很多成员:
How do I get conversation references for every team member once the bot is installed?安装机器人后,如何获取每个团队成员的对话参考?
It's important to note the difference between the users in a Team and the conversation reference between a user and a bot.请务必注意团队中用户之间的区别以及用户与机器人之间的对话引用。 What the docs are -trying- to say is this:文档 - 试图 - 说的是:
The docs, imo, don't really explain that well - they assume that by enumerating the list of users you'll be getting -actual- conversation references straight away, and/or that you might be able to initiate the conversation using the bot framework itself.文档,imo,并没有真正解释得那么好 - 他们假设通过枚举用户列表你会立即获得 - 实际 - 对话参考,和/或你可能能够使用机器人发起对话框架本身。
To start conversation in channel - I think you are looking for something like this - see 3 point MessageAllMembers .要在频道中开始对话- 我想你正在寻找这样的东西 - 请参阅 3 点MessageAllMembers 。 Try the sample available - Teams Conversation Bot .试用可用的示例 - Teams Conversation Bot 。 (see for code snippet ) (请参阅代码片段)
You can use TeamsInfo.getPagedMembers to get members details in the team您可以使用TeamsInfo.getPagedMembers获取团队成员的详细信息
UPDATE - To start 1:1 conversation - We have this implemented with C# in Company Communicator App template .更新 -开始 1:1 对话- 我们在Company Communicator App 模板中使用 C# 实现了这一点。 Company communicator's code snippet for app installation.公司通讯员的应用程序安装代码片段。
To install it first, refer the document shared by @Hilton Giesenow, JavaScript snippet and follow create authProvider .要首先安装它,请参考@Hilton Giesenow 共享的文档, JavaScript 片段并按照创建 authProvider 进行操作。
Have a look at this method where we are creating a 1:1 conversation in Company Communicator.看看我们在 Company Communicator 中创建 1:1 对话的方法。 ( JavaScript method ref ). ( JavaScript 方法参考)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.