WebApp that sends messages to MS Teams channel; Channel picker at WebApp side

Jan Hrdina 6 Reputation points
2021-05-31T15:41:59.857+00:00

We would like to implement a simple integration so that our webapp can send messages to specified team+channel of our users.

  • After the user authorizes, he can choose/change the target team+channel through our app
  • even non-admin user can install it
  • (nice-to-have) Displayed sender of the messages should be our FooApp, not the authorized user.

See below for UI workflow.

What is your recommended way of implementing the simple use-case above?

We've tried multiple solutions but always ended up in a dead end. Any help would be really appreciated...

Just for reference, here's what we've tried:

  1. Auth code flow and user delegated permissions
    • result is an ACCESS_TOKEN with 1 hour expiration (not worth storing) or, if we replace the node-msal library with manual implementation, we get REFRESH_TOKEN... We're not sure about its validity, but some of your Doc pages sources suggest it should be 14 days?
    • We don't want to refresh the token for all our registrations every 14 days... or is it really necessary?
    • CON (low priority): Sender of the messages is the registered user
  2. Authorize with application permissions (client_credentials)
    • don't store ACCESS_TOKEN nor REFRESH_TOKEN on our app's side but rather only store tenantId.
    • we were able to fetch teams and channels thus
    • messages cannot be sent with application permissions
    • CON: only admin can install these
    • CON: for some reason, normal user cannot login even if the Admin has already granted permissions to our app
    • we need the normal user login because we need to find out the tenantId of the user
  3. Webhooks or MS Teams connector that simply shows webhook URL our app Name + Logo
    • bad UX
    • user cannot select the team+channel directly in our app
    • manual copying of URL
    • you need to install it for each channel separately
  4. Create a bot
    • we don't know how to fetch the list of teams/channels in our app - we run into the issues mentioned in variants 1 and 2 above
      • 1 - requires refresh token refreshing and reimplementation of node-msal
      • 2 - cannot be installed by a non-admin user
    • we're currently investigating this option
    • CON: It is paid for the amount of messages we need
    • CON: Seems like an overkill for simple non-interactive messages.

101116-2021-05-31-ms-teams-ui-flows.png

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,437 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,062 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Harshit Kedia 6 Reputation points
    2021-06-09T11:58:11.987+00:00

    Hi, we are facing a similar problem, did you find any solution to this yet?
    We want to send same message from some person's account to multiple users as personal chat. We proposed using GraphAPI to solve the problem, authentication isn't our concern right now.
    But now we are at a dead-end due to throttle limits of the api.
    Throttling at 2rps will be very bad. Can anyone help us to get around this problem, is it possible to increase this limit (or use a paid plan), if i use json batching, will this limit apply.
    If the Graph api limit still applies, then we will have to look at solution using bots.

    1 person found this answer helpful.

  2. Mamatha-MSFT 161 Reputation points
    2021-06-04T04:48:53.64+00:00

    Hi @Jan Hrdina - You can fetch list of joined teams using graph API.
    GET https://graph.microsoft.com/v1.0/me/joinedTeams request and you can get list of channels in teams using
    GET https://graph.microsoft.com/v1.0/teams/{team-id}/channels request

    To send messages to a channel using graph for multi tenant, you need to register the application as a multi tenant,
    Or if you want to use it for personal account users then choose the option accordingly while registering the application.
    Please go through the documentation of register an application with the Microsoft identity platform.