What happens to the activity if my end point is not accessible or returns a 500? - botframework

I have a Microsoft bot app that can be installed in Teams on a team.
For now, I save the tenant ID + team id in our DB when the app gets installed, via a received activity on our end point.
What happens if my prod is not up at the moment of the installation? (for whatever reason, could be an update or just a technical downtime...)
Is it lost forever? Is it retried?
Same question with a 500 error?
This activity is an example, it could be any other activity. Ex: a user is added/removed, a message has been sent etc...

For OnMembersAddedAsync; unfortunately there is no retry from the Teams side, it fires and forgets.
The information in that Activity will be included in any subsequent send from Teams - so the bot can recover, if the user interacts with the bot again. Messages would just be sent when the bot recovers.
You can find a bit more info on Teams and events here:
How do I send a 1:1 welcome message?

Related

How to retrieve conversationId for notification only bot which was already installed?

I created a notification only Bot for MS Teams app for proactive notification. I was able to successfully install the bot and also received ConversationUpdate event, from which I saved conversationId for future notifications. However, there might be some situations when the conversationId could not be saved, maybe because of high volume of data or some bug in our codebase or server issue or some other reason. How to retrieve conversationId in these situations? Is there a way that we can acknowledge whether the ConverationUpdate event was successful, so that the event can be retried upon failure.
I've not actually tried this, but I think you can do this via the graph. I think it will require two steps:
get the app info: https://learn.microsoft.com/en-us/graph/api/userteamwork-list-installedapps?view=graph-rest-1.0&tabs=http (i.e. the specific installation ID for this app to this user)
get the details of the specific app/user conversation: https://learn.microsoft.com/en-us/graph/api/userscopeteamsappinstallation-get-chat?view=graph-rest-1.0&tabs=http

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.

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.

MS Teams bot no longer receives messages

After moving MS Teams bot to another server, it no longer replies to messages. It still successfully sends proactive messages on its own, however responding to messages no longer works. Messaging endpoint stayed the same (only IP changed)...
I watched for network activity when clicking a button in adaptive card (posted by bot) and error 502 is reported with {"errorCode":1008,"message":"Invoke agent action failed with status code: BadGateway"} returned. I'd appreciate any ideas how to sort this out... Thank you.
If the IP / URL of your bot changed you need to make sure to update the messaging endpoint in the bot definition.
If you registered your bot in dev.botframework.com or azure there's a setting "messaging endpoint url" which you need to update and point to the new ip.
If just the IP behind your URL changed, it might be some caching/dns issue on MS Teams end. Did you try to reinstall the bot completely?

How do I receive only the messages that are direct messages to my bot user?

I have successfully setup my slack bot app, have enabled events etc. I want to receive any direct messages that the members of my slack team send to my bot. For this, I have only enabled Bot Events and No Team Events like below
However, I do not get any event on my webhook on this setting.
If I enable message.im event under Team Events, then I start getting events. But then, I get every message that the user (who has installed the app) sends to any other user in the team.
How do I get only the messages that are sent to my bot user?
Update 1
Based on this SO question I created a private channel with the bot user. Even then, the messages in the private channel do not arrive in my webhook with the above event subscriptions.
Update 2
After reinstalling the app, it seems to be working fine. I have only used it for few minutes after the reinstall so far. I will keep posting here how it goes. It would still be interesting to know what went wrong where.
It is normal behavior that your script receives all messages (for every channel your bot is a member of), not only the messages sent directly to your bot. At this time you can not filter further in the event configuration. So you need to filter out any unwanted message in your script handling the event.
See also this answer.

Resources