Send Microsoft Teams message from Application to User

Certified Lead Developer

Hi, looking for some guidance on how to send Teams messages from our App directly to a user.

We tried using the Teams Plugin but found we were limited by only being able to send messages with authentication Authorisation Code Grant (Delegated Permissions), this was forcing each user to individually authenticate from the app, which isn't what we're looking for.

We want to send chat messages directly from a System(Application) user. (I think this is a limitation of Teams rather than the plugin itself).

We have found the below link on "Activity Notifications" in Teams rather than chat messages, has anyone had any experience with this? I'm just looking for confirmation that this method will achieve the results before I go down the rabbit hole.

learn.microsoft.com/.../teams-send-activityfeednotifications

Or if not, does anyone know any other way for us to achieve the desired behaviour?

Thanks!

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Hey Guy,

    There is some great information here - learn.microsoft.com/.../auth-v2-service

    In order for Teams to generate chat messages based upon a system account, the term to research is "Service Principal". There's way more detail about that in the link above than I could accurately provide here.

    We're still in the early stages of our API, so there may be additional hurdles. But here is what we have so far.

    For the graph API, you might not need the plugin in all cases.

    • Create a HTTP Connected System
      • Choose OAuth Client Credentials, input client id and secret
      • Token Request Endpoint: As noted in the above link - login.microsoftonline.com/{Tenant_Id}/oauth2/v2.0/token
    • Create integration
      • Use your connected system for authentication
      • Use the graph API for the URL, then add the appropriate query parameters / body based upon what you're trying to do. Pay specific attention to the quotes in query parameters.

    Also keep in mind that, functionally, a lot of the graph messaging API relies on Teams Id's, not email / names. We're still trying to solve that in a more fluid way.

    I don't have experience with Activity Notifications, but they will likely be our fall back plan if our currently-designed Teams chat features are not approved for production by our security team. Lots of folks get involved when there is potential (even if mitigated) for a service account to act on behalf of a user.