Forum Discussion
send notification for user
This is where I am struggling to convert Graph API to C# version. Could you provide example in C# for the below post call https://graph.microsoft.com/v1.0/teamwork/sendActivityNotificationToRecipients
In examples you provided I did found such implemntation.
vovanb -please have look into the below sample to implement the sendActivityNotificationToRecipients
Sample Link-Microsoft-Teams-Samples/samples/graph-activity-feed-broadcast/csharp/ActivityFeedBroadcast/Controllers/HomeController.cs at 03dae3d9e7fe34ca968abdc530ebef95132f490b · OfficeDev/Microsoft-Teams-Samples (github.com)
- Sayali-MSFTSep 06, 2023
Microsoft
vovanb - The purpose of the SendActivityNotification API is to send activity feed notifications in Microsoft Teams. This API allows you to send proactive messages to users, notifying them about updates or events related to your app.
You can send notifications to individual users or to a group of users. The recipients can be targeted based on their user ID, user principal name, or email address. You can also send notifications to a specific team or channel by specifying the team ID and channel ID.
The SendActivityNotification API should be used when you want to send notifications to users in real-time or based on specific events. It is commonly used to provide updates, alerts, or important information to users within the Teams app.
To use the SendActivityNotification API, you need to have the necessary permissions and authentication. - vovanbSep 02, 2023Copper Contributor
I am completely lost here. What is purpose of SendActivityNotification API? To whom I can send notification? When it should work? Nothing from your code example did not work for me?
Why this API created?
- Sayali-MSFTSep 01, 2023
Microsoft
vovanb -No, currently it is not possible. This is a kind of feature request, so could you please raise the feature request on Microsoft Teams · Community
- vovanbAug 31, 2023Copper Contributor
sorry, did not understand your response - so it is not possible to use that API at all? Then it is a bug?
- Sayali-MSFTAug 31, 2023
Microsoft
vovanb -Currently, we are not able to send the notification to be logged on user.
Could you please help by suggesting this feature on - Microsoft Teams · Community
- vovanbAug 21, 2023Copper Contributor
Sayali-MSFT thanks for links, BUT this examples do not working. I can not send notification to logged user.
Is it working for you? Did you try? - Sayali-MSFTAug 21, 2023
Microsoft
vovanb - We have checked with the internal team, but currently, the only available sample is the one mentioned above. There are no other simple samples available for reference.
Here is Graph Api samples available- https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/03dae3d9e7fe34ca968abdc530ebef95132f490b#graph-apis - vovanbJul 27, 2023Copper Contributor
- vovanbJul 19, 2023Copper Contributor
Below what I did :
1. Using example Sample link-https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/03dae3d9e7fe34ca968abdc530ebef95132f490b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Controllers/HomeController.cs#L72 I got:
Cannot read the value '1' as a quoted JSON string value
This is because in example Source = TeamworkActivityTopicSource.Text, converted to 1
So this example does not work
2. I create below code to simulate Graph API example I provided - similar to Graph no activities appear in Teams:var requestBody = new Microsoft.Graph.Teamwork.SendActivityNotificationToRecipients.SendActivityNotificationToRecipientsPostRequestBody { Topic = new TeamworkActivityTopic { Source = TeamworkActivityTopicSource.EntityUrl, Value = "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/12438DD2-E2C5-4CCC-B480-79D0672F86C7", }, ActivityType = "approvalRequired", PreviewText = new ItemBody { Content = "Internal spending team has a pending finance approval requests", }, Recipients = new List<TeamworkNotificationRecipient> { new AadUserNotificationRecipient { OdataType = "microsoft.graph.aadUserNotificationRecipient", UserId = userId, } }, TemplateParameters = new List<KeyValuePair> { new KeyValuePair { Name = "approvalTaskId", Value = "5", }, }, }; await graphClient.Teamwork.SendActivityNotificationToRecipients.PostAsync(requestBody);SO all examples I used does not send notification or failed.
Can you guys create simple sample which can send notification to logged user?