Print Page | Close Window

Setting Up Incoming Webhook into Microsoft Teams

Printed From: Parker Software Ltd
Category: ThinkAutomation Business Process Automation
Forum Name: Samples
Forum Description: Samples - images and accounts for import
URL: http://www.parkersoftware.com/forum/forum_posts.asp?TID=9280
Printed Date: 15 Oct 2019 at 6:44pm
Software Version: Web Wiz Forums 11.05 - http://www.webwizforums.com


Topic: Setting Up Incoming Webhook into Microsoft Teams
Posted By: arif.abdullah
Subject: Setting Up Incoming Webhook into Microsoft Teams
Date Posted: 16 Nov 2016 at 5:40am
How to Set Up an Incoming Webhook into Microsoft Teams Using Think Automation
  1. Create a Channel within a Team on Teams
  2. Within your Channel, add a connector called “Incoming Webhook”
  3. Enter a name for your Incoming Webhook(this will be the name shown when a message comes from the hook into teams). E.g. Parker Software
  4. Upload your image
  5. Copy the hook URL and store it safely (to use within TA)
  6. Open TA and Create an Account
  7. Set Account to Pull Data from Exchange mailbox
  8. Create a trigger with conditions and the extracted fields of your choice
  9. In the trigger actions, use the post to web page trigger to post JSON Data to Teams. 

  10. Post to web settings. If necessary, use http://jsonformat.com/#jsondataurllabel" rel="nofollow - http://jsonformat.com/#jsondataurllabel to evaluate and check your JSon.
  11.  The available Microsoft Teams JSON variables can be found on https://dev.outlook.com/Connectors/Reference" rel="nofollow - https://dev.outlook.com/Connectors/Reference

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%"
            }
          ] },
      { "activityImage" : " https://pslcrm-my.sharepoint.com/personal/arif_abdullah_parkersoftware_com/_layouts/15/guestaccess.aspx?guestaccesstoken=aGAaBeGzkhXqw%2b3A0DxwV15Tc2jjBXAjF43opuG5z3E%3d&docid=1ad7771761446409cb252277f275250d0&rev=1" rel="nofollow - https://pslcrm-my.sharepoint.com/personal/arif_abdullah_parkersoftware_com/_layouts/15/guestaccess.aspx?guestaccesstoken=aGAaBeGzkhXqw%2b3A0DxwV15Tc2jjBXAjF43opuG5z3E%3d&docid=1ad7771761446409cb252277f275250d0&rev=1" ,
        "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" rel="nofollow - https://pslcrm-my.sharepoint.com/personal/arif_abdullah_parkersoftware_com/_layouts/15/guestaccess.aspx?guestaccesstoken=aGAaBeGzkhXqw%2b3A0DxwV15Tc2jjBXAjF43opuG5z3E%3d&docid=1ad7771761446409cb252277f275250d0&rev=1" },
            { "image" : " https://pslcrm-my.sharepoint.com/personal/arif_abdullah_parkersoftware_com/_layouts/15/guestaccess.aspx?guestaccesstoken=aGAaBeGzkhXqw%2b3A0DxwV15Tc2jjBXAjF43opuG5z3E%3d&docid=1ad7771761446409cb252277f275250d0&rev=1" rel="nofollow - 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.
 
$uri = “ https://outlook.office365.com/webhook/a918869d-cc2e-4e78-9cb9-81fda207c1fe@4a119ac2-5b1c-4d8c-815d-67c44778c928/IncomingWebhook/1e4900f72a0d4c8187eca23a246f1519/71374a88-d205-434d-b17e-1e644b7e4ac0�" rel="nofollow - https://outlook.office365.com/webhook/a918869d-cc2e-4e78-9cb9-81fda207c1fe@4a119ac2-5b1c-4d8c-815d-67c44778c928/IncomingWebhook/1e4900f72a0d4c8187eca23a246f1519/71374a88-d205-434d-b17e-1e644b7e4ac0� ��
$body = ConvertTo-JSON @{
    text = 'Hello Channel'
}
 
Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'

Advanced Hook using Powershell
$uri = “ https://outlook.office365.com/webhook/a918869d-cc2e-4e78-9cb9-81fda207c1fe@4a119ac2-5b1c-4d8c-815d-67c44778c928/IncomingWebhook/1e4900f72a0d4c8187eca23a246f1519/71374a88-d205-434d-b17e-1e644b7e4ac0�" rel="nofollow - https://outlook.office365.com/webhook/a918869d-cc2e-4e78-9cb9-81fda207c1fe@4a119ac2-5b1c-4d8c-815d-67c44778c928/IncomingWebhook/1e4900f72a0d4c8187eca23a246f1519/71374a88-d205-434d-b17e-1e644b7e4ac0� ��
 
# 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" rel="nofollow - 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" rel="nofollow - 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" rel="nofollow - 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'






-------------
Thanks,

Arif Abdullah
Technical Team Leader
Parker Software
www.parkersoftware.com



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.05 - http://www.webwizforums.com
Copyright ©2001-2016 Web Wiz Ltd. - https://www.webwiz.co.uk