Parker Software Ltd Homepage
Forum Home Forum Home > ThinkAutomation Business Process Automation > Samples
  New Posts New Posts RSS Feed - Setting Up Incoming Webhook into Microsoft Teams
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Setting Up Incoming Webhook into Microsoft Teams

 Post Reply Post Reply
Author
Message
arif.abdullah View Drop Down
Admin Group
Admin Group


Joined: 10 Nov 2016
Location: UK
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote arif.abdullah Quote  Post ReplyReply Direct Link To This Post Topic: Setting Up Incoming Webhook into Microsoft Teams
    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 to evaluate and check your JSon.
  11.  The available Microsoft Teams JSON variables can be found on 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%"
            }
          ] },
        "activitySubtitle" : "%Datetime%",
        "activityText" : "%msg_from%",
        "activityTitle" : "%msg_subject%"
      },
      { "title" : "<i>%msg_body%</i>" },
          ],
        "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"
    sections = @(
        @{
            activityTitle = 'Build'
            activitySubtitle = 'automated test platform'
            activityText = 'A change was evaluated and new results are available.'
        },
        @{
            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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.066 seconds.