Send Notifications to Team Channel

As a Software or DevOps Engineer, you often want to share automated notifications of critical updates, release status, or any other info on a Microsoft Teams channel.

For example, I have previously automated the release information so stakeholders like Product Owners, Operations, and Management were able to follow on a Microsoft Teams channel a web release status notification on or post-critical system issues.

In this short article, I will show you how to achieve this in a simple way. Just follow 4 steps to send message notifications to your channels:

1- In your teams, right-click on your channel. And search for Incoming Webhook.

Right click channel

2- Installing/Adding Incoming Webhook if not added yet. 

enter image description here

3- Configure Incoming Webhook, by providing a webhook name. Click on Create

Configure Incoming webhook

It will generate you a link with unique GUIDs, copy the link

enter image description here

4- The last step, use this command line in the PowerShell
curl.exe -H "Content-Type:application/json" -d "{'text':'Servers x is started.'}"

The URL in the command line contains some faked guid numbers, but you need to replace it with the one you get from webhooks.

You can either call this line in power shell or incorporated it in C# as this simple example or other programming languages:

using (var httpClient = new HttpClient())
    using (var request = new HttpRequestMessage(new HttpMethod("POST"), ""))
        request.Content = new StringContent("{'text':'Servers x is started.'}");
        request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); 

        var response = await httpClient.SendAsync(request);

Now when I run the command or C# code I get a message in that channel:

Message Demo

In case you need to remove the hook that you have added, click on Configured then Configure. And Manage the webhook: 

Manage Web Hook

 And remove 

Remove Web Hook


As you can see, with a few steps you will be able to create a Microsoft Teams automated channel notification.

The use of this notification is not limited to my mentioned example, it can be used for a lot, like automated reminders, certificate expiration notifications, etc.

You can of course dig deeper in Microsoft Teams API and use Graph API to do a lot more, including sending notifications for other members, check Microsoft Teams API overview – Microsoft Graph | Microsoft Docs.

I have also another example of mentioning in a channel on StackOverflow java – Mention channel using ms graph api – Stack Overflow. that can be applied for c# as well. This article is also used to answer a question on StackOverflow as well java – Mention channel using ms graph api – Stack Overflow

Give it a try and let me know what you think about it.

Leave a Comment