MS Teams – Chats – Create Chat Notification
MS Teams – Chats – Create Chat Notification
Send an activity notification in the scope of a Chat.
Action details
| Property | Value |
|---|---|
| Action label | MS Teams – Chats – Create Chat Notification |
| Category | CloudTools |
| Apex class and method | CreateMSTeamsChatNotify.createChatNotification |
| Input type | CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyInput |
| Output type | List<CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyOutput> |
| Authorization | Microsoft 365 connector; check endpoint support for delegated and application access. |
| Microsoft Graph request | POST /chats/{chatId}/sendActivityNotification |
Prerequisites and permissions
Configure a CloudTools Connector with Connector Type set to Microsoft 365. Complete Microsoft sign-in for OAuth Delegated (Authorization Code). For endpoints supporting OAuth Application (Client Credentials), grant application permissions and administrator consent. The identity must have access to the selected resource. See Creating an Entra ID App and Integration Connectors for setup.
The action permission provider declares these alternatives. They are not cumulative requirements, and not all are least privileged. Confirm endpoint restrictions and any resource-specific consent requirements in the Microsoft reference.
| Permission type | Declared alternatives |
|---|---|
| Delegated | TeamsActivity.Send |
| Application | TeamsActivity.Send.Chat, TeamsActivity.Send |
Endpoints: /chats/{chatId}/sendActivityNotification. Resource-specific consent and installation requirements apply to resource-specific permissions.
See the Microsoft operation and permissions reference.
Inputs
| Input | Apex field | Type | Required | Description |
|---|---|---|---|---|
| Chat Id | chatId | String | Yes | MS Teams chat identifier |
| Activity Type | activityType | String | Yes | Activity type declared in Teams app manifest (or systemDefault) |
| Preview Text | previewText | String | Yes | Preview text shown in the notification |
| Recipient Type | recipientType | String | Yes | Recipient type: AadUser or ChatMembers |
| Recipient User Id | recipientUserId | String | No | Required when Recipient Type is AadUser |
| Recipient Chat Id | recipientChatId | String | No | Optional override chat id for ChatMembers; defaults to Chat Id |
| Topic Source | topicSource | String | No | Topic source (default: entityUrl) |
| Topic Value | topicValue | String | No | Topic value URL (default: https://graph.microsoft.com/v1.0/chats/{ChatId}) |
| Topic Web URL | topicWebUrl | String | No | Optional Teams deep link for topic |
| Template Parameter Names | templateParameterNamesCsv | String | No | Optional comma-separated template parameter names |
| Template Parameter Values | templateParameterValuesCsv | String | No | Optional comma-separated template parameter values aligned with names |
| Chain Id | chainId | String | No | Optional chain id for overriding previous notification |
| Icon Id | iconId | String | No | Optional icon id defined in Teams app manifest |
| Teams App Id | teamsAppId | String | No | Optional Teams app id to disambiguate installed apps |
Supply a nonempty list with a non-null first request. This implementation processes only the first request and does not bulk-process Flow interviews. Global inputs do not expose connectorId; Flow and subscriber Apex use CloudTools connector selection. Use Microsoft Graph IDs, not Salesforce IDs or browser links. Resolve dynamic values before invoking this action.
Outputs
Returns one operation result after the request completes. Inspect its documented fields. Failures throw an exception rather than returning a success=false result.
| Output | Apex field | Type | Description |
|---|---|---|---|
| Success | success | Boolean | Whether the notification request succeeded |
| Message | message | String | Result message |
Behavior and limits
This sends an activity feed notification, not a chat or channel message. Configure a Teams app and its activity types/templates for the target context. Topic and recipient fields must match the selected type. Template parameter names and values must have matching item counts; Chain Id must be a whole number when supplied.
Recipient Type selects AadUser or ChatMembers. AadUser requires Recipient User Id; a members recipient uses the supplied recipient resource or the target resource when omitted.
Use in Flow
Add MS Teams – Chats – Create Chat Notification where supported. Use a Microsoft 365 application connector configured as Set as default for Flow automations only if the endpoint supports the required application operation. Delegated connections are not supported for CloudTools Flow automation. Supply required values, retain outputs, and add fault handling.
Use in custom Apex
This subscriber-org example uses the Apptigent namespace. Replace example identifiers and values before use. Configure the connector, arrange authorization first, run in a context permitting callouts, and handle exceptions and empty results.
Apptigent.CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyInput request =
new Apptigent.CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyInput();
request.chatId = '19:cbee7eea878f4630a0ef1e99b235e6b5@thread.v2';
request.activityType = 'taskCreated';
request.previewText = 'A new task was created';
request.recipientType = 'AadUser';
request.recipientUserId = '569363e2-4e49-4661-87f2-16f245c5d66a';
request.recipientChatId = '';
request.topicSource = 'entityUrl';
request.topicValue = 'https://graph.microsoft.com/v1.0/chats/19:cbee7eea878f4630a0ef1e99b235e6b5@thread.v2';
request.topicWebUrl = '';
request.templateParameterNamesCsv = 'taskId';
request.templateParameterValuesCsv = '42';
request.chainId = '';
request.iconId = '';
request.teamsAppId = '';
List<Apptigent.CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyOutput> results =
Apptigent.CreateMSTeamsChatNotify.createChatNotification(
new List<Apptigent.CreateMSTeamsChatNotify.CreateMSTeamsChatNotifyInput>{ request }
);
System.debug(results);
Use in a Lightning Web Component
Use createMSTeamsChatNotify from msTeamsConnectorLib through MSTeamsConnectorController. Set request.connectorId to select a configured connector. These c/ imports apply in the same namespace. The controller uses a shared request DTO; its field names differ from the global invocable input.
| Global input | LWC request mapping |
|---|---|
chatId | request.chatId |
activityType | request.activityType |
previewText | request.previewText |
topicSource | request.topicSource |
The shared controller DTO does not expose these global inputs: recipientType, recipientUserId, recipientChatId, topicValue, topicWebUrl, templateParameterNamesCsv, templateParameterValuesCsv, chainId, iconId, teamsAppId. Adding them as arbitrary properties to request does not make them reach the action. Use global Apex/Flow for those inputs where authorization permits.
The current LWC route omits required global inputs (recipientType). It cannot invoke this action successfully as implemented; use the global Apex example until the controller mapping supports them.
The library resolves to one mapped object or null. rawJson serializes the mapped Apex model rather than the untouched Microsoft response. Message body, membership roles, and nested properties can be flattened or serialized in JavaScript DTOs.
Use getMSTeamsAuthorizationState, beginMSTeamsAuthorization, and createMSTeamsOAuthMessageHandler to arrange delegated sign-in. The library normalizes errors but does not automatically sign in or retry. Reset completed for a new deliberate operation. Inspect resource state before retrying a mutation with an uncertain outcome.
Error handling and troubleshooting
| Symptom | What to check |
|---|---|
| Required fields error | Supply a nonempty request list, a non-null first request, and required or conditionally required values. For LWC, check controller mappings. |
| Authorization or access denied | Check selected connector, delegated versus application support, consent, Teams app installation where required, and access to the resource. |
| Resource not found | Check team, channel, chat, message, membership, and app installation IDs; these are distinct identifiers. |
| Missing data | Check pagination, query support, empty-response behavior, and documented model mapping. |
| Operation rejected | Inspect the Microsoft error, endpoint restrictions, supported properties, message authorization limits, and notification configuration. |