I have created a bot using Bot framework V4 and hosted in Teams.
My bot is available for all the users in the organization.
I want to know if someone blocked the bot.
Is there any API or any event from the bot to know the user ID if the Bot has been blocked?
Thanks in Advance
I'm still testing this, so not sure if it really works, but I think if the user has uninstalled an app, then trying to get the "conversation members" will fail, whereas it would succeed otherwise. Code is something like this (C#):
ConnectorClient connector = new ConnectorClient(new Uri(serviceUrl), appId, appSecret);
MicrosoftAppCredentials.TrustServiceUrl(serviceUrl);
var members = connector.Conversations.GetConversationMembersAsync(userConversationId).Result;
That might only work if they're -uninstalled- the app though, versus -blocked- the bot, but it's easy enough to test (I won't have a chance today though).
Related
We have a notification only teams bot that is live for a number of customers in production.
Most of the time when it is installed it calls our messaging endpoint and updates the conversation ID so we can send teams notifications to our customers, however sometimes it seems to fail to do this for some reason so our systems don’t get a conversation ID.
We tried incrementing the version number of the teams bot and that didn’t seem to help.
Is there some way to get the conversation ID updated after initial installation?
Answer after contacting Microsoft Support is that it is impossible. The best solution is to have a non-notification only bot and then it works as you'd expect.
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.
I try to write an app for Microsoft Teams which does include a Bot.
The bot should write a welcome message as soon as the app is installed by the user in his personal scope. Additionally I want to be informed when the user uninstalled an app.
There are events when a new user is added/removed to a team (onTeamsMemberAdded/onTeamsMemberRemoved) in which the bot is installed, but is there also something for the personal scope?
onTeamsMemberAdded should deal with personal scope as well, and it will enable you to send a welcome message. However, there is unfortunately no way to get notified when your bot is removed. onTeamsMemberRemoved only applies when your bot is part of a group chat, or channel, and only tells if other users have been removed. This is a missing feature in Teams right now.
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.
I'm building a MS Teams bot and have a question about the serviceUrl.
For some context, our bot app will be installed in our customers' teams and we are wondering if users in the same tenant will share the same serviceUrl. We are aware that this url changes from time to time but trying to figure out at what resource level we need to cache this value.
Would be ideal if I can keep track of a single serviceUrl for my bot but wondering if the url could vary from tenant to tenant, or even, user to user.
Figuring this serviceUrl is an important piece to our implementation because 1) we want to be able to get the teams roster 2) we want to be able to send proactive messages to a user that has never messaged us before.
Please let me know if there is anything I could clarify and thank you so much for your help!
This was the documentation for Teams Roster that we were looking at that explains the serviceUrl
https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json#fetching-the-roster-or-user-profile