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

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

Related

How do you get a notification only teams bot to call the messaging endpoint after initial installation?

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.

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

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?

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.

Teams SDK events - determine if Team has been deleted

I have a fairly basic Teams app I've been developing, that has a bot associated with it. The bot is a simple NodeJS application, that us just waiting on events sent by my teams app to it
I see the teams conversationUpdate Type and some associated eventType in the SDK docs.
Is there an easy way to detect if the actual Team itself has been deleted?
i.e I have a Team, I add my app to it and create a tab in the team for the app. I can detect that the app has been added to the team, by checking the teamMemberAdded eventType.
But, I'm unsure if i can use the teamMemberRemoved eventType to determine if the Team has been deleted
Thanks
Currently, Bots do not receive an event when its containing team is deleted.
If you are storing team and channel details for proactive messages then you can clean it up when you get "NotFound" error code in exception while sending a message.

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