![]() |
|
Post Reply ![]() |
Author | |
arif.abdullah ![]() Professional ![]() Joined: 10 Nov 2016 Location: UK Points: 2 |
![]() ![]() ![]() ![]() ![]() Posted: 16 Nov 2016 at 5:40am |
How to Set Up an Incoming Webhook into Microsoft Teams Using Think Automation
Example JSON for Think Automation: { "sections" : [ { "facts" : [ { "name" : "<b><i>From:</i></b>", "value" : "%msg_from%" }, { "name" : "<b><i>Sent At:</i></b>", "value" : "%DateTime%" }, { "name" : "<b><i>From:</i></b>", "value" : "%msg_fromname%" } ] }, "activitySubtitle" : "%Datetime%", "activityText" : "%msg_from%", "activityTitle" : "%msg_subject%" }, { "title" : "<i>%msg_body%</i>" }, { "images" : [ { "image" : "https://pslcrm-my.sharepoint.com/personal/arif_abdullah_parkersoftware_com/_layouts/15/guestaccess.aspx?guestaccesstoken=aGAaBeGzkhXqw%2b3A0DxwV15Tc2jjBXAjF43opuG5z3E%3d&docid=1ad7771761446409cb252277f275250d0&rev=1" }, ], "title" : "Images" } ], "summary" : "<b>%msg_subject%</b>", } Call the Webhook from PowerShell Let’s start with a simple test to verify functionality. Replace the value for the URI string in the following script and test it by running it in PowerShell ISE. You should see a “1” returned in the PowerShell window and new post in the Teams channel. If an error occurs, it will appear as an error in PowerShell communicating a malformed web service call. $body = ConvertTo-JSON @{ text = 'Hello Channel' } Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json' Advanced Hook using Powershell # these values would be retrieved from or set by an application $status = 'success' $fact1 = 'All tests passed' $fact2 = '1 test failed' $body = ConvertTo-Json -Depth 4 @{ Image = ‘<img src="http://www.barcampmanchester.co.uk/wp-content/uploads/2015/09/Parker-Software-Logo-web-transparent.png " alt="Parker Software" title =”Testing This Title” style="width:100%;height:100%;">’ title = '<h1>New Build Notification<h1><br>' text = "A build completed with status $status" activityImage = ‘http://www.barcampmanchester.co.uk/wp-content/uploads/2015/09/Parker-Software-Logo-web-transparent.png' sections = @( @{ activityTitle = 'Build' activitySubtitle = 'automated test platform' activityText = 'A change was evaluated and new results are available.' activityImage = ‘http://www.barcampmanchester.co.uk/wp-content/uploads/2015/09/Parker-Software-Logo-web-transparent.png' }, @{ title = 'Details' facts = @( @{ name = 'Unit Tests' value = $fact1 }, @{ name = 'Integration Tests' value = $fact2 } ) } ) } Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json' Edited by Daniel Horton - 17 Nov 2016 at 4:59am |
|
Thanks,
Arif Abdullah Technical Team Leader Parker Software www.parkersoftware.com |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |