MS Teams – Channels – Update Channel Message
MS Teams – Channels – Update Channel Message
Update policy violation metadata on a channel message.
Action details
| Property | Value |
|---|---|
| Action label | MS Teams – Channels – Update Channel Message |
| Category | CloudTools |
| Apex class and method | UpdateMSTeamsChannelMessage.updateChannelMessage |
| Input type | UpdateMSTeamsChannelMessage.UpdateMSTeamsChannelMessageInput |
| Output type | List<MSGraphUpdateResponse> |
| Authorization | Microsoft 365 connector; check endpoint support for delegated and application access. |
| Microsoft Graph request | PATCH /teams/{teamId}/channels/{channelId}/messages/{messageId} |
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. Resource-specific permissions require consent for the relevant Teams resource.
| Permission type | Declared alternatives |
|---|---|
| Delegated | ChannelMessage.ReadWrite, Group.ReadWrite.All |
| Application | ChannelMessage.UpdatePolicyViolation.All, Group.ReadWrite.All |
Endpoints: /teams/{team-id}/channels/{channel-id}/messages/{message-id}. Application permissions only allow policyViolation updates and require a Microsoft Communications DLP service plan; editing message content requires delegated access. Group.ReadWrite.All is listed for backward compatibility.
See the Microsoft operation and permissions reference.
Inputs
| Input | Apex field | Type | Required | Description |
|---|---|---|---|---|
| Team Id | teamId | String | Yes | MS Teams team identifier |
| Channel Id | channelId | String | Yes | MS Teams channel identifier |
| Message Id | messageId | String | Yes | MS Teams channel message identifier |
| Content | content | String | No | Updated message body content |
| Content Type | contentType | String | No | Body content type: text or html |
| DLP Action | dlpAction | String | No | DLP action (for example: BlockAccess, NotifySender) |
| Justification Text | justificationText | String | No | Optional policy-override justification text |
| User Action | userAction | String | No | Optional user action (for example: Override, None) |
| Verdict Details | verdictDetails | String | No | Optional policy verdict details string |
| Policy Violation OData Type | policyViolationODataType | String | No | Optional @odata.type for policyViolation |
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 update succeeded |
| Message | message | String | Result message |
Behavior and limits
Despite the action description, this implementation can send a body update when Content is nonblank, and policyViolation when its fields are supplied. At least one update field is required. Message content editing requires delegated access; application policyViolation updates have Microsoft DLP service-plan requirements. Do not combine these fields without confirming authorization support.
Use in Flow
Add MS Teams – Channels – Update Channel Message 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.UpdateMSTeamsChannelMessage.UpdateMSTeamsChannelMessageInput request =
new Apptigent.UpdateMSTeamsChannelMessage.UpdateMSTeamsChannelMessageInput();
request.teamId = '893075dd-2487-4122-925f-022c42e20265';
request.channelId = '19:private-channel@thread.tacv2';
request.messageId = '1707402650048';
request.content = '<div>Updated channel message</div>';
request.contentType = 'html';
List<Apptigent.MSGraphUpdateResponse> results =
Apptigent.UpdateMSTeamsChannelMessage.updateChannelMessage(
new List<Apptigent.UpdateMSTeamsChannelMessage.UpdateMSTeamsChannelMessageInput>{ request }
);
System.debug(results);
Use in a Lightning Web Component
Use updateMSTeamsChannelMessage 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 |
|---|---|
teamId | request.teamId |
channelId | request.channelId |
messageId | request.messageId |
content | request.bodyContent |
contentType | request.bodyContentType |
The shared controller DTO does not expose these global inputs: dlpAction, justificationText, userAction, verdictDetails, policyViolationODataType. Adding them as arbitrary properties to request does not make them reach the action. Use global Apex/Flow for those inputs where authorization permits.
teamsActionExample.js
import { LightningElement } from 'lwc';
import { updateMSTeamsChannelMessage } from 'c/msTeamsConnectorLib';
export default class TeamsActionExample extends LightningElement {
result = null;
errorMessage = '';
isRunning = false;
completed = false;
async handleRun() {
if (this.isRunning || this.completed) return;
this.isRunning = true;
this.errorMessage = '';
try {
const request = { connectorId: 'REPLACE_WITH_CONNECTOR_RECORD_ID' };
request.teamId = '893075dd-2487-4122-925f-022c42e20265';
request.channelId = '19:private-channel@thread.tacv2';
request.messageId = '1707402650048';
request.bodyContent = '<div>Updated channel message</div>';
request.bodyContentType = 'html';
this.result = await updateMSTeamsChannelMessage(request);
this.completed = true;
} catch (error) {
this.errorMessage = error.requiresInteractiveAuthorization
? 'Sign in to Microsoft for the connector, then try again.'
: error.message || 'The Teams action failed.';
} finally {
this.isRunning = false;
}
}
}
teamsActionExample.html
<template>
<lightning-button label="Run action" onclick={handleRun}
disabled={isRunning}></lightning-button>
<p role="alert">{errorMessage}</p>
</template>
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. |