How to send the Message to teams using Bot Framework? - botframework

I have created one Chatbot using MS Bot Framework. Also added that in My Teams App. But not able to send messages to the users who not installed that app in there Teams. I just wanted to check if there is any provision to send the message to the users who not installed the Bot to there Teams App.

There is no way to send proactive messages to users who have not installed and interacted with your bot. Your bot has no way of knowing who those users are. If a user wants to communicate with the bot, they must install the app.

Adding to this. I ran into a similar issue where I had a Teams app that uses a notification style bot to send one-way notifications to users. The only way I was able to communicate to them was by getting the user context via an app install event. When an install event is captured, I save that users' context into a SQL database table in the event of the bot being restarted (then reload on start).
You can use the Graph API to install the bot automatically (see Proactive installation of apps using Graph API to send messages) or install it via a MS Teams app setup policies (see Install apps).

Related

Azure Bot messaging endpoint does not get teamMemberRemoved event when the Bot App is removed from Teams

I created an Azure Bot and set the Messaging Endpoint to my web-app, which is not hosted on Azure.
I created a deploy package zip as a Teams App to be deployed on Teams and use my bot.
My messaging endpoint gets the ConversationUpdate events with membersAdded type when the customer adds my bot to Teams, and when users are added. The events are sent to the Messaging Endpoint configured in my bot.
When the customer deletes the App from Teams I do not get any event to the messaging endpoint.
According to https://techcommunity.microsoft.com/t5/microsoft-teams/which-event-fired-when-someone-uninstall-your-app-in-microsoft/m-p/1610299 I expected to get an event with type teamMemberRemoved to the bot messaging endpoint.
I need to know the Teams App was removed so I can clean up resources on my end, and indicate in my UI to the customer that the bot is no longer configured for his Teams team.
I tried adding and removing the App from my Teams account a few times but never got the expected event to the messaging endpoint.
How can I know that my App was uninstalled on a Teams team?
If you just want to know when the App is getting added or remove you can use OnInstallationUpdateAsync, here you will get the type installationUpdate and action as remove when it gets uninstalled.
I tried with onConversationUpdateAsync as well and got the request as . Please confirm once if you are handling it property,

How to make a bot receive attachments when channeling it to MS Teams

I made a normal bot by using Microsoft Bot Framework and have deployed it to the Azure portal. I tried to channel the bot to Teams, which worked but the bot couldn’t receive attachments. How can I make it do so?
Thanks.
Microsoft Teams does not allow attachments by default. To send and receive files in the bot in teams, set the supportsFiles property in the manifest to true or else create an app for your bot in App studio. Specify your app allows upload attachments. And install it in your own Team account for testing. Please look at this sample code for reference.

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.

Is there any way to get user details whenever user uninstalls bot and bot is installed in personal scope only?

This is conversationUpdate event with membersRemoved object but that works only in the case when the bot is installed in a group and either the bot or member is removed from the group but I don't receive any callback when the bot is installed in personal scope and is removed later.
Unfortunately, there's no event/information sent on this at all from Teams. There's a new event in the bot framework (latest release) called "InstallationUpdate", which I was hoping would cover this, but that also doesn't send anything, at least not at the moment.

Slack Events API / RTM: New app installed realtime notification

Is it possible to get a slack event or real time message indicating that a new app was installed in a workspace? I can figure out apps which use "bot users" by listening for team_join event. But how can i find out in near realtime about apps installed that don't have a bot user. My use case is to present something to the user when a new app is installed (as soon as possible. I can find out apps from team logs but thats not realtime).
What you're doing with the team_join event is basically all you can do. And that's going to rely on either the app having a bot user, or it being a workspace app (https://api.slack.com/slack-apps-preview), which creates an app user.
Other than that, nothing is exposed in the Events API around app installation. The other alternative is to connect up via the RTM API and watch for the bot_added and commands_changed events. That should catch most apps.

Resources