Jump to content

Recommended Posts

Posted

Hi guys, wondering if anyone know how to tie into Teams. I just need to send a message but have never done anything like that before and autoit is the only programming language I know. Has anyone ever automated sending a message in teams before with the API? I really don't want to use webdriver as it's a relatively messy solution but will go that route if I have to.

Posted

@Danp2 I 'reviewed' that thread but unless I'm missing something, it's just a link to the Microsoft API. I know an API exists, I just have zero clue about how to implement something like that and was hoping someone had done something similar.

Posted

Probably the easier way is to use  PowerShell Module because to write it from raw AutoIt you will probably need HTTP request knowledge. 

 

Saludos

Posted

@Danyfirex You're 100% right. SUPER easy! Thanks.


Instructions for anyone who searches for this in the future: 

1) Activate Webhook by clicking on 'Connectors' in any chat channel.. Add Extension called "Webhooks", copy webhook value.

2) Paste into powershell either direct/via autoit after replacing the "URI" value with your webhook value, hit enter and success:

3) Visit link below for full details / better explanation

https://petri.com/how-to-send-a-microsoft-teams-message-using-powershell-7

 

$JSONBody = [PSCustomObject][Ordered]@{
    "@type"      = "MessageCard"
    "@context"   = "http://schema.org/extensions"
    "summary"    = "Incoming Alert Test Message!"
    "themeColor" = '0078D7'
    "title"      = "Incoming Alert Test Message!"
    "text"       = "There was an alert and we should act on it."
}

$TeamMessageBody = ConvertTo-Json $JSONBody -Depth 100

$parameters = @{
    "URI"         = 'https://outlook.office.com/webhook/{GUID}@{GUID}/IncomingWebhook/{GUID}/{GUID}'
    "Method"      = 'POST'
    "Body"        = $TeamMessageBody
    "ContentType" = 'application/json'
}

 

 

Invoke-RestMethod @paramete
rs | Out-Null

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...