Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Send an activity feed notification to a user. For more information, see sending Teams activity notifications.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|
✅ | ✅ | ✅ | ✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type | Least privileged permissions | Higher privileged permissions |
---|
Delegated (work or school account) | TeamsActivity.Send | Not available. |
Delegated (personal Microsoft account) | Not supported. | Not supported. |
Application | TeamsActivity.Send.User | TeamsActivity.Send |
Note: The TeamsActivity.Send.User
permission uses resource-specific consent.
HTTP request
POST /users/{userId | user-principal-name}/teamwork/sendActivityNotification
Request body
In the request body, supply JSON representation of the parameters.
The following table shows the parameters that can be used with this action.
Parameter | Type | Description |
---|
activityType | String | The activity type must be declared in the Teams app manifest, except for systemDefault Reserved activity type, which provides free-form text in the Actor+Reason line of the notification. |
chainId | Int64 | Optional. Used to override a previous notification. Use the same chainId in subsequent requests to override the previous notification. |
iconId | String | Optional. The unique icon ID that allows apps to send customized icons per activity type. Icon IDs must be present in the Teams app manifest schema. If the icon ID is specified in the manifest but missing from the API request body, the icon falls back to the default icon for the app. |
previewText | itemBody | The preview text for the notification. Microsoft Teams only shows the first 150 characters. |
teamsAppId | String | Optional. The Teams app ID of the Teams app associated with the notification. Used to disambiguate installed apps when multiple apps with the same Microsoft Entra ID app ID are installed for the same recipient user. Avoid sharing Microsoft Entra ID app IDs between Teams apps. |
templateParameters | keyValuePair collection | The values for the template variables defined in the activity feed entry corresponding to activityType in the Teams app manifest. |
topic | teamworkActivityTopic | The topic of the notification. Specifies the resource being talked about. |
The following resources are supported when setting the source
value of the topic property to entityUrl
:
Response
If successful, this action returns a 204 No Content
response code.
Examples
Example 1: Send notification to a user for a task created
Request
POST https://graph.microsoft.com/beta/users/{userId}/teamwork/sendActivityNotification Content-Type: application/json { "topic": { "source": "entityUrl", "value": "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}" }, "activityType": "taskCreated", "previewText": { "content": "New Task Created" }, "templateParameters": [ { "name": "taskId", "value": "Task 12322" } ] }
// Code snippets are only available for the latest version. Current version is 5.x // Dependencies using Microsoft.Graph.Beta.Users.Item.Teamwork.SendActivityNotification; using Microsoft.Graph.Beta.Models; var requestBody = new SendActivityNotificationPostRequestBody { Topic = new TeamworkActivityTopic { Source = TeamworkActivityTopicSource.EntityUrl, Value = "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}", }, ActivityType = "taskCreated", PreviewText = new ItemBody { Content = "New Task Created", }, TemplateParameters = new List<KeyValuePair> { new KeyValuePair { Name = "taskId", Value = "Task 12322", }, }, }; // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp await graphClient.Users["{user-id}"].Teamwork.SendActivityNotification.PostAsync(requestBody);
mgc-beta users teamwork send-activity-notification post --user-id {user-id} --body '{\ "topic": {\ "source": "entityUrl",\ "value": "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}"\ },\ "activityType": "taskCreated",\ "previewText": {\ "content": "New Task Created"\ },\ "templateParameters": [\ {\ "name": "taskId",\ "value": "Task 12322"\ }\ ]\ }\ '
// Code snippets are only available for the latest major version. Current major version is $v0.* // Dependencies import ( "context" msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go" graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users" graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models" //other-imports ) requestBody := graphusers.NewSendActivityNotificationPostRequestBody() topic := graphmodels.NewTeamworkActivityTopic() source := graphmodels.ENTITYURL_TEAMWORKACTIVITYTOPICSOURCE topic.SetSource(&source) value := "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}" topic.SetValue(&value) requestBody.SetTopic(topic) activityType := "taskCreated" requestBody.SetActivityType(&activityType) previewText := graphmodels.NewItemBody() content := "New Task Created" previewText.SetContent(&content) requestBody.SetPreviewText(previewText) keyValuePair := graphmodels.NewKeyValuePair() name := "taskId" keyValuePair.SetName(&name) value := "Task 12322" keyValuePair.SetValue(&value) templateParameters := []graphmodels.KeyValuePairable { keyValuePair, } requestBody.SetTemplateParameters(templateParameters) // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go graphClient.Users().ByUserId("user-id").Teamwork().SendActivityNotification().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x GraphServiceClient graphClient = new GraphServiceClient(requestAdapter); com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody sendActivityNotificationPostRequestBody = new com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody(); TeamworkActivityTopic topic = new TeamworkActivityTopic(); topic.setSource(TeamworkActivityTopicSource.EntityUrl); topic.setValue("https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}"); sendActivityNotificationPostRequestBody.setTopic(topic); sendActivityNotificationPostRequestBody.setActivityType("taskCreated"); ItemBody previewText = new ItemBody(); previewText.setContent("New Task Created"); sendActivityNotificationPostRequestBody.setPreviewText(previewText); LinkedList<KeyValuePair> templateParameters = new LinkedList<KeyValuePair>(); KeyValuePair keyValuePair = new KeyValuePair(); keyValuePair.setName("taskId"); keyValuePair.setValue("Task 12322"); templateParameters.add(keyValuePair); sendActivityNotificationPostRequestBody.setTemplateParameters(templateParameters); graphClient.users().byUserId("{user-id}").teamwork().sendActivityNotification().post(sendActivityNotificationPostRequestBody);
const options = { authProvider, }; const client = Client.init(options); const sendActivityNotification = { topic: { source: 'entityUrl', value: 'https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}' }, activityType: 'taskCreated', previewText: { content: 'New Task Created' }, templateParameters: [ { name: 'taskId', value: 'Task 12322' } ] }; await client.api('/users/{userId}/teamwork/sendActivityNotification') .version('beta') .post(sendActivityNotification);
<?php use Microsoft\Graph\Beta\GraphServiceClient; use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\SendActivityNotification\SendActivityNotificationPostRequestBody; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopic; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopicSource; use Microsoft\Graph\Beta\Generated\Models\ItemBody; use Microsoft\Graph\Beta\Generated\Models\KeyValuePair; $graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes); $requestBody = new SendActivityNotificationPostRequestBody(); $topic = new TeamworkActivityTopic(); $topic->setSource(new TeamworkActivityTopicSource('entityUrl')); $topic->setValue('https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}'); $requestBody->setTopic($topic); $requestBody->setActivityType('taskCreated'); $previewText = new ItemBody(); $previewText->setContent('New Task Created'); $requestBody->setPreviewText($previewText); $templateParametersKeyValuePair1 = new KeyValuePair(); $templateParametersKeyValuePair1->setName('taskId'); $templateParametersKeyValuePair1->setValue('Task 12322'); $templateParametersArray []= $templateParametersKeyValuePair1; $requestBody->setTemplateParameters($templateParametersArray); $graphServiceClient->users()->byUserId('user-id')->teamwork()->sendActivityNotification()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams $params = @{ topic = @{ source = "entityUrl" value = "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}" } activityType = "taskCreated" previewText = @{ content = "New Task Created" } templateParameters = @( @{ name = "taskId" value = "Task 12322" } ) } Send-MgBetaUserTeamworkActivityNotification -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x from msgraph_beta import GraphServiceClient from msgraph_beta.generated.users.item.teamwork.send_activity_notification.send_activity_notification_post_request_body import SendActivityNotificationPostRequestBody from msgraph_beta.generated.models.teamwork_activity_topic import TeamworkActivityTopic from msgraph_beta.generated.models.teamwork_activity_topic_source import TeamworkActivityTopicSource from msgraph_beta.generated.models.item_body import ItemBody from msgraph_beta.generated.models.key_value_pair import KeyValuePair # To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python request_body = SendActivityNotificationPostRequestBody( topic = TeamworkActivityTopic( source = TeamworkActivityTopicSource.EntityUrl, value = "https://graph.microsoft.com/beta/users/{userId}/teamwork/installedApps/{installationId}", ), activity_type = "taskCreated", preview_text = ItemBody( content = "New Task Created", ), template_parameters = [ KeyValuePair( name = "taskId", value = "Task 12322", ), ], ) await graph_client.users.by_user_id('user-id').teamwork.send_activity_notification.post(request_body)
Response
HTTP/1.1 204 No Content
Example 2: Notify a user about an event using a custom topic
If you want to link an aspect that Microsoft Graph doesn't represent, or you want to customize the name, you can set the source of the topic
to text
and pass in a custom value for it. webUrl
is required when using topic
source as text
.
Request
POST https://graph.microsoft.com/beta/users/{userId}/teamwork/sendActivityNotification Content-Type: application/json { "topic": { "source": "text", "value": "Deployment Approvals Channel", "webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" }, "activityType": "deploymentApprovalRequired", "previewText": { "content": "New deployment requires your approval" }, "templateParameters": [ { "name": "deploymentId", "value": "6788662" } ] }
// Code snippets are only available for the latest version. Current version is 5.x // Dependencies using Microsoft.Graph.Beta.Users.Item.Teamwork.SendActivityNotification; using Microsoft.Graph.Beta.Models; var requestBody = new SendActivityNotificationPostRequestBody { Topic = new TeamworkActivityTopic { Source = TeamworkActivityTopicSource.Text, Value = "Deployment Approvals Channel", WebUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000", }, ActivityType = "deploymentApprovalRequired", PreviewText = new ItemBody { Content = "New deployment requires your approval", }, TemplateParameters = new List<KeyValuePair> { new KeyValuePair { Name = "deploymentId", Value = "6788662", }, }, }; // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp await graphClient.Users["{user-id}"].Teamwork.SendActivityNotification.PostAsync(requestBody);
mgc-beta users teamwork send-activity-notification post --user-id {user-id} --body '{\ "topic": {\ "source": "text",\ "value": "Deployment Approvals Channel",\ "webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"\ },\ "activityType": "deploymentApprovalRequired",\ "previewText": {\ "content": "New deployment requires your approval"\ },\ "templateParameters": [\ {\ "name": "deploymentId",\ "value": "6788662"\ }\ ]\ }\ '
// Code snippets are only available for the latest major version. Current major version is $v0.* // Dependencies import ( "context" msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go" graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users" graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models" //other-imports ) requestBody := graphusers.NewSendActivityNotificationPostRequestBody() topic := graphmodels.NewTeamworkActivityTopic() source := graphmodels.TEXT_TEAMWORKACTIVITYTOPICSOURCE topic.SetSource(&source) value := "Deployment Approvals Channel" topic.SetValue(&value) webUrl := "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" topic.SetWebUrl(&webUrl) requestBody.SetTopic(topic) activityType := "deploymentApprovalRequired" requestBody.SetActivityType(&activityType) previewText := graphmodels.NewItemBody() content := "New deployment requires your approval" previewText.SetContent(&content) requestBody.SetPreviewText(previewText) keyValuePair := graphmodels.NewKeyValuePair() name := "deploymentId" keyValuePair.SetName(&name) value := "6788662" keyValuePair.SetValue(&value) templateParameters := []graphmodels.KeyValuePairable { keyValuePair, } requestBody.SetTemplateParameters(templateParameters) // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go graphClient.Users().ByUserId("user-id").Teamwork().SendActivityNotification().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x GraphServiceClient graphClient = new GraphServiceClient(requestAdapter); com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody sendActivityNotificationPostRequestBody = new com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody(); TeamworkActivityTopic topic = new TeamworkActivityTopic(); topic.setSource(TeamworkActivityTopicSource.Text); topic.setValue("Deployment Approvals Channel"); topic.setWebUrl("https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"); sendActivityNotificationPostRequestBody.setTopic(topic); sendActivityNotificationPostRequestBody.setActivityType("deploymentApprovalRequired"); ItemBody previewText = new ItemBody(); previewText.setContent("New deployment requires your approval"); sendActivityNotificationPostRequestBody.setPreviewText(previewText); LinkedList<KeyValuePair> templateParameters = new LinkedList<KeyValuePair>(); KeyValuePair keyValuePair = new KeyValuePair(); keyValuePair.setName("deploymentId"); keyValuePair.setValue("6788662"); templateParameters.add(keyValuePair); sendActivityNotificationPostRequestBody.setTemplateParameters(templateParameters); graphClient.users().byUserId("{user-id}").teamwork().sendActivityNotification().post(sendActivityNotificationPostRequestBody);
const options = { authProvider, }; const client = Client.init(options); const sendActivityNotification = { topic: { source: 'text', value: 'Deployment Approvals Channel', webUrl: 'https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000' }, activityType: 'deploymentApprovalRequired', previewText: { content: 'New deployment requires your approval' }, templateParameters: [ { name: 'deploymentId', value: '6788662' } ] }; await client.api('/users/{userId}/teamwork/sendActivityNotification') .version('beta') .post(sendActivityNotification);
<?php use Microsoft\Graph\Beta\GraphServiceClient; use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\SendActivityNotification\SendActivityNotificationPostRequestBody; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopic; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopicSource; use Microsoft\Graph\Beta\Generated\Models\ItemBody; use Microsoft\Graph\Beta\Generated\Models\KeyValuePair; $graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes); $requestBody = new SendActivityNotificationPostRequestBody(); $topic = new TeamworkActivityTopic(); $topic->setSource(new TeamworkActivityTopicSource('text')); $topic->setValue('Deployment Approvals Channel'); $topic->setWebUrl('https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000'); $requestBody->setTopic($topic); $requestBody->setActivityType('deploymentApprovalRequired'); $previewText = new ItemBody(); $previewText->setContent('New deployment requires your approval'); $requestBody->setPreviewText($previewText); $templateParametersKeyValuePair1 = new KeyValuePair(); $templateParametersKeyValuePair1->setName('deploymentId'); $templateParametersKeyValuePair1->setValue('6788662'); $templateParametersArray []= $templateParametersKeyValuePair1; $requestBody->setTemplateParameters($templateParametersArray); $graphServiceClient->users()->byUserId('user-id')->teamwork()->sendActivityNotification()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams $params = @{ topic = @{ source = "text" value = "Deployment Approvals Channel" webUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" } activityType = "deploymentApprovalRequired" previewText = @{ content = "New deployment requires your approval" } templateParameters = @( @{ name = "deploymentId" value = "6788662" } ) } Send-MgBetaUserTeamworkActivityNotification -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x from msgraph_beta import GraphServiceClient from msgraph_beta.generated.users.item.teamwork.send_activity_notification.send_activity_notification_post_request_body import SendActivityNotificationPostRequestBody from msgraph_beta.generated.models.teamwork_activity_topic import TeamworkActivityTopic from msgraph_beta.generated.models.teamwork_activity_topic_source import TeamworkActivityTopicSource from msgraph_beta.generated.models.item_body import ItemBody from msgraph_beta.generated.models.key_value_pair import KeyValuePair # To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python request_body = SendActivityNotificationPostRequestBody( topic = TeamworkActivityTopic( source = TeamworkActivityTopicSource.Text, value = "Deployment Approvals Channel", web_url = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000", ), activity_type = "deploymentApprovalRequired", preview_text = ItemBody( content = "New deployment requires your approval", ), template_parameters = [ KeyValuePair( name = "deploymentId", value = "6788662", ), ], ) await graph_client.users.by_user_id('user-id').teamwork.send_activity_notification.post(request_body)
Response
HTTP/1.1 204 No Content
Example 3: Notify a user about an event using a custom icon
If you want to notify a user with a customized icon instead of the default app icon, you can set the optional iconId property in the request body.
Note: The activityType
in the manifest must contain the list of allowed icon IDs in order to use this parameter. The request validation fails if the app manifest is missing the customized list of icons. For more information, see Public developer preview app manifest.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/users/2f39ffba-51ca-4d2d-a66f-a020a83ce208/teamwork/sendActivityNotification Content-Type: application/json { "topic": { "source": "text", "value": "Deployment Approvals Channel", "webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" }, "activityType": "announcementPosted", "previewText": { "content": "new announcemnet posted" }, "iconId": "announcementCreated", "templateParameters": [ { "name": "deploymentId", "value": "6788662" } ] }
// Code snippets are only available for the latest version. Current version is 5.x // Dependencies using Microsoft.Graph.Beta.Users.Item.Teamwork.SendActivityNotification; using Microsoft.Graph.Beta.Models; var requestBody = new SendActivityNotificationPostRequestBody { Topic = new TeamworkActivityTopic { Source = TeamworkActivityTopicSource.Text, Value = "Deployment Approvals Channel", WebUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000", }, ActivityType = "announcementPosted", PreviewText = new ItemBody { Content = "new announcemnet posted", }, TemplateParameters = new List<KeyValuePair> { new KeyValuePair { Name = "deploymentId", Value = "6788662", }, }, AdditionalData = new Dictionary<string, object> { { "iconId" , "announcementCreated" }, }, }; // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp await graphClient.Users["{user-id}"].Teamwork.SendActivityNotification.PostAsync(requestBody);
mgc-beta users teamwork send-activity-notification post --user-id {user-id} --body '{\ "topic": {\ "source": "text",\ "value": "Deployment Approvals Channel",\ "webUrl": "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"\ },\ "activityType": "announcementPosted",\ "previewText": {\ "content": "new announcemnet posted"\ },\ "iconId": "announcementCreated",\ "templateParameters": [\ {\ "name": "deploymentId",\ "value": "6788662"\ }\ ]\ }\ '
// Code snippets are only available for the latest major version. Current major version is $v0.* // Dependencies import ( "context" msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go" graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users" graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models" //other-imports ) requestBody := graphusers.NewSendActivityNotificationPostRequestBody() topic := graphmodels.NewTeamworkActivityTopic() source := graphmodels.TEXT_TEAMWORKACTIVITYTOPICSOURCE topic.SetSource(&source) value := "Deployment Approvals Channel" topic.SetValue(&value) webUrl := "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" topic.SetWebUrl(&webUrl) requestBody.SetTopic(topic) activityType := "announcementPosted" requestBody.SetActivityType(&activityType) previewText := graphmodels.NewItemBody() content := "new announcemnet posted" previewText.SetContent(&content) requestBody.SetPreviewText(previewText) keyValuePair := graphmodels.NewKeyValuePair() name := "deploymentId" keyValuePair.SetName(&name) value := "6788662" keyValuePair.SetValue(&value) templateParameters := []graphmodels.KeyValuePairable { keyValuePair, } requestBody.SetTemplateParameters(templateParameters) additionalData := map[string]interface{}{ "iconId" : "announcementCreated", } requestBody.SetAdditionalData(additionalData) // To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go graphClient.Users().ByUserId("user-id").Teamwork().SendActivityNotification().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x GraphServiceClient graphClient = new GraphServiceClient(requestAdapter); com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody sendActivityNotificationPostRequestBody = new com.microsoft.graph.beta.users.item.teamwork.sendactivitynotification.SendActivityNotificationPostRequestBody(); TeamworkActivityTopic topic = new TeamworkActivityTopic(); topic.setSource(TeamworkActivityTopicSource.Text); topic.setValue("Deployment Approvals Channel"); topic.setWebUrl("https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000"); sendActivityNotificationPostRequestBody.setTopic(topic); sendActivityNotificationPostRequestBody.setActivityType("announcementPosted"); ItemBody previewText = new ItemBody(); previewText.setContent("new announcemnet posted"); sendActivityNotificationPostRequestBody.setPreviewText(previewText); LinkedList<KeyValuePair> templateParameters = new LinkedList<KeyValuePair>(); KeyValuePair keyValuePair = new KeyValuePair(); keyValuePair.setName("deploymentId"); keyValuePair.setValue("6788662"); templateParameters.add(keyValuePair); sendActivityNotificationPostRequestBody.setTemplateParameters(templateParameters); HashMap<String, Object> additionalData = new HashMap<String, Object>(); additionalData.put("iconId", "announcementCreated"); sendActivityNotificationPostRequestBody.setAdditionalData(additionalData); graphClient.users().byUserId("{user-id}").teamwork().sendActivityNotification().post(sendActivityNotificationPostRequestBody);
const options = { authProvider, }; const client = Client.init(options); const sendActivityNotification = { topic: { source: 'text', value: 'Deployment Approvals Channel', webUrl: 'https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000' }, activityType: 'announcementPosted', previewText: { content: 'new announcemnet posted' }, iconId: 'announcementCreated', templateParameters: [ { name: 'deploymentId', value: '6788662' } ] }; await client.api('/users/2f39ffba-51ca-4d2d-a66f-a020a83ce208/teamwork/sendActivityNotification') .version('beta') .post(sendActivityNotification);
<?php use Microsoft\Graph\Beta\GraphServiceClient; use Microsoft\Graph\Beta\Generated\Users\Item\Teamwork\SendActivityNotification\SendActivityNotificationPostRequestBody; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopic; use Microsoft\Graph\Beta\Generated\Models\TeamworkActivityTopicSource; use Microsoft\Graph\Beta\Generated\Models\ItemBody; use Microsoft\Graph\Beta\Generated\Models\KeyValuePair; $graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes); $requestBody = new SendActivityNotificationPostRequestBody(); $topic = new TeamworkActivityTopic(); $topic->setSource(new TeamworkActivityTopicSource('text')); $topic->setValue('Deployment Approvals Channel'); $topic->setWebUrl('https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000'); $requestBody->setTopic($topic); $requestBody->setActivityType('announcementPosted'); $previewText = new ItemBody(); $previewText->setContent('new announcemnet posted'); $requestBody->setPreviewText($previewText); $templateParametersKeyValuePair1 = new KeyValuePair(); $templateParametersKeyValuePair1->setName('deploymentId'); $templateParametersKeyValuePair1->setValue('6788662'); $templateParametersArray []= $templateParametersKeyValuePair1; $requestBody->setTemplateParameters($templateParametersArray); $additionalData = [ 'iconId' => 'announcementCreated', ]; $requestBody->setAdditionalData($additionalData); $graphServiceClient->users()->byUserId('user-id')->teamwork()->sendActivityNotification()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Teams $params = @{ topic = @{ source = "text" value = "Deployment Approvals Channel" webUrl = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000" } activityType = "announcementPosted" previewText = @{ content = "new announcemnet posted" } iconId = "announcementCreated" templateParameters = @( @{ name = "deploymentId" value = "6788662" } ) } Send-MgBetaUserTeamworkActivityNotification -UserId $userId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x from msgraph_beta import GraphServiceClient from msgraph_beta.generated.users.item.teamwork.send_activity_notification.send_activity_notification_post_request_body import SendActivityNotificationPostRequestBody from msgraph_beta.generated.models.teamwork_activity_topic import TeamworkActivityTopic from msgraph_beta.generated.models.teamwork_activity_topic_source import TeamworkActivityTopicSource from msgraph_beta.generated.models.item_body import ItemBody from msgraph_beta.generated.models.key_value_pair import KeyValuePair # To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python request_body = SendActivityNotificationPostRequestBody( topic = TeamworkActivityTopic( source = TeamworkActivityTopicSource.Text, value = "Deployment Approvals Channel", web_url = "https://teams.microsoft.com/l/message/19:448cfd2ac2a7490a9084a9ed14cttr78c@thread.skype/1605223780000?tenantId=c8b1bf45-3834-4ecf-971a-b4c755ee677d&groupId=d4c2a937-f097-435a-bc91-5c1683ca7245&parentMessageId=1605223771864&teamName=Approvals&channelName=Azure%20DevOps&createdTime=1605223780000", ), activity_type = "announcementPosted", preview_text = ItemBody( content = "new announcemnet posted", ), template_parameters = [ KeyValuePair( name = "deploymentId", value = "6788662", ), ], additional_data = { "icon_id" : "announcementCreated", } ) await graph_client.users.by_user_id('user-id').teamwork.send_activity_notification.post(request_body)
Response
The following example shows the response.
HTTP/1.1 204 No Content
Related content