A Channel is a part or a subset of a Team in Microsoft Teams. Any conversations, storing or sharing files and tabs are all managed through channels. We can categorize the channels for the team based on a specific topic, department or project.
Each channel has moderation settings, where we can handle what kind of conversations should be in the chat window. In this post, I would like to show how to block the bot to post messages in Channel's chat window for the specific team in Microsoft Teams.
Teams UI
- Open Microsoft Team
- If you are the owner of the Channel, click the More Options (...) button for the particular Channel under the specific Team
- Select the Manage Channel menu
- Then click the Channel Settings tab
- Under the permissions section, uncheck the option Allow bots to submit channel messages
Microsoft Graph API
We can also use the Microsoft Graph API to do the same action. Use the below options in Microsoft Graph Explorer to change the moderation settings to avoid bots posting messages in the channel.
Microsoft Graph API EndPoint
PATCH https://graph.microsoft.com/beta/teams/<team id>/channels/<channel id>
Consent Permission
Delegated Permission: ChannelSettings.ReadWrite.All
Application Permission: ChannelSettings.ReadWrite.Group or ChannelSettings.ReadWrite.All
The below request headers should be sent along with the request to get the details,
Request Header
Content-Type: application/json
Request Body
{
"moderationSettings": {
"allowNewMessageFromBots": false
}
}
In Microsoft Graph Explorer, click Run Query to send the request and update the settings for the specified channel in the Microsoft Team.
Output
Now the channel does not allow the bot or any automated messages to be posted on the channel's conversation window. After running the request, the output returns an empty object.
{}