Reputation: 61
I need to send a Teams message to user/channel from the java service. These are notifications about events that happen in the application (e.g. when someone sells a product, they should receive a message on the teams that the product has been sold). I have already configured Microsoft Graph API for my application in Azure but as far as I know it is not possible to send message directly to users using "Application" permissions. (DOCS)
Is it any walk around for this restriction? Can I use a newly created account specifically for my purposes to authorize from the Java service in graph API and then sending messages to users?
I also found information about bots and sending proactive notifications to users. Is it possible to use it in my case as a proxy between java app and Teams user?
If I have multiple customers from multiple Microsoft organizations and I want to provide them my bot with proactive notification feature How should I deploy it? Does each client have to provide me an access to the Microsoft AD with application permissions and add my bot to his Bot Service? Or it is possible to deploy the bot only in my environment and make it available to my clients somehow?
Upvotes: 3
Views: 9586
Reputation: 595
There is a way to easily send a message to a channel, but not to a direct message to a person though. To achiever so you can follow the official documentation In other words you can add/setup an incoming web hook to a channel, grab the link provided by it and use a CURL request to send a message like so:
curl -H "Content-Type: application/json" -d "{\"text\": \"test\"}" https://uri-provided_by_hook
Hopefully, there is no need to inform about how to execute an http request through Java code.
Upvotes: 0
Reputation: 12284
What you're trying to do is called proactive messaging and you can read about it here: https://learn.microsoft.com/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages
You can deploy your bot wherever you like so long as you make sure the Teams app is published. You can make your bot available to everyone by publishing to the Teams app store, also called AppSource: https://learn.microsoft.com/microsoftteams/platform/concepts/deploy-and-publish/appsource/publish
If you don't want the app to be available to everyone, there may be a way to publish it to individual app catalogs: https://learn.microsoft.com/MicrosoftTeams/manage-apps
Upvotes: 0