Webhooks Cookbook - Microsoft Teams
The webhook use cases for Microsoft Teams that are referred to on this page are in regards to Approvals completed in the Microsoft Teams UI.
Â
Adding Webhooks in Microsoft Teams
See the Teams plugin configuration pages for information on how to set up FlexDeploy and Microsoft Teams.Â
Configuring FlexDeploy for Teams Webhook Operations
and
Configuring FlexDeploy for Teams Operations using User Credentials
Incoming
Provider Match Script
This provider match script for Microsoft Teams validates that it is a message from a card that FlexDeploy created.
Additional security checks are performed after match and before completing processing of approval tasks. These checks are in regards to the security that Microsoft provides on the incoming message, and the users and groups setup in FlexDeploy.
return HTTP_HEADERS.containsKey("flex-sync-webhook") && "TeamsTask".equals(HTTP_HEADERS.get("flex-sync-webhook"));
Function Script - Update Tasks from Teams Messages
Microsoft Teams Incoming Webhooks are validated and processed Synchronously. Behind the scenes, the JWT token is validated and the message is checked for unauthorized modification. The user that clicked the button is matched to a FlexDeploy user account behind the scenes using the JWT Token found in the HTTP Headers. If the matched user is authorized to approve/reject the linked FlexDeploy task, the task is approved or rejected and the card is updated to indicate that the task was processed.Â
Â
MICROSOFTTEAMS.updateTask(QUERY_PARAMS,HTTP_HEADERS,"<Teams Messaging Integration Account Code>");
Outgoing
Create Teams Approval Tasks
This sample sends an interactive message to a Microsoft Teams channel that allows members of the channel to approve or reject an associated FlexDeploy task. As shown in this script, you can add conditions to handle sending to multiple different channels in one listener depending on some condition. (e.g. environment, pipeline, release, etc.) You could also apply similar logic to the webhook listener filter to customize when and where the Teams message should be sent.
See the incoming samples also. An incoming webhook is needed to capture the button clicks that users perform on the Teams messages and ultimately approve/reject the task in FlexDeploy.
- style