Forum Discussion
vovanb
Jul 10, 2023Copper Contributor
send notification for user
I am using SendActivityNotification as below: var requestBody = new Microsoft.Graph.Users.Item.Teamwork.SendActivityNotification.SendActivityNotificationPostRequestBody
...
Sayali-MSFT
Microsoft
Jul 11, 2023vovanb -To ensure that the recipient of the notification is not the same as the sender.
Could you please try with the code like below, as here mentioned the recipient -
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new Microsoft.Graph.Chats.Item.SendActivityNotification.SendActivityNotificationPostRequestBody
{
Topic = new TeamworkActivityTopic
{
Source = TeamworkActivityTopicSource.EntityUrl,
Value = "https://graph.microsoft.com/v1.0/chats/{chatId}",
},
ActivityType = "taskCreated",
PreviewText = new ItemBody
{
Content = "New Task Created",
},
Recipient = new AadUserNotificationRecipient
{
OdataType = "microsoft.graph.aadUserNotificationRecipient",
UserId = "569363e2-4e49-4661-87f2-16f245c5d66a",
},
TemplateParameters = new List<KeyValuePair>
{
new KeyValuePair
{
Name = "taskId",
Value = "12322",
},
},
};
await graphClient.Chats["{chat-id}"].SendActivityNotification.PostAsync(requestBody);
Reference Document-Send activity feed notifications to users in Microsoft Teams - Microsoft Graph | Microsoft Learn
Sayali-MSFT
Microsoft
Jul 13, 2023vovanb -Did you get chance to check above solution?
- vovanbJul 13, 2023Copper ContributorHi
I do not see difference between example I sent and you provided. I need to notify my user (which I logged in ) about new task created. so - notification should be sent to me. How to do it?- Sayali-MSFTJul 13, 2023
Microsoft
vovanb - Could you please Refer the below sample- https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/03dae3d9e7fe34ca968abdc530ebef95132f490b/samples/graph-activity-feed/csharp/ActivityFeedNotification/Controllers/HomeController.cs#L72- vovanbJul 13, 2023Copper ContributorThis is EXACTLY what I used - you can even see my code from this example. BUT i got error "The recipient of the notification cannot be the same as the sender of the notification."