I need to get and active users list or active connections who are in chat Bot Framework - asp.net-core-mvc

I need active users or active connections list who are available to chat, who left from conversation I don't want to retrive those in below code, please help me out on this below is the code of getting all connections list.
var activity = dc.Context.Activity;
IList<ConnectionRequest> connectionRequests =
_messageRouter.RoutingDataManager.GetConnectionRequests();
replyActivity = activity.CreateReply();
if (connectionRequests.Count == 0)
{
replyActivity.Text = "No pending requests";
}
else
{
replyActivity.Attachments = CommandCardFactory.CreateMultipleConnectionRequestCards(
connectionRequests, userService, activity.Recipient?.Name);
}

The way bots built with the Bot Framework work is somewhat different that bots made for a specific service, like a Discord bot or a Slack bot. Since there are a multitude of different channels that you might offer your bot on, some of which don't have the concept of "online users" as such, there is no built-in functionality that gets all online users.
Depending on the channel in which your bot is operating, the concept of "online users" could have different meanings. A Teams bot for example only connects to a new user one time, and persists the conversation, whereas a Direct Line bot does not.
Bots developed with the Bot Framework SDK are inherently stateless, and as such you would need to define and implement your own method for identifying and contacting "online users".
You could for example store the names and user IDs of users who connect to your bot for a period of time. If your users use AAD auth you could make use of Microsoft Graph APIs.
Essentially, there is no standard way to do this, and you would need to define your own custom logic to fit the channel and features of your specific bot.

Related

Send a user message to a user via Power Automate in MS Teams

Is there a possibility to send a user message to specified user(s) in MS Teams?
Elaboration:
My current flow triggers a message to a user, but it is always sent via FlowBot and appears in the Power Automate chat of MS Teams.
Flow: (Outlook; Trigger) "When a new email arrives (V3)" → (MS Teams) "Post message in chat or channel" → (Outlook) "Mark as read or unread" (v3)
Can individual users be set as recipients of direct messages with the message sent in the already existing chat with the user?
If yes, is it possible without a value chain?
Thanks!
As I see it, there are kind of a few different questions in your post, so I'll try deal with each of them:
In order to send a message directly to a user, the user has to come "from" someone/something, and in Teams that basically means a Bot. The easiest way, therefore, to do this is to use the out-of-box FlowBot. If that's fine for you, you're good to go. If you want it to come from another Bot (i.e. one you own) then you need to create a Bot somehow. Two main options are:
Code it from scratch using Microsoft Bot Framework - code in a regular language (C#, Python, etc.) or using Bot Framework Composer
Use Power Virtual Agents - ala "Power" family, it's kind of a "Drag and Drop" bot capability. You don't need to actually have the bot DO anything though, if you don't want it to handle user responses (you can do most of that visually in your Power Automate flow. For this option, you'll be able to select the bot from within Power Automate designer as the "send from" bot
You can choose to have the bot send a message directly to the user (i.e. in a 1-1 chat, like what you're seeing with FlowBot) or you can choose to have it send to a particular Channel inside Teams - either is fine. Be aware that Channels have threaded conversations, if you want to use them, but 1-1 chats do not.
You can try these Power Automate steps to create the 1:1 chat between you and the user, then send a message to it.

How to send message to all the members of the group on Installing teams bot

I have created a teams bot and had a service written in .NET core to handle events and user's messages to reply accordingly.
When I install a bot in a group, I need to send personal message(one-to-one i.e between bot and the user) to all the members of that group on installation. I am trying to do that in OnConversationUpdateActivityAsync event handler (which gets fired when I install the bot). But in this event I am getting information of the user who is installing the bot, not the other members which are added in that group, also I am not getting any information of the channel(channelId and members etc.) in which the bot is getting installed.
Any different approach or solution will work.
Thanks in Advance.
You haven't said if you want the bot to message the users privately (like 1-1 between the bot and user) or just send each person a personal message inside the group chat, but in both cases, Proactive Messaging is your correct approach. If you want to send a message inside the group chat itself, see this sample.
If you want to send the users messages directly, 1-1, they need to have the bot installed as a personal app already. It's possible to do this automatically, but it's a bit more work, and requires Microsoft Graph. The proactive messaging is a bit different too - you get the list of members as per the previous sample, but see here for how to get the required 1-1 conversation details, and how to send the actual message. This last link also has documentation on how to get started, and some background reading (at the bottom of the page).
#Hilton is correct, You need to specify in which scope you want to notify user 1:1 or directly in Group chat?
App should be installed in user scope if notifying user on installation, You can proactively install the App in User/Group Chat/ team scope using Graph API. To notify users in Teams or Group chat, You can fetch the list of members using List conversation members API, When you install the App using Graph API Bot received converstionUpdate, You can save the conversationReference and use it for proactively notifying.

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.

Is it possible for a single Teams bot to have more than 1 simultaneous chat conversation with the same user?

For a remote advisor solution, we would like a Teams bot to be able to carry on multiple 1:1 chat conversations with the same user (advisor) in independent chat windows.
Currently of course you can only have one chat widow between 2 participants and it appears only 1 conversation ID. (Using threaded conversations has cognitive overload on the adviser to keep track of multiple threads, so independent chat windows is preferred)
What are some techniques to make this possible, other than to use multiple cooperating bots?
It is not possible, because when you create a conversation with a user you use tenantId + userId, which results in a conversation. There is no way to have multiple ones.. it is like 1-on-1 chat with a person, you cannot have many of them.
As an alternative, you can create public or private group chat and invite there a person and the bot. You can many of them.
It is not possible to have multiple 1:1 chats with the same Bot. Each user will only have a single chat window with one Bot. If you want this bot to be able to interact with many people at once you can add it to teams scope.

Can user resume a conversation in a different channel? (Bot Framework)

Let's think of the following example:
1) I have a certain bot deployed on Azure
2) Bot can be talked via Facebook Messenger and via Skype
3) A certain user talks to the bot via Facebook Messenger and then he leaves.
4)A couple of minutes ago the same user resumes the conversation with the bot, but via Skype.
Is this possible? I assume Bot Framework doesn't have anything included for this, hence, that this isn't posible (as conversations are independent and state changes depending on the channel). Is there any way to identify a user (via some authentication method maybe), and then making this logic again?
Do any of you know any workaround for this?
Thanks in advance!
The Bot Framework Connector service is a component which provides a single API for your bot to communicate across multiple client services such as Skype, Email, Slack. Every bot and user has an account within each channel.
The channel account contains an identifier (id) and other informative bot non-structural data, like an optional name.
And there us unique conversation ID created for each conversation of each user for each channel. And you can customize your channel capabilities as described here.
Regards,
Jyo

Resources