• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
ControlUp Community

ControlUp Community

Connect, Learn, and Grow

  • Blog
  • Podcast
  • Meetups
  • Archives
  • Categories
    • ControlUp One Platform
    • ControlUp for Apps
    • ControlUp for Compliance
    • ControlUp for Desktops
    • ControlUp Scripts & Triggers
    • ControlUp Synthetic Monitoring
    • ControlUp for VDI
  • Topics
  • Events
    • Logos & Wallpaper
    • ControlUp.com
  • Join

Sending MSFT Teams Messages with ControlUp Realtime DX’s Rest Action

Posted on November 3, 2023

A user asked for examples of using Realtime DX’s Rest action to send messages to MSFT Teams via the Graph API. It was suggested to follow ControlUp guidelines (https://support.controlup.com/docs/using-webhooks-as-follow-up-action) and use webhooks and Adaptive Cards for Teams. Sample powershell code was provided along with the permissions typically needed (Chat.ReadWrite or ChannelMessage.Send).


Read the entire ‘Sending MSFT Teams Messages with Realtime DX’s Rest Action’ thread below:

Good day all, does anyone have any examples of using Realtime DX’s Rest action to send messages to MSFT Teams leveraging the MSFT Graph API? Having trouble getting the JSON payload formatted correctly. Thanks in advance.


Followed these guidelines? https://support.controlup.com/docs/using-webhooks-as-follow-up-action

Obviously in conjunction with MS specific payload instructions


@member You’ve sent messages via MS Teams, right? Was that via Teams webhooks or via the graph API?


wasn’t needed yet for any graph integrations. Microsoft Teams Webhook created by right clicking the channel -> Integrations and then used PowerShell to leverage adaptive cards – the pretty O365 cards for teams.

Sample code @member:

param (

[string]$webhookUrl = "INSERT-WEBHOOK-URL-HERE"

)

$body = @{

"@type" = "MessageCard"

"@context" = ""

"summary" = "VMware Connection Brokers Health Alert"

"themeColor" = "D8000C"

"title" = "ALERT: VMware Connection Brokers are not healthy"

"sections" = @(

`@{`

`"activityTitle" = "Details"`

`"facts" = @(`

`@{`

`"name" = "Broker 1"`

`"value" = "Not Responding"`

`},`

`@{`

`"name" = "Broker 2"`

`"value" = "Not Responding"`

`},`

`@{`

`"name" = "Broker 3"`

`"value" = "Not Responding"`

`}`

`)`

`"text" = "Immediate attention required. Please check the VMware Connection Brokers as soon as possible."`

`}`

)

} | ConvertTo-Json -Compress -Depth 20

$body = $body -replace ‘\\r\\n’,”


Web hooks are a security issue, so are frowned upon. We’re looking at using Powershell to get to Teams via Graph API


I’d certainly point out the fact a particular webhook would only have access to the explicit channel it was given access to. It also can only post, not read. Either way, I’ll check last I looked the Graph API lacked a lot of the teams functions.

Looks like it most certainly can be done, just haven’t had an opportunity to test it. Here’s an example in PowerShell that interfaces with the Graph API to send a message to a Teams Channel:

# Install the required module

Install-Module -Name Microsoft.Graph.Authentication -Scope CurrentUser

# Import the module

Import-Module Microsoft.Graph.Authentication

# Connect to Microsoft Graph

$clientId = "YOUR-APP-CLIENT-ID"

$tenantId = "YOUR-TENANT-ID"

$clientSecret = "YOUR-APP-SECRET"

$scopes = ""

$tokenRequest = @{

`TenantId = $tenantId`

`ClientId = $clientId`

`ClientSecret = $clientSecret`

`Scope = $scopes`

}

Connect-MgGraph -ClientSecret $tokenRequest

# Set the required parameters

$teamId = "YOUR-TEAM-ID"

$channelId = "YOUR-CHANNEL-ID"

$messageContent = "Hello from PowerShell!"

# Create the message to post

$messageBody = @{

`body = @{`

`content = $messageContent`

`contentType = "text"`

`}`

} | ConvertTo-Json

# Send the message to the channel

$uri = ""

$response = Invoke-MgGraphRequest -Method POST -Uri $uri -Body $messageBody -ContentType "application/json"

# Output the response

$response | ConvertTo-Json | Write-Output

Just FYI @member the permissions you’ll typically need are Chat.ReadWrite for posting messages in a chat or ChannelMessage.Send for sending messages in a channel.

Continue reading and comment on the thread ‘Sending MSFT Teams Messages with ControlUp Realtime DX’s Rest Action’.  Not a member? Join Here!


Categories: All Archives, ControlUp for VDI, ControlUp Scripts & Triggers
Topics: Authentication, Automation & Alerting, Microsoft, Microsoft Teams, PowerShell, Scripts, Security, Unified Communications, Virtual Desktops, VMware

Ask Us Anything, Connect, Learn, and Grow with the ControlUp Community!

Login to the ControlUp Community to ask us anything, stay up-to-date on what’s new and coming soon and meet other like-minded techies like you.

Not already a member? Join Today!

Primary Sidebar

ControlUp Academy

Enroll in ControlUp Academy for expert-led technical training, equipping you with skills to effectively deploy, manage, and grow your ControlUp investment.

Learn here >

Rotating Images

Hidden Gem from our Community on Slack!

ControlUp Betas - What's Coming Next?
NEW ControlUp Features - Stay Up-to-Date!
ControlUp Scripts - Scripting, Zero to Hero
Latest KB Articles - Be the First to Learn
Did you Know - with Sivan Kroitoru
Practical Perspectives Technical Use Case Training

Video Tutorials Library

Visit our technical how-to videos, offering step-by-step tutorials on advanced features, troubleshooting, and best practices.

Watch here >

ControlUp Blog

Check out the ControlUp blog for expert advice and in-depth analysis.

Read here >

ControlUp Script Library

Visit the ControlUp technical script library, which offers a multitude of pre-built scripts and custom actions for your monitoring and troubleshooting requirements.

See here >

ControlUp Support

Visit the ControlUp support home and to delve deeper into ControlUp solutions.

Browse here >

Download ControlUp RealTime DX

Start with ControlUp for real-time end-user environment insights, swift troubleshooting, and unprecedented performance optimization. Download now.

Download here >

Footer

      

ControlUp Community
Of Techie, By Techie, For Techie!

Terms of Use | Privacy Policy | Security
Dive Deeper, Learn more at ControlUp.com

  • facebook
  • twitter
  • youtube
  • linkedin

© 2023–2025 ControlUp Technologies LTD, All Rights Reserved.

We use cookies to ensure that we give you the best experience on our website. by continuing to use this site you agree to our Cookie policy..