How to get the information about all groupChats in which my bot is part of. MsBot framework for Teams (nodejs) - botframework

When someone add my bot to their groupchat I am receiving a ConversationUpdate event and I am storing it for future reference. But storing all conversationUpdate events(which I will get when someone add my bot to their chat) of all groupChats has become a problematic. Is their any function for getting the Information about all groupChats that my bot has added to. Like we have a function for listing all Teams channels ex:- TeamsInfo.getChannels(context)
I would be thankful for any help

I'm not aware of any way to do this - the best I could suggest is something like listing conversation members of existing chats, on the graph beta endpoint (https://learn.microsoft.com/en-us/graph/api/conversationmember-list?view=graph-rest-beta&tabs=http). However, that would mean (a) it needs to returns bots as members of the chat, which I'm not sure it does (b) you'd need to basically query EVERY possible group chat in the organisation and (c) you'd need access rights to do that (e.g. application access). So, it certainly sounds like just storing the conversation id upfront on your own would be a better bet.
Recall that you can get the conversation id (if that's what you're looking for) from any event, not just conversationUpdate - even a regular message to your bot from a user in the chat will have the conversation id attached. Also, you've haven't stated what you need the conversation id for. Presumably it's for pro-active messaging, but in that case remember to store the service url as well.

Related

Can I create a configuration page for a Teams bot app?

I'm building my first Teams app which will have two primary functions:
Proactively send a message to the channel (the bot is installed into) when a specific event occurs on my backend.
Members of the channel reacts to the message via actions.
I finally have a pretty good idea of how to set this up (I think) - but one part I'm missing is that in order to identify the specific app installation as belonging to one of my customers, I need to be able to allow the installing user to supply extra information like e.g. an API-key so that I can associate the specific channel with my specific customer.
Is there any way of doing this with a bot app? I've found examples for creating a configuration page, but they all seem to be associated with tab apps?
I could of cource have the bot ask the user for the information - but maybe there's a "cleaner" way?
Any examples or tutorials would be greatly appreciated as I find it rather hard to get stuff working using Microsoft's own examples etc. :)
Thanks a lot!
When you receive any message from the user, either by typing to your bot, or even installing it into a channel, group chat, or personal context (where you get the conversationUpdate event), you are able to get specific details off of the activity object. If the user sends a message, for instance, then the text property on the activity object will have a value. Incidentally, this is the same activity you will use to get the conversation details you need for the Proactive message.
With regards your question, the activity class also includes a tenantId property, hanging off the conversation property. This is the unique Microsoft 365 Id for the tenant, which would be what I'd suggest to uniquely identify them for your API, or licensing, or similar.

Microsoft Azure Bot Service Proactive Messaging to Group (Meeting) Chat

I would like to implement the following Scenario:
Within a Meeting that should take place in the real world in a room (not necessarily within MS Teams), I want a Microsoft Azure Chat bot to post a message to the meeting-chat, without someone having to add the bot to that meeting chat.
I noticed, that real proactive messaging to MS Teams is still not possible, a workaround is necessary: Catching a conversation reference including the users teams-chat-id while he adds the bot e.g. via personal teams app. This works good, if the teams app is pushed to all users within an organization via policies.
This workaround however is not possible within a meeting-chat, that might not exist at the time the bot should write to it. So, no possibility to catch a conversation reference to post to.
Also, I noticed that there does not even exist a MS Graph endpoint neither a connector within Logic apps to post a teams message to several users without cannel-context.
Do you see any workaround for this scenario, or is it simply not supported?
To my knowledge, you're right on both accounts - a bot can't proactively message a chat that it's not part of, and I don't think Graph supports messaging to group chats altogether, which is your scenario.
Just on a point of correctness though, a bot can proactively message (a) individual users (1-1), (b) group chats, and (c) Team channels, each separately (i.e. it does not need to be installed by each user, and message each user privately, unless that is the desired scenario. All that's required for each of these is the relevant "conversationid" that represents the specific conversation, and the ServiceUrl.

MS Teams - fetch the team Ids and channel Ids in which the bot is installed

I have developed a bot in MS Teams and i want to fetch the channel Ids where the bot is installed and can send the messages.
Any ideas how to do this, thanks a lot
You can only really do this when there's an interaction from the user, so for example when the user sends your bot a message. The best time of all, however, is when your bot is actually installed, because then you have it right from the beginning. You use the ConversationUpdate event, as described here.
If it's too late for that (your bot is installed already), then I'm only aware of waiting for the next message - I'm not sure if it's possible to get things like the conversation id another way.

How to make a bot to message only certain people

I developed a welcome bot using the Microsoft Bot Framework. I want to add it to Teams. In teams I want the bot to send welcome messages to only certain members belonging to a particular team or group. Please provide me advice or steps how to do it.
You can only send a welcome message to a specific user if that user first contacted your bot. This is done purposefully to minimize the possibility of spam bots being created. Once a user has contacted your bot you can capture the user's Id and, coupled with the conversationId, you can send future (proactive) messages.

How do I correlate user between channels?

From what I see, Bot Framework is providing an abstraction over users in different channels by providing a ChannelAccount class that has ChannelId/Address pair to identify user via its account and Id property, which is... okay, here's the question.
I suppose that the idea behind Id is to provide a unique and persistent identifier that can be used to cross-correlate users between account (i.e., I can say that Slack user #alpha is also email user alpha#company.con). This idea is supported by the fact that ChannelAccount for my bot always has same Id regardless of the channel (and Address is different between channels, obviously).
If this is right, and I hope it is, is there any way to provide BotConnector with the correlation information? I.e., I want BotConnector to give me ChannelId/Address, and I'd give back user Id which I'd the get back in incoming message.
The purpose of this is quite simple: I want the code inside my bot to use the Id as already correlated identifier so that I can log it, build logic from it and so on.
BotFramework does not yet support linking of accounts. In the interim, take a look at this post for one way you might implement a solution:
Why isn't BotUserData persisting and retrievable in my Bot Framework bot?

Resources