SOLVED

Notifications for custom applications

Occasional Contributor

 

Hello Everyone,

 

I have created an app using the Developer portal and hosted it for my domain. App loads data from an external system where the web application is hosted. 

The app works fine when I am on that particular app but when I move to the Calls or Chats tab the connection is getting closed. At this point, if anyone is trying to send some information it doesn't come up as the connection is closed.

 

Is there any way to make a rest API call from an external system to teams and notify the user or the app that something is new, please have a look.

 

I went through graph API but in that case, we need to have a user who will be used to send a request to another user. 

 

Suggestions will help to evaluate the possible options.

 

Thanks,

Pratap

 

8 Replies
1) One way is to send an activity feed notification to a user using application permissions like below:
https://docs.microsoft.com/en-us/graph/api/userteamwork-sendactivitynotification?view=graph-rest-1.0...

2) Other way is to create a Incoming Webhooks but it allows external applications to share content in Microsoft Teams channels but not personally to specific person:
https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming...





Thanks, Chetan for your reply.

For using the sendactivitynotification we will need a user with O365 license.

Is there any alternate way where we will not need a licensed user ?


If you are using Teams then I think you already have O365 license.
Also, you need Azure Subscription to create Azure App registration with application permission to call the specific Graph API.


Hi,

I tried using sendActivityNotification API but got the below error every time.

Application with AAD App Id 'de8bc8b5-d9f9-48b1-a8ad-b748da725064' is not authorized to generate custom text notifications about '/v1.0/users/XXXX/teamwork/Microsoft.Teams.GraphSvc.sendActivityNotification' to the recipient. Ensure that the expected Teams app is installed in the target scope (user, team, or chat).

 

The token which is generated has below scopes:
openid profile User.Read email TeamsActivity.Send

 

de8bc8b5-d9f9-48b1-a8ad-b748da725064 is the appid of the graph explorer, in my case I want API to be executed from an external system.


Let me know if I am missing anything and how to achieve it. 

best response confirmed by ChetanSharma-msft (Microsoft)
Solution

Based on the error it seems like the app is not installed in the Teams. Could you please follow this document and sample to set it up correctly.

 

  1. https://docs.microsoft.com/en-us/graph/teams-send-activityfeednotifications
  2. https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/graph-activity-feed

Thanks Meghana, it worked.
Yes..