microsoft-graph-apimicrosoft-teams

Microsoft Graph API w/ delegated user problem


As I'm working to update my code that previously used a webhook to send messages over Microsoft Teams (marked as deprecated) I've followed the directions in the official Microsoft Graph Postman collection here and realized that application-authorization cannot send Teams messages, and I have to go the delegated-authorization route. What I'm struggling now is that this route will show me a popup in Postman to authenticate (as the user) - which is not possible from my server-side code. I've also explored the possibility to set token expiration to 1 year, but I'm not sure that this is the best path forward. Any insight is greatly appreciated!


Solution

  • There are two others options you can look at. The first is to build a bot and then use "pro-active messaging" (which basically means your bot can send a message whenever it wants, rather than trying to reply to a message that someone else has just sent) - you can read more about that here: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet#send-the-message

    Another option is to use Power Automate. In essence, it's doing the same as above, just using a pre-built bot for this scenario, the "Flow" bot. You can then trigger the flow however you like (e.g. via an http endpoint, with a Premium flow). See more on that here: https://learn.microsoft.com/en-us/power-automate/teams/send-a-message-in-teams