I'm trying to implement Proactive Messaging with a MS Teams bot. 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:
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.
To start conversation in channel - I think you are looking for something like this - see 3 point MessageAllMembers . Try the sample available - Teams Conversation Bot . (see for code snippet )
You can use TeamsInfo.getPagedMembers to get members details in the team
UPDATE - To start 1:1 conversation - We have this implemented with C# in Company Communicator App template . 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 .
Have a look at this method where we are creating a 1:1 conversation in Company Communicator. ( JavaScript method ref ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.