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