Search code examples
pythonazurebotframeworkmicrosoft-teams

Proactive Messaging in MS Teams


I am trying to build a bot that can initiate a message direclty to a user who is in our organization (i.e. not a message into a Teams channel). I was only able to do this with the following methods:

  1. when the user initiates the conversation?
  2. when the user install the apps from the app store (the bot app is available)
  3. when the user is added to the teams channel where the app is installed.

I have spent a huge amount of time searching the solution documentation and now I'm getting the feeling that my requirement is not possible. It would be really nice if someone has some leads on it?

Thanks in advance


Solution

  • Per the conversation above in the original post, Bots in Teams can only continue an existing conversation - they can't create new ones per se. As a result, you need to pre-install your bot for the relevant users. There are two main ways to do this:

    1. Using Teams Policy - this requires an Admin, in the Teams Admin centre - see more here: https://learn.microsoft.com/en-us/microsoftteams/teams-app-setup-policies#install-apps . This option is the easiest, fastest, and most simple, but might not be available (e.g. no access to Teams Admin)
    2. The other option is to use the Microsoft Graph to auto-install the app for the user. To do this, here's the reference: https://learn.microsoft.com/en-us/graph/api/userteamwork-post-installedapps?view=graph-rest-1.0&tabs=http

    Both of these approaches will work fine for an organisational app too - they don't need to be in the actual Teams Store